Skip to content

Commit

Permalink
Added Disqus reports features
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyvdw committed May 19, 2011
1 parent 6eebde1 commit c91c5a3
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 0 deletions.
75 changes: 75 additions & 0 deletions lib/disqussion/client/reports.rb
@@ -1,4 +1,79 @@
module Disqussion
class Reports < Client
# Returns report on domains
# @accessibility: public key, secret key
# @methods: GET
# @format: json, jsonp
# @authenticated: false
# @limited: false
# @param options [Hash] A customizable set of options.
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
# @return [Hashie::Rash] Returns report
# @example Return report on comments by domains usage
# Disqussion::Client.reports.domains
# @see: http://disqus.com/api/3.0/reports/domains.json
def domains(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
response = get('reports/domains', options)
end

# Returns report on ips
# @accessibility: public key, secret key
# @methods: GET
# @format: json, jsonp
# @authenticated: false
# @limited: false
# @param options [Hash] A customizable set of options.
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
# @return [Hashie::Rash] Returns report
# @example Return report on comments by IPs usage
# Disqussion::Client.reports.ips
# @see: http://disqus.com/api/3.0/reports/ips.json
def ips(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
response = get('reports/ips', options)
end

# Returns report on threads
# @accessibility: public key, secret key
# @methods: GET
# @format: json, jsonp
# @authenticated: false
# @limited: false
# @param options [Hash] A customizable set of options.
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
# @return [Hashie::Rash] Returns report
# @example Return report on comments by threads
# Disqussion::Client.reports.threads
# @see: http://disqus.com/api/3.0/reports/threads.json
def threads(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
response = get('reports/threads', options)
end

# Returns report on users
# @accessibility: public key, secret key
# @methods: GET
# @format: json, jsonp
# @authenticated: false
# @limited: false
# @param options [Hash] A customizable set of options.
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
# @return [Hashie::Rash] Returns report
# @example Return report on comments by users
# Disqussion::Client.reports.users
# @see: http://disqus.com/api/3.0/reports/users.json
def users(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
response = get('reports/users', options)
end
end
end
63 changes: 63 additions & 0 deletions spec/disqussion/client/reports_spec.rb
@@ -0,0 +1,63 @@
require 'helper'

describe Disqussion::Reports do
Disqussion::Configuration::VALID_FORMATS.each do |format|
context ".new(:format => '#{format}')" do
before do
@client = Disqussion::Client.reports
end

describe ".domains" do
before do
stub_get("reports/domains.json", :query => { }).
to_return(:body => fixture("reports/domains.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end

it "returns report on domains." do
@client.domains
a_get("reports/domains.json", :query => { }).
should have_been_made
end
end

describe ".ips" do
before do
stub_get("reports/ips.json", :query => { }).
to_return(:body => fixture("reports/ips.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end

it "returns report on ips." do
@client.ips
a_get("reports/ips.json", :query => { }).
should have_been_made
end
end

describe ".threads" do
before do
stub_get("reports/threads.json", :query => { }).
to_return(:body => fixture("reports/threads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end

it "returns report on threads." do
@client.threads
a_get("reports/threads.json", :query => { }).
should have_been_made
end
end

describe ".users" do
before do
stub_get("reports/users.json", :query => { }).
to_return(:body => fixture("reports/users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end

it "returns report on users." do
@client.users
a_get("reports/users.json", :query => { }).
should have_been_made
end
end
end
end
end
4 changes: 4 additions & 0 deletions spec/fixtures/reports/domains.json
@@ -0,0 +1,4 @@
{
"code": 0,
"response": []
}
82 changes: 82 additions & 0 deletions spec/fixtures/reports/ips.json
@@ -0,0 +1,82 @@
{
"code": 0,
"response": [
{
"link": "http://disqus.com/admin/moderate/?query=ip:41.177.2.78",
"isBlacklisted": false,
"percent": 15.380000000000001,
"value": 2,
"label": "41.177.2.78"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:75.141.156.152",
"isBlacklisted": false,
"percent": 15.380000000000001,
"value": 2,
"label": "75.141.156.152"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:14.139.69.1",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "14.139.69.1"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:62.163.182.156",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "62.163.182.156"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:68.39.32.201",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "68.39.32.201"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:85.49.27.49",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "85.49.27.49"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:89.176.215.136",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "89.176.215.136"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:124.60.141.25",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "124.60.141.25"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:128.172.26.174",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "128.172.26.174"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:174.61.82.198",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "174.61.82.198"
},
{
"link": "http://disqus.com/admin/moderate/?query=ip:202.156.10.231",
"isBlacklisted": false,
"percent": 7.6900000000000004,
"value": 1,
"label": "202.156.10.231"
}
]
}
4 changes: 4 additions & 0 deletions spec/fixtures/reports/threads.json
@@ -0,0 +1,4 @@
{
"code": 0,
"response": []
}
82 changes: 82 additions & 0 deletions spec/fixtures/reports/users.json
@@ -0,0 +1,82 @@
{
"code": 0,
"response": [
{
"link": "http://disqus.com/admin/moderate/?query=email:antonseim%40gmail.com",
"isBlacklisted": false,
"percent": 16.670000000000002,
"value": 2,
"label": "antonseim@gmail.com"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:bartdepuij%40bartdepuij.com",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "bartdepuij@bartdepuij.com"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:bellcath%40gmail.com",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "bellcath@gmail.com"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:crika%40free.fr",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "crika@free.fr"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:info%40iammonster.co.za",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "info@iammonster.co.za"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:joa.bp%40hotmail.com",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "joa.bp@hotmail.com"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:joanne.kiely86%40live.ie",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "joanne.kiely86@live.ie"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:k.s.srinivas123%40gmail.com",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "k.s.srinivas123@gmail.com"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:melissa%40missmollyfashions.co.za",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "melissa@missmollyfashions.co.za"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:miirraa%40korea.com",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "miirraa@korea.com"
},
{
"link": "http://disqus.com/admin/moderate/?query=email:monibogusz%40yahoo.com",
"isBlacklisted": false,
"percent": 8.3300000000000001,
"value": 1,
"label": "monibogusz@yahoo.com"
}
]
}

0 comments on commit c91c5a3

Please sign in to comment.