Module: Camper::Client::MessageTypesAPI
- Included in:
- Camper::Client
- Defined in:
- lib/camper/api/message_types.rb
Overview
Defines methods related to message types.
Instance Method Summary collapse
-
#create_message_type(project, name, icon) ⇒ Resource
Create a messages type in a given project.
-
#delete_message_type(project, type) ⇒ Object
(also: #trash_message_type)
Delete a message type in a given project.
-
#message_type(project, message_type_id) ⇒ Resource
Get a messages type in a given project.
-
#message_types(project) ⇒ PaginatedResponse<Resource>
Get a paginated list of all messages types in a given project.
-
#update_message_type(project, type, options = {}) ⇒ Resource
Update a message type in a given project.
Instance Method Details
#create_message_type(project, name, icon) ⇒ Resource
Create a messages type in a given project
46 47 48 49 50 |
# File 'lib/camper/api/message_types.rb', line 46 def (project, name, icon) raise Error::InvalidParameter, 'Name and icon parameters cannot be blank' if name.blank? || icon.blank? post("/buckets/#{project.id}/categories", body: { name: name, icon: icon }) end |
#delete_message_type(project, type) ⇒ Object Also known as: trash_message_type
Delete a message type in a given project
81 82 83 84 85 |
# File 'lib/camper/api/message_types.rb', line 81 def (project, type) type_id = type.respond_to?(:id) ? type.id : type delete("/buckets/#{project.id}/categories/#{type_id}") end |
#message_type(project, message_type_id) ⇒ Resource
Get a messages type in a given project
31 32 33 |
# File 'lib/camper/api/message_types.rb', line 31 def (project, ) get("/buckets/#{project.id}/categories/#{}") end |
#message_types(project) ⇒ PaginatedResponse<Resource>
Get a paginated list of all messages types in a given project
16 17 18 |
# File 'lib/camper/api/message_types.rb', line 16 def (project) get("/buckets/#{project.id}/categories") end |
#update_message_type(project, type, options = {}) ⇒ Resource
Update a message type in a given project
65 66 67 68 69 70 71 |
# File 'lib/camper/api/message_types.rb', line 65 def (project, type, = {}) raise Error::InvalidParameter, 'options cannot be empty' if .empty? type_id = type.respond_to?(:id) ? type.id : type put("/buckets/#{project.id}/categories/#{type_id}", body: ) end |