Class: Asana::Resources::Attachment

Inherits:
Resource
  • Object
show all
Defined in:
lib/asana/resources/attachment.rb

Overview

An attachment object represents any file attached to a task in Asana, whether it’s an uploaded file or one associated via a third-party service such as Dropbox or Google Drive.

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Resource

inherited, #initialize, #method_missing, #refresh, #respond_to_missing?, #to_h, #to_s

Methods included from ResponseHelper

#parse

Constructor Details

This class inherits a constructor from Asana::Resources::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Asana::Resources::Resource

Instance Attribute Details

#idObject (readonly)



12
13
14
# File 'lib/asana/resources/attachment.rb', line 12

def id
  @id
end

Class Method Details

.find_by_id(client, id, options: {}) ⇒ Object

Returns the full record for a single attachment.

Parameters:

  • id (Id)

    Globally unique identifier for the attachment.

  • options (Hash) (defaults to: {})

    the request I/O options.



25
26
27
28
# File 'lib/asana/resources/attachment.rb', line 25

def find_by_id(client, id, options: {})

  self.new(parse(client.get("/attachments/#{id}", options: options)).first, client: client)
end

.find_by_task(client, task: required("task"), per_page: 20, options: {}) ⇒ Object

Returns the compact records for all attachments on the task.

Parameters:

  • task (Id) (defaults to: required("task"))

    Globally unique identifier for the task.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



36
37
38
39
# File 'lib/asana/resources/attachment.rb', line 36

def find_by_task(client, task: required("task"), per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/tasks/#{task}/attachments", params: params, options: options)), type: self, client: client)
end

.plural_nameObject

Returns the plural name of the resource.



16
17
18
# File 'lib/asana/resources/attachment.rb', line 16

def plural_name
  'attachments'
end