Class: BugherdClient::Resources::V2::Attachment
- Defined in:
- lib/bugherd_client/resources/v2/attachment.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(project_id, task_id) ⇒ Object
LIST.
-
#create(project_id, task_id, payload) ⇒ Object
CREATE.
-
#delete(project_id, task_id, attachment_id) ⇒ Object
DELETE.
-
#find(project_id, task_id, attachment_id) ⇒ Object
SHOW.
-
#upload(project_id, task_id, payload) ⇒ Object
UPLOAD.
Methods inherited from Base
#api_methods, #converter, #initialize, #parse_response, #send_request
Constructor Details
This class inherits a constructor from BugherdClient::Resources::V2::Base
Instance Method Details
#all(project_id, task_id) ⇒ Object
LIST
Get a paginated list of attachments for a task. GET /api_v2/projects/#project_id/tasks/#task_id/attachments.json
11 12 13 14 |
# File 'lib/bugherd_client/resources/v2/attachment.rb', line 11 def all(project_id, task_id) raw_response = get_request("projects/#{project_id}/tasks/#{task_id}/attachments") parse_response(raw_response, :attachments) end |
#create(project_id, task_id, payload) ⇒ Object
CREATE
Adds a new attachment to the specified task using an existing URL. POST /api_v2/projects/#project_id/tasks/#task_id/attachments.json
PARAMS
'file_name':'resolution.gif',
'url':'http://i.imgur.com/U9h3jZI.gif'
}
35 36 37 38 |
# File 'lib/bugherd_client/resources/v2/attachment.rb', line 35 def create(project_id, task_id, payload) raw_response = post_request("projects/#{project_id}/tasks/#{task_id}/attachments", attachment: payload) parse_response(raw_response, :attachment) end |
#delete(project_id, task_id, attachment_id) ⇒ Object
DELETE
Delete an attachment from a task. Note that this action is permanent and cannot be undone. DELETE /api_v2/projects/#project_id/tasks/#task_id/attachments/#id.json
64 65 66 67 |
# File 'lib/bugherd_client/resources/v2/attachment.rb', line 64 def delete(project_id, task_id, ) raw_response = delete_request("projects/#{project_id}/tasks/#{task_id}/attachments/#{attachment_id}") parse_response(raw_response) end |
#find(project_id, task_id, attachment_id) ⇒ Object
SHOW
Get detail for specific attachment. GET /api_v2/projects/#project_id/tasks/#task_id/attachments/#id.json
20 21 22 23 |
# File 'lib/bugherd_client/resources/v2/attachment.rb', line 20 def find(project_id, task_id, ) raw_response = get_request("projects/#{project_id}/tasks/#{task_id}/attachments/#{attachment_id}") parse_response(raw_response) end |
#upload(project_id, task_id, payload) ⇒ Object
UPLOAD
Upload a new attachment and add it to the specified task. The file contents need to be specified as the POST data on this request.
Note that your upload needs to be reasonable in size as the maximum time the request may take is around 30 seconds. If you have larger uploads please create arrange your own file upload and create the attachment from a URL instead.
POST /api_v2/projects/#project_id/tasks/#task_id/attachments/upload
Note in the sample below please specify an existing file name.
53 54 55 56 57 58 |
# File 'lib/bugherd_client/resources/v2/attachment.rb', line 53 def upload(project_id, task_id, payload) uri = "projects/#{project_id}/tasks/#{task_id}/attachments/upload" headers = { content_type: 'application/binary' } raw_response = post_request(uri, payload.merge(headers: headers)) parse_response(raw_response, :attachment) end |