Class: Basecamp::Services::TemplatesService
- Inherits:
-
BaseService
- Object
- BaseService
- Basecamp::Services::TemplatesService
- Defined in:
- lib/basecamp/generated/services/templates_service.rb
Overview
Service for Templates operations
Instance Method Summary collapse
-
#create(name:, description: nil) ⇒ Hash
Create a new template.
-
#create_project(template_id:, project:) ⇒ Hash
Create a project from a template (asynchronous).
-
#delete(template_id:) ⇒ void
Delete a template (trash it).
-
#get(template_id:) ⇒ Hash
Get a single template by id.
-
#get_construction(template_id:, construction_id:) ⇒ Hash
Get the status of a project construction.
-
#list(status: nil) ⇒ Enumerator<Hash>
List all templates visible to the current user.
-
#update(template_id:, name: nil, description: nil) ⇒ Hash
Update an existing template.
Constructor Details
This class inherits a constructor from Basecamp::Services::BaseService
Instance Method Details
#create(name:, description: nil) ⇒ Hash
Create a new template
24 25 26 27 28 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 24 def create(name:, description: nil) with_operation(service: "templates", operation: "create", is_mutation: true) do http_post("/templates.json", body: compact_params(name: name, description: description)).json end end |
#create_project(template_id:, project:) ⇒ Hash
Create a project from a template (asynchronous)
64 65 66 67 68 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 64 def create_project(template_id:, project:) with_operation(service: "templates", operation: "create_project", is_mutation: true, resource_id: template_id) do http_post("/templates/#{template_id}/project_constructions.json", body: compact_params(project: project)).json end end |
#delete(template_id:) ⇒ void
This method returns an undefined value.
Delete a template (trash it)
53 54 55 56 57 58 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 53 def delete(template_id:) with_operation(service: "templates", operation: "delete", is_mutation: true, resource_id: template_id) do http_delete("/templates/#{template_id}") nil end end |
#get(template_id:) ⇒ Hash
Get a single template by id
33 34 35 36 37 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 33 def get(template_id:) with_operation(service: "templates", operation: "get", is_mutation: false, resource_id: template_id) do http_get("/templates/#{template_id}").json end end |
#get_construction(template_id:, construction_id:) ⇒ Hash
Get the status of a project construction
74 75 76 77 78 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 74 def get_construction(template_id:, construction_id:) with_operation(service: "templates", operation: "get_construction", is_mutation: false, resource_id: construction_id) do http_get("/templates/#{template_id}/project_constructions/#{construction_id}").json end end |
#list(status: nil) ⇒ Enumerator<Hash>
List all templates visible to the current user
13 14 15 16 17 18 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 13 def list(status: nil) wrap_paginated(service: "templates", operation: "list", is_mutation: false) do params = compact_query_params(status: status) paginate("/templates.json", params: params) end end |
#update(template_id:, name: nil, description: nil) ⇒ Hash
Update an existing template
44 45 46 47 48 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 44 def update(template_id:, name: nil, description: nil) with_operation(service: "templates", operation: "update", is_mutation: true, resource_id: template_id) do http_put("/templates/#{template_id}", body: compact_params(name: name, description: description)).json end end |