Class: Asana::Resources::Story
- 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
- #created_at ⇒ Object readonly
- #created_by ⇒ Object readonly
-
#hearted ⇒ Object
readonly
DEPRECATED: prefer “liked”.
-
#hearts ⇒ Object
readonly
DEPRECATED: prefer “likes”.
- #html_text ⇒ Object readonly
- #id ⇒ Object readonly
- #is_edited ⇒ Object readonly
- #is_pinned ⇒ Object readonly
- #liked ⇒ Object readonly
- #likes ⇒ Object readonly
-
#num_hearts ⇒ Object
readonly
DEPRECATED: prefer “num_likes”.
- #num_likes ⇒ Object readonly
- #source ⇒ Object readonly
- #target ⇒ Object readonly
- #text ⇒ Object readonly
- #type ⇒ Object readonly
Class Method Summary collapse
-
.create_on_task(client, task: required("task"), text: required("text"), options: {}, **data) ⇒ Object
Adds a comment to a task.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full record for a single story.
-
.find_by_task(client, task: required("task"), per_page: 20, options: {}) ⇒ Object
Returns the compact records for all stories on the task.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes a story.
-
#update(text: nil, html_text: nil, is_pinned: nil, options: {}, **data) ⇒ Object
Updates the story and returns the full record for the updated story.
Methods inherited from Resource
inherited, #initialize, #method_missing, #refresh, #respond_to_missing?, #to_h, #to_s
Methods included from ResponseHelper
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
#created_at ⇒ Object (readonly)
18 19 20 |
# File 'lib/asana/resources/story.rb', line 18 def created_at @created_at end |
#created_by ⇒ Object (readonly)
20 21 22 |
# File 'lib/asana/resources/story.rb', line 20 def created_by @created_by end |
#hearted ⇒ Object (readonly)
DEPRECATED: prefer “liked”
23 24 25 |
# File 'lib/asana/resources/story.rb', line 23 def hearted @hearted end |
#hearts ⇒ Object (readonly)
DEPRECATED: prefer “likes”
26 27 28 |
# File 'lib/asana/resources/story.rb', line 26 def hearts @hearts end |
#html_text ⇒ Object (readonly)
39 40 41 |
# File 'lib/asana/resources/story.rb', line 39 def html_text @html_text end |
#id ⇒ Object (readonly)
16 17 18 |
# File 'lib/asana/resources/story.rb', line 16 def id @id end |
#is_edited ⇒ Object (readonly)
45 46 47 |
# File 'lib/asana/resources/story.rb', line 45 def is_edited @is_edited end |
#is_pinned ⇒ Object (readonly)
43 44 45 |
# File 'lib/asana/resources/story.rb', line 43 def is_pinned @is_pinned end |
#liked ⇒ Object (readonly)
31 32 33 |
# File 'lib/asana/resources/story.rb', line 31 def liked @liked end |
#likes ⇒ Object (readonly)
33 34 35 |
# File 'lib/asana/resources/story.rb', line 33 def likes @likes end |
#num_hearts ⇒ Object (readonly)
DEPRECATED: prefer “num_likes”
29 30 31 |
# File 'lib/asana/resources/story.rb', line 29 def num_hearts @num_hearts end |
#num_likes ⇒ Object (readonly)
35 36 37 |
# File 'lib/asana/resources/story.rb', line 35 def num_likes @num_likes end |
#source ⇒ Object (readonly)
47 48 49 |
# File 'lib/asana/resources/story.rb', line 47 def source @source end |
#target ⇒ Object (readonly)
41 42 43 |
# File 'lib/asana/resources/story.rb', line 41 def target @target end |
#text ⇒ Object (readonly)
37 38 39 |
# File 'lib/asana/resources/story.rb', line 37 def text @text end |
#type ⇒ Object (readonly)
49 50 51 |
# File 'lib/asana/resources/story.rb', line 49 def type @type 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.
89 90 91 92 |
# File 'lib/asana/resources/story.rb', line 89 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: )).first, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full record for a single story.
73 74 75 76 |
# File 'lib/asana/resources/story.rb', line 73 def find_by_id(client, id, options: {}) self.new(parse(client.get("/stories/#{id}", 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.
63 64 65 66 |
# File 'lib/asana/resources/story.rb', line 63 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: )), type: self, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
53 54 55 |
# File 'lib/asana/resources/story.rb', line 53 def plural_name 'stories' end |
Instance Method Details
#delete ⇒ Object
Deletes a story. A user can only delete stories they have created. Returns an empty data record.
111 112 113 114 |
# File 'lib/asana/resources/story.rb', line 111 def delete() client.delete("/stories/#{id}") && true end |
#update(text: nil, html_text: nil, is_pinned: nil, options: {}, **data) ⇒ Object
Updates the story and returns the full record for the updated story. Only comment stories can have their text updated, and only comment stories and attachment stories can be pinned. Only one of ‘text` and `html_text` can be specified.
105 106 107 108 |
# File 'lib/asana/resources/story.rb', line 105 def update(text: nil, html_text: nil, is_pinned: nil, options: {}, **data) with_params = data.merge(text: text, html_text: html_text, is_pinned: is_pinned).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.put("/stories/#{id}", body: with_params, options: )).first) end |