Class: Asana::Resources::Tag
- Defined in:
- lib/asana/resources/tag.rb
Overview
A tag is a label that can be attached to any task in Asana. It exists in a single workspace or organization.
Tags have some metadata associated with them, but it is possible that we will simplify them in the future so it is not encouraged to rely too heavily on it. Unlike projects, tags do not provide any ordering on the tasks they are associated with.
Instance Attribute Summary collapse
- #color ⇒ Object readonly
- #created_at ⇒ Object readonly
- #followers ⇒ Object readonly
- #gid ⇒ Object readonly
- #id ⇒ Object readonly
- #name ⇒ Object readonly
- #resource_type ⇒ Object readonly
- #workspace ⇒ Object readonly
Class Method Summary collapse
-
.create(client, workspace: required("workspace"), options: {}, **data) ⇒ Object
Creates a new tag in a workspace or organization.
-
.create_in_workspace(client, workspace: required("workspace"), options: {}, **data) ⇒ Object
Creates a new tag in a workspace or organization.
-
.find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact tag records for some filtered set of tags.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete tag record for a single tag.
-
.find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) ⇒ Object
Returns the compact tag records for all tags in the workspace.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#delete ⇒ Object
A specific, existing tag can be deleted by making a DELETE request on the URL for that tag.
-
#get_tasks_with_tag(per_page: 20, options: {}) ⇒ Object
Returns the compact task records for all tasks with the given tag.
-
#update(options: {}, **data) ⇒ Object
Updates the properties of a tag.
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
#color ⇒ Object (readonly)
28 29 30 |
# File 'lib/asana/resources/tag.rb', line 28 def color @color end |
#created_at ⇒ Object (readonly)
22 23 24 |
# File 'lib/asana/resources/tag.rb', line 22 def created_at @created_at end |
#followers ⇒ Object (readonly)
24 25 26 |
# File 'lib/asana/resources/tag.rb', line 24 def followers @followers end |
#gid ⇒ Object (readonly)
18 19 20 |
# File 'lib/asana/resources/tag.rb', line 18 def gid @gid end |
#id ⇒ Object (readonly)
16 17 18 |
# File 'lib/asana/resources/tag.rb', line 16 def id @id end |
#name ⇒ Object (readonly)
26 27 28 |
# File 'lib/asana/resources/tag.rb', line 26 def name @name end |
#resource_type ⇒ Object (readonly)
20 21 22 |
# File 'lib/asana/resources/tag.rb', line 20 def resource_type @resource_type end |
#workspace ⇒ Object (readonly)
30 31 32 |
# File 'lib/asana/resources/tag.rb', line 30 def workspace @workspace end |
Class Method Details
.create(client, workspace: required("workspace"), options: {}, **data) ⇒ Object
Creates a new tag in a workspace or organization.
Every tag is required to be created in a specific workspace or organization, and this cannot be changed once set. Note that you can use the ‘workspace` parameter regardless of whether or not it is an organization.
50 51 52 53 |
# File 'lib/asana/resources/tag.rb', line 50 def create(client, workspace: required("workspace"), options: {}, **data) with_params = data.merge(workspace: workspace).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/tags", body: with_params, options: )).first, client: client) end |
.create_in_workspace(client, workspace: required("workspace"), options: {}, **data) ⇒ Object
Creates a new tag in a workspace or organization.
Every tag is required to be created in a specific workspace or organization, and this cannot be changed once set. Note that you can use the ‘workspace` parameter regardless of whether or not it is an organization.
67 68 69 70 |
# File 'lib/asana/resources/tag.rb', line 67 def create_in_workspace(client, workspace: required("workspace"), options: {}, **data) self.new(parse(client.post("/workspaces/#{workspace}/tags", body: data, options: )).first, client: client) end |
.find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact tag records for some filtered set of tags. Use one or more of the parameters provided to filter the tags returned.
91 92 93 94 |
# File 'lib/asana/resources/tag.rb', line 91 def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {}) params = { workspace: workspace, team: team, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tags", params: params, options: )), type: self, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete tag record for a single tag.
76 77 78 79 |
# File 'lib/asana/resources/tag.rb', line 76 def find_by_id(client, id, options: {}) self.new(parse(client.get("/tags/#{id}", options: )).first, client: client) end |
.find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) ⇒ Object
Returns the compact tag records for all tags in the workspace.
101 102 103 104 |
# File 'lib/asana/resources/tag.rb', line 101 def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/tags", params: params, options: )), type: self, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
34 35 36 |
# File 'lib/asana/resources/tag.rb', line 34 def plural_name 'tags' end |
Instance Method Details
#delete ⇒ Object
A specific, existing tag can be deleted by making a DELETE request on the URL for that tag.
127 128 129 130 |
# File 'lib/asana/resources/tag.rb', line 127 def delete() client.delete("/tags/#{gid}") && true end |
#get_tasks_with_tag(per_page: 20, options: {}) ⇒ Object
Returns the compact task records for all tasks with the given tag. Tasks can have more than one tag at a time.
137 138 139 140 |
# File 'lib/asana/resources/tag.rb', line 137 def get_tasks_with_tag(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tags/#{gid}/tasks", params: params, options: )), type: Task, client: client) end |
#update(options: {}, **data) ⇒ Object
Updates the properties of a tag. Only the fields provided in the ‘data` block will be updated; any unspecified fields will remain unchanged.
When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the task.
118 119 120 121 |
# File 'lib/asana/resources/tag.rb', line 118 def update(options: {}, **data) refresh_with(parse(client.put("/tags/#{gid}", body: data, options: )).first) end |