Skip to content

Instantly share code, notes, and snippets.

@tstachl
Created December 18, 2014 23:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstachl/1d958ed328d65eb8261b to your computer and use it in GitHub Desktop.
Save tstachl/1d958ed328d65eb8261b to your computer and use it in GitHub Desktop.
This is a very rudimentary script of exporting data from desk.com to a CSV file.
require 'desk_api'
require 'csv'
# Create the CSV files
cases = CSV.open('./cases.csv', 'wb')
interactions = CSV.open('./interactions.csv', 'wb')
# Add the headers to the CSV files
cases << ['Case #', 'Subject', 'Description', 'Status']
interactions << ['Case #', 'Body', 'Created Date']
# Run through the cases and interactions assuming DeskApi has been configured globally
DeskApi.cases.all do |res|
cases << [res.id, res.subject, res.description, res.status]
res.replies.all do |reply|
interactions << [res.id, reply.body, reply.created_at]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment