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, page: nil, max_items: nil) ⇒ ListEnumerator<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
26 27 28 29 30 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 26 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)
66 67 68 69 70 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 66 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)
55 56 57 58 59 60 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 55 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
35 36 37 38 39 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 35 def get(template_id:) with_operation(service: "templates", operation: "get", is_mutation: false, resource_id: template_id) do http_get("/templates/#{template_id}", operation: "GetTemplate").json end end |
#get_construction(template_id:, construction_id:) ⇒ Hash
Get the status of a project construction
76 77 78 79 80 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 76 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}", operation: "GetProjectConstruction").json end end |
#list(status: nil, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>
List all templates visible to the current user
15 16 17 18 19 20 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 15 def list(status: nil, page: nil, max_items: nil) wrap_paginated(service: "templates", operation: "list", is_mutation: false) do params = compact_query_params(status: status, page: page) paginate("/templates.json", params: params, operation: "ListTemplates", max_items: max_items) end end |
#update(template_id:, name: nil, description: nil) ⇒ Hash
Update an existing template
46 47 48 49 50 |
# File 'lib/basecamp/generated/services/templates_service.rb', line 46 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 |