Class: FreeAgent::TasksResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/free_agent/resources/tasks.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from FreeAgent::Resource

Instance Method Details

#create(project:, name:, **params) ⇒ Object



19
20
21
22
23
24
# File 'lib/free_agent/resources/tasks.rb', line 19

def create(project:, name:,  **params)
  attributes = {project: project, name: name}

  response = post_request("tasks", body: attributes.merge(params))
  Task.new(response.body["task"]) if response.success?
end

#delete(id:) ⇒ Object



31
32
33
34
# File 'lib/free_agent/resources/tasks.rb', line 31

def delete(id:)
  response = delete_request("tasks/#{id}")
  response.success?
end

#list(**params) ⇒ Object



4
5
6
7
# File 'lib/free_agent/resources/tasks.rb', line 4

def list(**params)
  response = get_request("tasks", params: params)
  Collection.from_response(response, type: Task, key: "tasks")
end

#list_for_project(project:, **params) ⇒ Object



9
10
11
12
# File 'lib/free_agent/resources/tasks.rb', line 9

def list_for_project(project:, **params)
  response = get_request("tasks?project=#{project}", params: params)
  Collection.from_response(response, type: Task, key: "tasks")
end

#retrieve(id:) ⇒ Object



14
15
16
17
# File 'lib/free_agent/resources/tasks.rb', line 14

def retrieve(id:)
  response = get_request("tasks/#{id}")
  Task.new(response.body["task"])
end

#update(id:, **params) ⇒ Object



26
27
28
29
# File 'lib/free_agent/resources/tasks.rb', line 26

def update(id:, **params)
  response = put_request("tasks/#{id}", body: params)
  Task.new(response.body["task"]) if response.success?
end