Class: Wrike3::Attachment

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/wrike3/attachment.rb

Instance Attribute Summary

Attributes included from Common

#wrike

Instance Method Summary collapse

Constructor Details

#initialize(wrike) ⇒ Attachment

Returns a new instance of Attachment.



5
6
7
# File 'lib/wrike3/attachment.rb', line 5

def initialize(wrike)
  @wrike = wrike
end

Instance Method Details

#delete(id, options = {}) ⇒ Object

Delete attachments



30
31
32
# File 'lib/wrike3/attachment.rb', line 30

def delete(id, options={})
  wrike.execute(:delete, api_url("attachments/#{id}"), options)
end

#details(id, options = {}) ⇒ Object

Get attachment details



14
15
16
# File 'lib/wrike3/attachment.rb', line 14

def details(id, options={})
  wrike.execute(:get, api_url("attachments/#{id}"), options)
end

#download(id, options = {}) ⇒ Object

Get file binary stream



25
26
27
# File 'lib/wrike3/attachment.rb', line 25

def download(id, options={})
  wrike.execute(:get, api_url("attachments/#{id}/download"), options)
end

#list(attachable_type = nil, attachable_id = nil, options = {}) ⇒ Object



9
10
11
# File 'lib/wrike3/attachment.rb', line 9

def list(attachable_type = nil, attachable_id = nil, options={})
  wrike.execute(:get, api_url(nested_path('attachments', attachable_type, attachable_id)), options)
end

#upload(attachable_type, attachable_id, stream, options = {}) ⇒ Object

Upload attachment for specified task



19
20
21
22
# File 'lib/wrike3/attachment.rb', line 19

def upload(attachable_type, attachable_id, stream, options={})
  body, headers = http_multipart_data({:stream => stream})
  wrike.execute(:post, api_url(nested_path('attachments', attachable_type, attachable_id)), body, headers)
end