Class: Basecamp::Services::ProjectsService
- Inherits:
-
BaseService
- Object
- BaseService
- Basecamp::Services::ProjectsService
- Defined in:
- lib/basecamp/generated/services/projects_service.rb
Overview
Service for Projects operations
Instance Method Summary collapse
-
#create(name:, description: nil) ⇒ Hash
Create a new project.
-
#get(project_id:) ⇒ Hash
Get a single project by id.
-
#list(status: nil) ⇒ Enumerator<Hash>
List projects (active by default; optionally archived/trashed).
-
#trash(project_id:) ⇒ void
Trash a project (returns 204 No Content).
-
#update(project_id:, name:, description: nil, admissions: nil, schedule_attributes: nil) ⇒ Hash
Update an existing project.
Constructor Details
This class inherits a constructor from Basecamp::Services::BaseService
Instance Method Details
#create(name:, description: nil) ⇒ Hash
Create a new project
24 25 26 27 28 |
# File 'lib/basecamp/generated/services/projects_service.rb', line 24 def create(name:, description: nil) with_operation(service: "projects", operation: "create", is_mutation: true) do http_post("/projects.json", body: compact_params(name: name, description: description)).json end end |
#get(project_id:) ⇒ Hash
Get a single project by id
33 34 35 36 37 |
# File 'lib/basecamp/generated/services/projects_service.rb', line 33 def get(project_id:) with_operation(service: "projects", operation: "get", is_mutation: false, project_id: project_id) do http_get("/projects/#{project_id}").json end end |
#list(status: nil) ⇒ Enumerator<Hash>
List projects (active by default; optionally archived/trashed)
13 14 15 16 17 18 |
# File 'lib/basecamp/generated/services/projects_service.rb', line 13 def list(status: nil) wrap_paginated(service: "projects", operation: "list", is_mutation: false) do params = compact_query_params(status: status) paginate("/projects.json", params: params) end end |
#trash(project_id:) ⇒ void
This method returns an undefined value.
Trash a project (returns 204 No Content)
55 56 57 58 59 60 |
# File 'lib/basecamp/generated/services/projects_service.rb', line 55 def trash(project_id:) with_operation(service: "projects", operation: "trash", is_mutation: true, project_id: project_id) do http_delete("/projects/#{project_id}") nil end end |
#update(project_id:, name:, description: nil, admissions: nil, schedule_attributes: nil) ⇒ Hash
Update an existing project
46 47 48 49 50 |
# File 'lib/basecamp/generated/services/projects_service.rb', line 46 def update(project_id:, name:, description: nil, admissions: nil, schedule_attributes: nil) with_operation(service: "projects", operation: "update", is_mutation: true, project_id: project_id) do http_put("/projects/#{project_id}", body: compact_params(name: name, description: description, admissions: admissions, schedule_attributes: schedule_attributes)).json end end |