class Wrike3::Attachment
Constants
- CRLF
Public Class Methods
new(wrike)
click to toggle source
# File lib/wrike3/attachment.rb, line 8 def initialize(wrike) @wrike = wrike end
Public Instance Methods
delete(id, params = {})
click to toggle source
Delete attachments
# File lib/wrike3/attachment.rb, line 33 def delete(id, params = {}) wrike.execute(:delete, api_url("attachments/#{id}"), params) end
details(id, params = {})
click to toggle source
Get attachment details
# File lib/wrike3/attachment.rb, line 17 def details(id, params = {}) wrike.execute(:get, api_url("attachments/#{id}"), params) end
download(id, params = {})
click to toggle source
Get file binary stream
# File lib/wrike3/attachment.rb, line 28 def download(id, params = {}) wrike.execute(:get, api_url("attachments/#{id}/download"), params) end
list(attachable_type = nil, attachable_id = nil, params = {})
click to toggle source
# File lib/wrike3/attachment.rb, line 12 def list(attachable_type = nil, attachable_id = nil, params = {}) wrike.execute(:get, api_url(nested_path('attachments', attachable_type, attachable_id)), params) end
upload(attachable_type, attachable_id, params)
click to toggle source
Upload attachment for specified task
# File lib/wrike3/attachment.rb, line 22 def upload(attachable_type, attachable_id, params) body, headers = http_multipart_data(params) wrike.execute(:post, api_url(nested_path('attachments', attachable_type, attachable_id)), {}, headers, true, body) end
Private Instance Methods
http_multipart_data(params = {})
click to toggle source
# File lib/wrike3/attachment.rb, line 39 def http_multipart_data(params = {}) headers = { 'X-Requested-With' => 'XMLHttpRequest', 'X-File-Name' => params['file_name'], 'Content-Type' => params['content_type'] } return params['stream'], headers end