Class: TrackerApi::Endpoints::Iteration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Iteration

Returns a new instance of Iteration.



6
7
8
# File 'lib/tracker_api/endpoints/iteration.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/iteration.rb', line 4

def client
  @client
end

Instance Method Details

#get(project_id, iteration_number) ⇒ Object



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

def get(project_id, iteration_number)
  data = client.get("/projects/#{project_id}/iterations/#{iteration_number}").body

  Resources::Iteration.new({ client: client, project_id: project_id }.merge(data))
end

#get_analytics_cycle_time_details(project_id, iteration_number) ⇒ Object



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

def get_analytics_cycle_time_details(project_id, iteration_number)
  data = client.paginate("/projects/#{project_id}/iterations/#{iteration_number}/analytics/cycle_time_details")
  raise Errors::UnexpectedData, 'Array of cycle time details expected' unless data.is_a? Array

  data.map do |cycle_time_details|
    Resources::CycleTimeDetails.new(
      { project_id: project_id, iteration_number: iteration_number }.merge(cycle_time_details)
    )
  end
end

#get_history(project_id, iteration_number) ⇒ Object



27
28
29
30
31
32
# File 'lib/tracker_api/endpoints/iteration.rb', line 27

def get_history(project_id, iteration_number)
  data = client.get("/projects/#{project_id}/history/iterations/#{iteration_number}/days").body
  raise Errors::UnexpectedData, 'Hash of history data expected' unless data.is_a? Hash

  Resources::DailyHistoryContainer.new({ project_id: project_id, iteration_number: iteration_number }.merge(data))
end