Class: Asana::Resources::Story

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

Overview

A story represents an activity associated with an object in the Asana system. Stories are generated by the system whenever users take actions such as creating or assigning tasks, or moving tasks between projects. Comments are also a form of user-generated story.

Stories are a form of history in the system, and as such they are read-only. Once generated, it is not possible to modify a story.

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)



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

def id
  @id
end

Class Method Details

.create_on_task(client, task: required("task"), text: required("text"), options: {}, **data) ⇒ Object

Adds a comment to a task. The comment will be authored by the currently authenticated user, and timestamped when the server receives the request.

Parameters:

  • Returns

    the full record for the new story added to the task.

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

    Globally unique identifier for the task.

  • text (String) (defaults to: required("text"))

    The plain text of the comment to add.

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

    the request I/O options.

  • data (Hash)

    the attributes to post.



56
57
58
59
# File 'lib/asana/resources/story.rb', line 56

def create_on_task(client, task: required("task"), text: required("text"), options: {}, **data)
  with_params = data.merge(text: text).reject { |_,v| v.nil? || Array(v).empty? }
  self.new(parse(client.post("/tasks/#{task}/stories", body: with_params, options: options)).first, client: client)
end

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

Returns the full record for a single story.

Parameters:

  • id (Id)

    Globally unique identifier for the team.

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

    the request I/O options.



29
30
31
32
# File 'lib/asana/resources/story.rb', line 29

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

  self.new(parse(client.get("/stories/#{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 stories 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.



40
41
42
43
# File 'lib/asana/resources/story.rb', line 40

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}/stories", params: params, options: options)), type: self, client: client)
end

.plural_nameObject

Returns the plural name of the resource.



20
21
22
# File 'lib/asana/resources/story.rb', line 20

def plural_name
  'stories'
end