Module: Catch::Media
- Included in:
- Client
- Defined in:
- lib/catch/media.rb
Instance Method Summary collapse
-
#add_media(id, filepath, params = {}) ⇒ Object
Adds a file to a note.
-
#delete_media(note_id, media_id) ⇒ Object
Deletes a file attachment from a note.
-
#media(note_id, media_id, params = {}) ⇒ Object
Return the media file.
Instance Method Details
#add_media(id, filepath, params = {}) ⇒ Object
Adds a file to a note.
13 14 15 16 17 |
# File 'lib/catch/media.rb', line 13 def add_media(id, filepath, params={}) params.merge!({:data => Faraday::UploadIO.new(filepath, 'image/jpeg')}) connection.put("media/#{id}", params).body end |
#delete_media(note_id, media_id) ⇒ Object
Deletes a file attachment from a note
39 40 41 |
# File 'lib/catch/media.rb', line 39 def delete_media(note_id, media_id) connection.delete("media/#{note_id}/#{media_id}").body.status == 'ok' end |
#media(note_id, media_id, params = {}) ⇒ Object
Return the media file
small images are at most 128 pixels in the longer dimension. medium images are at most 800 pixels in the longer dimension. large images are at most 9999 pixels in the longer dimension.
28 29 30 31 32 33 |
# File 'lib/catch/media.rb', line 28 def media(note_id, media_id, params={}) media_connection.get do |req| req.url("media/#{note_id}/#{media_id}") req.params.merge!(params) end.body end |