class GetToWork::Service::PivotalTracker
Public Instance Methods
api_client()
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 52 def api_client @api_client ||= TrackerApi::Client.new(token: api_token) end
api_token()
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 48 def api_token @api_token ||= authenticate_with_keychain end
authenticate(username:, password:, subdomain:)
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 33 def authenticate(username:, password:, subdomain:) token = get_auth_token(user: username, pass: password) set_client_token(token) end
authenticate_with_keychain()
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 38 def authenticate_with_keychain if keychain set_client_token(keychain.password) end end
get_auth_token(user:, pass:)
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 11 def get_auth_token(user:, pass:) # POST uri = URI("https://www.pivotaltracker.com/services/v3/tokens/active") req = Net::HTTP::Get.new(uri) req.basic_auth user, pass res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end case res when Net::HTTPUnauthorized raise Service::UnauthorizedError else res end # Parse the token xml = Nokogiri::XML(res.body) xml.xpath("//guid").first.text end
get_projects()
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 60 def get_projects api_client.projects.sort do |x, y| x[:name] <=> y[:name] end end
projects()
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 56 def projects @projects ||= get_projects end
set_client_token(token)
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 44 def set_client_token(token) @api_token = token end
story(story_id)
click to toggle source
# File lib/get_to_work/service/pivotal_tracker.rb, line 66 def story(story_id) api_client.project(@project_id).story(story_id) end