class PTLog::Pivotal::API
Public Class Methods
connection()
click to toggle source
# File lib/ptlog/pivotal/api.rb, line 8 def connection @connection ||= Faraday.new 'https://www.pivotaltracker.com/services/v5' do |faraday| faraday.request :json faraday.response :json, :content_type => /\bjson$/ faraday.adapter Faraday.default_adapter faraday.headers['X-TrackerToken'] = ENV['PIVOTAL_TOKEN'] faraday.options[:timeout] = 30 faraday.options[:open_timeout] = 30 end end
epic(id)
click to toggle source
# File lib/ptlog/pivotal/api.rb, line 38 def epic(id) get("epics/#{id}") end
get(uri)
click to toggle source
# File lib/ptlog/pivotal/api.rb, line 19 def get(uri) begin response = connection.get(uri) raise Pivotal::NetworkError unless response.status == 200 response.body rescue Pivotal::NetworkError, Faraday::Error::TimeoutError => e { 'kind' => 'error', 'error' => 'Unable to fetch data' } end end
story(id)
click to toggle source
# File lib/ptlog/pivotal/api.rb, line 34 def story(id) get("stories/#{id}") end