Class: TrackerApi::Endpoints::Attachment
- Defined in:
- lib/tracker_api/endpoints/attachment.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create(comment, file) ⇒ Object
-
#get(comment) ⇒ Object
TODO : Discuss before implementing this as it orphans the file.
-
#initialize(client) ⇒ Attachment
constructor
A new instance of Attachment.
Constructor Details
#initialize(client) ⇒ Attachment
Returns a new instance of Attachment.
6 7 8 |
# File 'lib/tracker_api/endpoints/attachment.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/tracker_api/endpoints/attachment.rb', line 4 def client @client end |
Instance Method Details
#create(comment, file) ⇒ Object
10 11 12 13 |
# File 'lib/tracker_api/endpoints/attachment.rb', line 10 def create(comment, file) data = client.post("/projects/#{comment.project_id}/uploads", body: FileUtility.get_file_upload(file)).body Resources::FileAttachment.new({ comment: comment }.merge(data)) end |
#get(comment) ⇒ Object
TODO : Discuss before implementing this as it orphans the file. It deletes source, but the file name appears in the comments def delete(comment, file_attachment_id)
client.delete("/projects/#{comment.project_id}/stories/#{comment.story_id}/comments/#{comment.id}/file_attachments/#{}").body
end
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tracker_api/endpoints/attachment.rb', line 21 def get(comment) comment_target_slug = !comment.story_id.nil? ? "stories/#{comment.story_id}" : "epics/#{comment.epic_id}" data = client.get("/projects/#{comment.project_id}/#{comment_target_slug}/comments/#{comment.id}?fields=file_attachments").body["file_attachments"] raise Errors::UnexpectedData, 'Array of file attachments expected' unless data.is_a? Array data.map do || Resources::FileAttachment.new({ comment: comment }.merge()) end end |