Explained in this blog post.
Created
March 14, 2012 14:56
-
-
Save timriley/2037031 to your computer and use it in GitHub Desktop.
Trajectory CSV export script
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
require 'rubygems' | |
require 'bundler/setup' | |
require 'csv' | |
require 'faraday' | |
require 'faraday_middleware' | |
API_KEY = "" | |
ACCOUNT_KEYWORD = "" | |
PROJECT_KEYWORD = "" | |
# Current story fields are: | |
# | |
# archived | |
# assignee_id | |
# branch | |
# created_at | |
# deleted | |
# design_needed | |
# development_needed | |
# id | |
# idea_id | |
# iteration_id | |
# points | |
# position | |
# state | |
# task_type | |
# title | |
# updated_at | |
# user_id | |
# comments_count | |
# assignee_name | |
# user_name | |
# state_events | |
# idea_subject | |
FIELDS = [ | |
'id', | |
'task_type', | |
'points', | |
'title' | |
].freeze | |
connection = Faraday.new(:url => 'https://www.apptrajectory.com/') do |conn| | |
conn.response :json, :content_type => /\bjson$/ | |
conn.adapter Faraday.default_adapter | |
end | |
response = connection.get("/api/#{API_KEY}/accounts/#{ACCOUNT_KEYWORD}/projects/#{PROJECT_KEYWORD}/stories.json") | |
csv_str = CSV.generate do |csv| | |
csv << FIELDS | |
response.body['stories'].each do |story| | |
csv << FIELDS.map { |field_name| story[field_name] } | |
end | |
end | |
puts csv_str |
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
source :rubygems | |
gem 'faraday', '>= 0.8.0.rc2' | |
gem 'faraday_middleware' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment