Class: Asana::Resources::Section
- Defined in:
- lib/asana/resources/section.rb
Overview
A section is a subdivision of a project that groups tasks together. It can either be a header above a list of tasks in a list view or a column in a board view of a project.
Instance Attribute Summary collapse
- #created_at ⇒ Object readonly
- #id ⇒ Object readonly
- #name ⇒ Object readonly
- #project ⇒ Object readonly
Class Method Summary collapse
-
.create_in_project(client, project: required("project"), name: required("name"), options: {}, **data) ⇒ Object
Creates a new section in a project.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete record for a single section.
-
.find_by_project(client, project: required("project"), options: {}) ⇒ Object
Returns the compact records for all sections in the specified project.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#delete ⇒ Object
A specific, existing section can be deleted by making a DELETE request on the URL for that section.
-
#insert_in_project(project: required("project"), before_section: nil, after_section: nil, options: {}, **data) ⇒ Object
Move sections relative to each other in a board view.
-
#update(options: {}, **data) ⇒ Object
A specific, existing section can be updated by making a PUT request on the URL for that project.
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/section.rb', line 18 def created_at @created_at end |
#id ⇒ Object (readonly)
12 13 14 |
# File 'lib/asana/resources/section.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
14 15 16 |
# File 'lib/asana/resources/section.rb', line 14 def name @name end |
#project ⇒ Object (readonly)
16 17 18 |
# File 'lib/asana/resources/section.rb', line 16 def project @project end |
Class Method Details
.create_in_project(client, project: required("project"), name: required("name"), options: {}, **data) ⇒ Object
Creates a new section in a project.
34 35 36 37 |
# File 'lib/asana/resources/section.rb', line 34 def create_in_project(client, project: required("project"), name: required("name"), options: {}, **data) with_params = data.merge(name: name).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/projects/#{project}/sections", body: with_params, options: )).first, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete record for a single section.
52 53 54 55 |
# File 'lib/asana/resources/section.rb', line 52 def find_by_id(client, id, options: {}) self.new(parse(client.get("/sections/#{id}", options: )).first, client: client) end |
.find_by_project(client, project: required("project"), options: {}) ⇒ Object
Returns the compact records for all sections in the specified project.
43 44 45 46 |
# File 'lib/asana/resources/section.rb', line 43 def find_by_project(client, project: required("project"), options: {}) self.new(parse(client.get("/projects/#{project}/sections", options: )).first, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
22 23 24 |
# File 'lib/asana/resources/section.rb', line 22 def plural_name 'sections' end |
Instance Method Details
#delete ⇒ Object
A specific, existing section can be deleted by making a DELETE request on the URL for that section.
Note that sections must be empty to be deleted.
The last remaining section in a board view cannot be deleted.
84 85 86 87 |
# File 'lib/asana/resources/section.rb', line 84 def delete() client.delete("/sections/#{id}") && true end |
#insert_in_project(project: required("project"), before_section: nil, after_section: nil, options: {}, **data) ⇒ Object
Move sections relative to each other in a board view. One of ‘before_section` or `after_section` is required.
Sections cannot be moved between projects.
At this point in time, moving sections is not supported in list views, only board views.
103 104 105 106 |
# File 'lib/asana/resources/section.rb', line 103 def insert_in_project(project: required("project"), before_section: nil, after_section: nil, options: {}, **data) with_params = data.merge(before_section: before_section, after_section: after_section).reject { |_,v| v.nil? || Array(v).empty? } client.post("/projects/#{project}/sections/insert", body: with_params, options: ) && true end |
#update(options: {}, **data) ⇒ Object
A specific, existing section can be updated by making a PUT request on the URL for that project. Only the fields provided in the ‘data` block will be updated; any unspecified fields will remain unchanged. (note that at this time, the only field that can be updated is the `name` field.)
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.
71 72 73 74 |
# File 'lib/asana/resources/section.rb', line 71 def update(options: {}, **data) refresh_with(parse(client.put("/sections/#{id}", body: data, options: )).first) end |