Class: Basecamp::Services::TemplatesService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/basecamp/generated/services/templates_service.rb

Overview

Service for Templates operations

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Basecamp::Services::BaseService

Instance Method Details

#create(name:, description: nil) ⇒ Hash

Create a new template

Parameters:

  • name (String)

    name

  • description (String, nil) (defaults to: nil)

    description

Returns:

  • (Hash)

    response data



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)

Parameters:

  • template_id (Integer)

    template id ID

  • project (Hash)

    project

Returns:

  • (Hash)

    response data



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)

Parameters:

  • template_id (Integer)

    template id ID



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

Parameters:

  • template_id (Integer)

    template id ID

Returns:

  • (Hash)

    response data



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

Parameters:

  • template_id (Integer)

    template id ID

  • construction_id (Integer)

    construction id ID

Returns:

  • (Hash)

    response data



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

Parameters:

  • status (String, nil) (defaults to: nil)

    active|archived|trashed

Returns:

  • (Enumerator<Hash>)

    paginated results



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

Parameters:

  • template_id (Integer)

    template id ID

  • name (String, nil) (defaults to: nil)

    name

  • description (String, nil) (defaults to: nil)

    description

Returns:

  • (Hash)

    response data



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