Created
March 18, 2015 12:44
-
-
Save fancyremarker/f76d2004fab623ecf1ba to your computer and use it in GitHub Desktop.
Export (and delete) all Zendesk HC Articles
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 'zendesk_api' | |
require 'active_support' | |
require 'active_support/core_ext' | |
# https://github.com/zendesk/zendesk_api_client_rb/issues/175 | |
module ZendeskAPI | |
class Article < Resource; end | |
class Section < Resource; end | |
class Category < Resource | |
namespace "help_center" | |
has_many Section | |
has_many Article | |
end | |
class Section < Resource | |
namespace "help_center" | |
has_many Article | |
has Category | |
end | |
class Article < Resource | |
namespace "help_center" | |
has :author, :class => User | |
end | |
end | |
def client | |
fail 'ENV["TOKEN"] not set!' unless ENV['TOKEN'] | |
@client ||= ZendeskAPI::Client.new do |config| | |
config.url = 'https://aptible.zendesk.com/api/v2' | |
config.username = '[email protected]' | |
config.token = ENV['TOKEN'] | |
end | |
end | |
client.articles.all do |article| | |
filename = "#{article.id}-#{article.title.parameterize}.html" | |
File.open(filename, 'w') do |file| | |
file << article.body | |
end | |
end | |
client.articles.all do |article| | |
client.articles.destroy(id: article.id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment