Created
December 18, 2014 23:44
-
-
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.
This file contains hidden or 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 '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