Sha256: edc2f3fa7cef48a1989c8b51374ecaec05e7af229d2898c73fa5772efda14b71
Contents?: true
Size: 985 Bytes
Versions: 9
Compression:
Stored size: 985 Bytes
Contents
module PivotalTracker class Client class << self attr_writer :use_ssl, :token def use_ssl @use_ssl || false end def token(username, password, method='post') response = if method == 'post' RestClient.post 'https://www.pivotaltracker.com/services/v3/tokens/active', :username => username, :password => password else RestClient.get "https://#{username}:#{password}@www.pivotaltracker.com/services/v3/tokens/active" end @token ||= Nokogiri::XML(response.body).search('guid').inner_html end # this is your connection for the entire module def connection(options={}) @connection ||= RestClient::Resource.new("#{protocol}://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => @token, 'Content-Type' => 'application/xml'}) end protected def protocol use_ssl ? 'https' : 'http' end end end end
Version data entries
9 entries across 9 versions & 1 rubygems