Class: TrackerApi::Endpoints::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/tracker_api/endpoints/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Task

Returns a new instance of Task.



6
7
8
# File 'lib/tracker_api/endpoints/task.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/tracker_api/endpoints/task.rb', line 4

def client
  @client
end

Instance Method Details

#create(project_id, story_id, params = {}) ⇒ Object



10
11
12
13
# File 'lib/tracker_api/endpoints/task.rb', line 10

def create(project_id, story_id, params={})
  data = client.post("/projects/#{project_id}/stories/#{story_id}/tasks", params: params).body
  Resources::Task.new({ client: client }.merge(data))
end

#update(task, params = {}) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
# File 'lib/tracker_api/endpoints/task.rb', line 15

def update(task, params={})
  raise ArgumentError, 'Valid task required to update.' unless task.instance_of?(Resources::Task)

  data = client.put("/projects/#{task.project_id}/stories/#{task.story_id}/tasks/#{task.id}",
                    params: params).body

  task.attributes = data
  task.clean!
  task
end