Permalink
Browse files

Added Disqus Exports feature

  • Loading branch information...
1 parent 3a7324c commit 66e519e68a8355ca5af3ef8bffcac52541fc3f4f @jeremyvdw committed May 19, 2011
Showing with 52 additions and 2 deletions.
  1. +2 −2 README.mkd
  2. +22 −0 lib/disqussion/client/exports.rb
  3. +24 −0 spec/disqussion/client/export_spec.rb
  4. +4 −0 spec/fixtures/exports/exportForum.json
View
@@ -23,9 +23,9 @@ Continuous Integration
What's in 0.0.3?
----------------
-Disqussion currently covers *only* stable Disqus API features for: applications, categories, forums, imports, posts, reactions, reports, threads and users.
+Disqussion currently covers *only* stable Disqus API features for: applications, categories, exports, forums, imports, posts, reactions, reports, threads and users.
-Missing following features: blacklists, exports and whitelists.
+Missing following features: blacklists and whitelists.
The error classes are consistent with [Disqus documented response codes](http://disqus.com/api/docs/errors/).
Error details from Disqus API are encapsulated in HTTP response.
@@ -1,4 +1,26 @@
module Disqussion
class Exports < Client
+ # Export a forum
+ # @accessibility: public key, secret key
+ # @methods: POST
+ # @format: json, jsonp
+ # @authenticated: true
+ # @limited: false
+ # @param forum [String] Forum short name (aka forum id).
+ # @return [Hashie::Rash] Export infos
+ # @param options [Hash] A customizable set of options.
+ # @option options [String] :format. Defaults to "xml". Choices: xml, xml-old
+ # @example Export forum "the88"
+ # Disqussion::Client.exports.exportForum("the88")
+ # @see: http://disqus.com/api/3.0/exports/exportForum.json
+ def exportForum(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ if args.size == 1
+ options.merge!(:forum => args[0])
+ response = post('exports/exportForum', options)
+ else
+ puts "#{Kernel.caller.first}: exports.exportForum expects an arguments: forum"
+ end
+ end
end
end
@@ -0,0 +1,24 @@
+require 'helper'
+
+describe Disqussion::Exports do
+ Disqussion::Configuration::VALID_FORMATS.each do |format|
+ context ".new(:format => '#{format}')" do
+ before do
+ @client = Disqussion::Client.exports
+ end
+
+ describe ".create" do
+ before do
+ stub_post("exports/exportForum.json", :body => { :forum => "the88" }).
+ to_return(:body => fixture("exports/exportForum.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+
+ it "exports a forum." do
+ @client.exportForum("the88")
+ a_post("exports/exportForum.json", :body => { :forum => "the88" }).
+ should have_been_made
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,4 @@
+{
+ "code": 0,
+ "response": {}
+}

0 comments on commit 66e519e

Please sign in to comment.