-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to export my GrooveHQ data NOW ... actually a quick solution #31
Comments
Thanks nice! Mind creating a PR?
Am 7. Juni 2018, 17:25 +0200 schrieb jayjlawrence <[email protected]>:
… Now not really an issue ... here's a quick solution to getting your GrooveHQ data out of the system asap. I wrote it up here so you may consider incorporating into the gem.
In a file called groovehq_private_token put the value for Private Token in API Settings:
I put this in my Gemfile
source 'https://rubygems.org'
gem 'groovehq', path: 'groovehq'
And this in my dump_groovehq.rb file
require 'groovehq'
require 'pp'
export_dir = "groovehq_dump"
export_all = true # false exports just tickets and skips config
export_attachments = true # false skips exporting any attachment info
collapse_single_message = true # If just on message on ticket put everything in the ticket directory
client = GrooveHQ::Client.new(File.read('groovehq_private_token').chomp)
Dir.mkdir export_dir unless Dir.exist? export_dir
if export_all
subdir = "#{export_dir}/config"
Dir.mkdir subdir unless Dir.exist? subdir
client.agents.each {|agent|
File.open("#{subdir}/agent-#{agent.id}.yml", "w") {|f| f.puts agent.to_yaml}
}
client.customers.each {|customer|
File.open("#{subdir}/customer-#{customer.id}.yml", "w") {|f| f.puts customer.to_yaml}
}
client.folders.each {|folder|
File.open("#{subdir}/folder-#{folder.id}.yml", "w") {|f| f.puts folder.to_yaml}
}
client.groups.each {|group|
File.open("#{subdir}/group-#{group.id}.yml", "w") {|f| f.puts group.to_yaml}
}
client.mailboxes.each {|mailbox|
File.open("#{subdir}/mailbox-#{mailbox.id}.yml", "w") {|f| f.puts mailbox.to_yaml}
}
end
client.tickets(per_page: 50).each {|ticket|
puts "Exporting ticket #{ticket.number}"
ticketdir = "#{export_dir}/ticket-#{ticket.number}"
Dir.mkdir ticketdir unless Dir.exist? ticketdir
File.open("#{ticketdir}/ticket.yml", "w") {|f| f.puts ticket.to_yaml}
ticket.rels[:messages] && ticket.rels[:messages].get.each_with_index {|message, message_index|
msgdir = collapse_single_message && ticket.message_count==1 ? ticketdir : "#{ticketdir}/#{message_index}"
Dir.mkdir msgdir unless Dir.exist? msgdir
File.open("#{msgdir}/message.yml", "w") {|f| f.puts message.to_yaml}
File.open("#{msgdir}/message.txt", "w") {|f| f.puts message.plain_text_body}
File.open("#{msgdir}/message.html", "w") {|f| f.puts message.body} if message.body != message.plain_text_body || message.body.strip.squeeze.downcase != message.plain_text_body.strip.squeeze.downcase
export_attachments && message.rels[:attachments] && message.rels[:attachments].get.each {|attachment|
File.open("#{msgdir}/attachment.yml", "w") {|f| f.puts attachment.to_yaml}
File.open("#{msgdir}/#{attachment.filename}", "w") {|f|
begin
response = HTTParty.get(attachment.url)
rescue
STDERR.puts "Issue fetching attachment #{msgdir}/#{attachment.filename} - skipping"
next
end
f.binmode
f.write response.body
}
}
}
}
download dump_groovehq.rb.txt Forced to use .txt extension
If you're fairly new to Ruby you will want to know:
• create the 3 files in the same directory
• run the command bundle install
• permissions problem? run sudo bundle install
• adjust the export options at top of script
• run the script with the command bundle exec ruby dump_groovehq.rb
• go have coffee
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Hi! Just a reminder - would you have time to commit it as part of readme or examples/ dir? :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now not really an issue ... here's a quick solution to getting your GrooveHQ data out of the system asap. I wrote it up here so you may consider incorporating into the gem.
In a file called
groovehq_private_token
put the value for Private Token in API Settings:I put this in my
Gemfile
And this in my
dump_groovehq.rb
filedownload dump_groovehq.rb.txt Forced to use .txt extension
If you're fairly new to Ruby you will want to know:
bundle install
sudo bundle install
bundle exec ruby dump_groovehq.rb
The text was updated successfully, but these errors were encountered: