-
-
Save pagelab/41365e8e6197fb1072804be8a1bd9a1b to your computer and use it in GitHub Desktop.
Script to export helpscout data
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
| #!/usr/bin/env ruby | |
| require 'helpscout' | |
| require 'fileutils' | |
| api_key = ARGV[0] | |
| helpscout = HelpScout::Client.new(api_key) | |
| helpscout.mailboxes.each do |box| | |
| FileUtils.mkdir(box.name) unless File.exists?(box.name) | |
| puts "Fetching #{helpscout.conversation_count(box.id, 'all', nil)} conversations for #{box.name}" | |
| helpscout.conversations(box.id, "all", nil).each do |c| | |
| next if File.exists?(path = "#{box.name}/#{c.id}.yaml") | |
| File.open(path, "w") {|f| f.puts helpscout.conversation(c.id).to_yaml; putc "."; sleep 0.5 } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment