Module: Camper::Client::MessagesAPI
- Included in:
- Camper::Client
- Defined in:
- lib/camper/api/messages.rb
Overview
Defines methods related to messages.
Instance Method Summary collapse
-
#create_message(parent, subject, options = {}) ⇒ Resource
Create a message.
-
#message(parent, message_id) ⇒ Resource
Get a paginated list of active messages under the given message board or project.
-
#messages(parent) ⇒ PaginatedResponse<Resource>
Get a paginated list of active messages under the given message board or project.
-
#trash_message(message) ⇒ Object
Trash message it calls the trash_recording endpoint under the hood.
-
#update_message(message, options = {}) ⇒ Resource
Update a message.
Instance Method Details
#create_message(parent, subject, options = {}) ⇒ Resource
Create a message
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/camper/api/messages.rb', line 60 def (parent, subject, = {}) if parent.is_a?(Project) bucket_id, board_id = parent.id, parent..id else bucket_id, board_id = parent.bucket.id, parent.id end post( "/buckets/#{bucket_id}/message_boards/#{board_id}/messages", body: .merge({ subject: subject, status: 'active' }) ) end |
#message(parent, message_id) ⇒ Resource
Get a paginated list of active messages under the given message board or project
39 40 41 42 43 |
# File 'lib/camper/api/messages.rb', line 39 def (parent, ) bucket_id = parent.is_a?(Project) ? parent.id : parent.bucket.id get("/buckets/#{bucket_id}/messages/#{}") end |
#messages(parent) ⇒ PaginatedResponse<Resource>
Get a paginated list of active messages under the given message board or project
18 19 20 21 22 23 24 25 26 |
# File 'lib/camper/api/messages.rb', line 18 def (parent) if parent.is_a?(Project) bucket_id, board_id = parent.id, parent..id else bucket_id, board_id = parent.bucket.id, parent.id end get("/buckets/#{bucket_id}/message_boards/#{board_id}/messages") end |
#trash_message(message) ⇒ Object
Trash message
it calls the trash_recording endpoint under the hood
103 104 105 |
# File 'lib/camper/api/messages.rb', line 103 def () trash_recording() end |
#update_message(message, options = {}) ⇒ Resource
Update a message
87 88 89 90 91 |
# File 'lib/camper/api/messages.rb', line 87 def (, = {}) raise Error::InvalidParameter, 'options cannot be empty' if .empty? update("/buckets/#{.bucket.id}/messages/#{.id}", body: ) end |