Class: Asana::Workspace
- Defined in:
- lib/asana/resources/workspace.rb
Instance Method Summary collapse
- #create_tag(options = {}) ⇒ Object
- #create_task(options = {}) ⇒ Object
-
#find_or_create_tag(options = {}) ⇒ Object
TODO imporve this when Asana API is more advanced.
- #tags ⇒ Object
-
#tasks(options = {}) ⇒ Object
From API docs: If you specify a workspace you must also specify an assignee to filter on.
Methods inherited from Resource
collection_path, custom_method_collection_url, element_path, #method_not_allowed, new_element_path, #reload, remove_json_extension, singleton_path, #to_json
Instance Method Details
#create_tag(options = {}) ⇒ Object
34 35 36 37 |
# File 'lib/asana/resources/workspace.rb', line 34 def create_tag( = {}) response = post("tags", nil, {data: }.to_json) Asana::Tag.new(connection.format.decode(response.body)) end |
#create_task(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/asana/resources/workspace.rb', line 4 def create_task( = {}) # options.merge!(assignee: 'me') unless options[:assignee] or options['assignee'] .merge!(workspace: self.id) post_body = { data: } response = Task.post(nil, nil, post_body.to_json) hash = connection.format.decode(response.body) # want to return a persisted record Task.find hash["id"] rescue Exception => e $stderr.puts "ERROR: #{e.}" $stderr.puts "RESPONSE: #{e.response.body}" if e.respond_to?(:response) end |
#find_or_create_tag(options = {}) ⇒ Object
TODO imporve this when Asana API is more advanced
30 31 32 |
# File 'lib/asana/resources/workspace.rb', line 30 def find_or_create_tag( = {}) .find {|t| t.name == [:name]} || create_tag() end |
#tags ⇒ Object
39 40 41 |
# File 'lib/asana/resources/workspace.rb', line 39 def get(:tags).map{|h| Asana::Tag.find h["id"]} end |
#tasks(options = {}) ⇒ Object
From API docs: If you specify a workspace you must also specify an assignee to filter on.
20 21 22 23 24 25 26 27 |
# File 'lib/asana/resources/workspace.rb', line 20 def tasks( = {}) .merge!(assignee: 'me') unless [:assignee] or ['assignee'] get("tasks?assignee=#{[:assignee]}").map{|h| Asana::Task.find h["id"]} rescue Exception => e $stderr.puts "ERROR: #{e.}" $stderr.puts "RESPONSE: #{e.response.body}" if e.respond_to?(:response) end |