Created
April 28, 2015 15:01
-
-
Save fkchang/1616d020e00196ad86e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extracted from the tracker_api gem | |
require 'rubygems' | |
require 'faraday' | |
require 'faraday_middleware' | |
if ARGV.size != 2 | |
puts "usage: project_id pivotal_token" | |
return | |
end | |
project_id = ARGV[0] | |
token = ARGV[1] | |
puts "project_id: #{project_id}" | |
puts "token: #{token}" | |
url = "https://www.pivotaltracker.com/services/v5/projects/#{project_id}" | |
connection = Faraday.new({url: url}) do |builder| | |
builder.use Faraday::Response::RaiseError | |
builder.response :json | |
# request | |
builder.request :multipart | |
builder.request :json | |
builder.adapter :net_http | |
end | |
response = connection.get do |req| | |
req.url(url) | |
headers = { | |
'User-Agent' => 'Ruby/2.0.0 (java; jruby) Faraday/0.8.9', | |
'X-TrackerToken' => token | |
} | |
req.headers.merge!(headers) | |
end | |
pp response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment