Class: Wrike3::Attachment

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

Constant Summary collapse

CRLF =
"\r\n"

Instance Attribute Summary

Attributes included from Common

#wrike

Instance Method Summary collapse

Constructor Details

#initialize(wrike) ⇒ Attachment

Returns a new instance of Attachment.



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

def initialize(wrike)
  @wrike = wrike
end

Instance Method Details

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

Delete attachments



33
34
35
# File 'lib/wrike3/attachment.rb', line 33

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

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

Get attachment details



17
18
19
# File 'lib/wrike3/attachment.rb', line 17

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

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

Get file binary stream



28
29
30
# 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 = {}) ⇒ Object



12
13
14
# 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) ⇒ Object

Upload attachment for specified task



22
23
24
25
# 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