Class: Todone::PivotalPuller

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/todone/pivotal_puller.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ PivotalPuller

Returns a new instance of PivotalPuller.



9
10
11
12
# File 'lib/todone/pivotal_puller.rb', line 9

def initialize opts 
	@project_id = opts[:project_id]
	Todone::PivotalPuller.headers 'X-TrackerToken' => opts[:tracker_token]
end

Instance Method Details

#pull_stories(state) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/todone/pivotal_puller.rb', line 14

def pull_stories state
	return { "error" => "invalid_state" } unless %w(started unstarted accepted delivered unscheduled).include? state
	filter = CGI.escape("state:#{state}")
	PivotalPuller.get("/services/v3/projects/#{@project_id}/stories?filter=#{filter}")['stories'] || []
	rescue 
		return { "error" => "api_problem" }
end