Skip to content

Instantly share code, notes, and snippets.

@timriley
Created March 14, 2012 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timriley/2037031 to your computer and use it in GitHub Desktop.
Save timriley/2037031 to your computer and use it in GitHub Desktop.
Trajectory CSV export script
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
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