Class: Basecamp::Services::MessageTypesService

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

Overview

Service for MessageTypes operations

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#create(name:, icon:) ⇒ Hash

Create a new message type in a project

Parameters:

  • name (String)

    name

  • icon (String)

    icon

Returns:

  • (Hash)

    response data



22
23
24
25
26
# File 'lib/basecamp/generated/services/message_types_service.rb', line 22

def create(name:, icon:)
  with_operation(service: "messagetypes", operation: "create", is_mutation: true) do
    http_post("/categories.json", body: compact_params(name: name, icon: icon)).json
  end
end

#delete(type_id:) ⇒ void

This method returns an undefined value.

Delete a message type

Parameters:

  • type_id (Integer)

    type id ID



51
52
53
54
55
56
# File 'lib/basecamp/generated/services/message_types_service.rb', line 51

def delete(type_id:)
  with_operation(service: "messagetypes", operation: "delete", is_mutation: true, resource_id: type_id) do
    http_delete("/categories/#{type_id}")
    nil
  end
end

#get(type_id:) ⇒ Hash

Get a single message type by id

Parameters:

  • type_id (Integer)

    type id ID

Returns:

  • (Hash)

    response data



31
32
33
34
35
# File 'lib/basecamp/generated/services/message_types_service.rb', line 31

def get(type_id:)
  with_operation(service: "messagetypes", operation: "get", is_mutation: false, resource_id: type_id) do
    http_get("/categories/#{type_id}").json
  end
end

#listEnumerator<Hash>

List message types in a project

Returns:

  • (Enumerator<Hash>)

    paginated results



12
13
14
15
16
# File 'lib/basecamp/generated/services/message_types_service.rb', line 12

def list()
  wrap_paginated(service: "messagetypes", operation: "list", is_mutation: false) do
    paginate("/categories.json")
  end
end

#update(type_id:, name: nil, icon: nil) ⇒ Hash

Update an existing message type

Parameters:

  • type_id (Integer)

    type id ID

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

    name

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

    icon

Returns:

  • (Hash)

    response data



42
43
44
45
46
# File 'lib/basecamp/generated/services/message_types_service.rb', line 42

def update(type_id:, name: nil, icon: nil)
  with_operation(service: "messagetypes", operation: "update", is_mutation: true, resource_id: type_id) do
    http_put("/categories/#{type_id}", body: compact_params(name: name, icon: icon)).json
  end
end