disqussion 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,22 @@
1
1
  module Disqussion
2
2
  class Users < Client
3
+ # Updates username for the user, fails if username does not meet requirements, or is taken by another user
4
+ # @accessibility: public key, secret key
5
+ # @methods: POST
6
+ # @format: json, jsonp
7
+ # @authenticated: true
8
+ # @limited: false
9
+ # @param username [String] A Disqus username. Defaults to null. Minimum length of 3 and Maximum length of 30
10
+ # @example Updates username for the user for 'the88' to 'saxonbeat'
11
+ # Disqussion::Client.users.checkusername(:username => 'saxonbeat')
12
+ # @see: http://disqus.com/api/3.0/users/checkUsername.json
13
+ def checkUsername(*args)
14
+ options = args.last.is_a?(Hash) ? args.pop : {}
15
+ options[:username] = args.first
16
+ response = post('users/checkUsername', options)
17
+ end
18
+
19
+
3
20
  # Returns details of a user
4
21
  # @accessibility: public key, secret key
5
22
  # @methods: GET
@@ -86,7 +103,7 @@ module Disqussion
86
103
 
87
104
  # BETA
88
105
  # Returns a list of various activity types made by the user.
89
- # @accessibility: public key, secret key
106
+ # @accessibility: public key, secret key
90
107
  # @methods: GET
91
108
  # @format: json, jsonp
92
109
  # @authenticated: false
@@ -98,7 +115,6 @@ module Disqussion
98
115
  # @option options [Integer] :cursor. Defaults to null
99
116
  # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
100
117
  # @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
101
- # @option options [] :query. Defaults to null
102
118
  # @option options [String, Array] :include. Allows multiple. Defaults to ["user", "replies", "following" ]. Choices: user, replies, following
103
119
  # @option options [String] :anon_user. Defaults to null. Looks up an anonymous user by unique hash.
104
120
  # @example Return a list of active threads user 1234 has been active on
@@ -111,14 +127,44 @@ module Disqussion
111
127
 
112
128
  # BETA
113
129
  # Returns a list of users a user is being followed by.
130
+ # @accessibility: public key, secret key
131
+ # @methods: GET
132
+ # @format: json, jsonp
133
+ # @authenticated: false
134
+ # @limited: true
135
+ # @return [Hashie::Rash] Details on the users the user is being followed by.
136
+ # @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
137
+ # @option options [Integer] :cursor. Defaults to null
138
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
139
+ # @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
140
+ # @option options [String] :order. Defaults to "asc". Choices: asc, desc
141
+ # @example Return a list of users the user is currently being followed by
142
+ # Disqussion::Client.users.listFollowers(:user => 1234)
143
+ # @see: http://disqus.com/api/3.0/users/listFollowers.json
114
144
  def listFollowers(*args)
115
-
145
+ options = args.last.is_a?(Hash) ? args.pop : {}
146
+ response = get('users/listFollowers', options)
116
147
  end
117
148
 
118
149
  # BETA
119
150
  # Returns a list of users a user is following.
151
+ # @accessibility: public key, secret key
152
+ # @methods: GET
153
+ # @format: json, jsonp
154
+ # @authenticated: false
155
+ # @limited: true
156
+ # @return [Hashie::Rash] Details on the users the user is following.
157
+ # @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
158
+ # @option options [Integer] :cursor. Defaults to null
159
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
160
+ # @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
161
+ # @option options [String] :order. Defaults to "asc". Choices: asc, desc
162
+ # @example Return a list of users the user is currently following
163
+ # Disqussion::Client.users.listFollowing(:user => 1234)
164
+ # @see: http://disqus.com/api/3.0/users/listFollowing.json
120
165
  def listFollowing(*args)
121
-
166
+ options = args.last.is_a?(Hash) ? args.pop : {}
167
+ response = get('users/listFollowing', options)
122
168
  end
123
169
 
124
170
  # Returns a list of forums a user owns.
@@ -144,8 +190,20 @@ module Disqussion
144
190
 
145
191
  # BETA
146
192
  # Returns a list of forums a user has been active on recenty, sorted by the user's activity.
193
+ # @accessibility: public key, secret key
194
+ # @methods: GET
195
+ # @format: json, jsonp
196
+ # @authenticated: false
197
+ # @limited: true
198
+ # @return [Hashie::Rash] Details on the users list of forums they have been most active on recently.
199
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
200
+ # @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
201
+ # @example Return a list of the forums the user has been most active on recently.
202
+ # Disqussion::Client.users.listMostActiveForums(:user => 1234)
203
+ # @see: http://disqus.com/api/3.0/users/listMostActiveForums.json
147
204
  def listMostActiveForums(*args)
148
-
205
+ options = args.last.is_a?(Hash) ? args.pop : {}
206
+ response = get('users/listMostActiveForums', options)
149
207
  end
150
208
 
151
209
  # Returns a list of posts made by the user.
@@ -1,3 +1,3 @@
1
1
  module Disqussion
2
- VERSION = '0.0.6'.freeze unless defined?(::Disqussion::VERSION)
3
- end
2
+ VERSION = '0.0.7'.freeze unless defined?(::Disqussion::VERSION)
3
+ end
@@ -6,6 +6,19 @@ describe Disqussion::Forums do
6
6
  before do
7
7
  @client = Disqussion::Client.forums
8
8
  end
9
+
10
+ describe ".addModerator" do
11
+ before do
12
+ stub_post("forums/addModerator.json", :body => { :user => "boom", :forum => "the88"}).
13
+ to_return(:body => fixture("forums/addModerator.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+
16
+ xit "adds a moderator to a forum" do
17
+ @client.addModerator("boom", "the88")
18
+ a_post("forums/addModerator.json", :body => { :user => "boom", :forum => "the88"}).
19
+ should have_been_made
20
+ end
21
+ end
9
22
 
10
23
  describe ".create" do
11
24
  before do
@@ -32,6 +45,32 @@ describe Disqussion::Forums do
32
45
  should have_been_made
33
46
  end
34
47
  end
48
+
49
+ describe ".listModerators" do
50
+ before do
51
+ stub_get("forums/listModerators.json", :query => { :forum => "the88" }).
52
+ to_return(:body => fixture("forums/listModerators.json"), :headers => {:content_type => "application/json; charset=utf-8"})
53
+ end
54
+
55
+ it "returns a list of moderators of the forum" do
56
+ @client.listModerators("the88")
57
+ a_get("forums/listModerators.json", :query => { :forum => "the88" }).
58
+ should have_been_made
59
+ end
60
+ end
61
+
62
+ describe ".listMostActiveUsers" do
63
+ before do
64
+ stub_get("forums/listMostActiveUsers.json", :query => { :forum => "the88" }).
65
+ to_return(:body => fixture("forums/listMostActiveUsers.json"), :headers => {:content_type => "application/json; charset=utf-8"})
66
+ end
67
+
68
+ it "returns a list of the most active users on a forum" do
69
+ @client.listMostActiveUsers("the88")
70
+ a_get("forums/listMostActiveUsers.json", :query => { :forum => "the88" }).
71
+ should have_been_made
72
+ end
73
+ end
35
74
 
36
75
  describe ".listMostLikedUsers" do
37
76
  before do
@@ -99,4 +138,4 @@ describe Disqussion::Forums do
99
138
  end
100
139
  end
101
140
  end
102
- end
141
+ end
@@ -47,7 +47,16 @@ describe Disqussion::Posts do
47
47
  end
48
48
 
49
49
  describe ".getContext" do
50
- pending
50
+ before do
51
+ stub_get("posts/getContext.json", :query => { :post => "3" }).
52
+ to_return(:body => fixture("posts/getContext.json"), :headers => {:content_type => "application/json; charset=utf-8"})
53
+ end
54
+
55
+ it "Returns the hierarchal tree of a post (all parents)" do
56
+ @client.getContext(3)
57
+ a_get("posts/getContext.json", :query => { :post => "3" }).
58
+ should have_been_made
59
+ end
51
60
  end
52
61
 
53
62
  describe ".highlight" do
@@ -77,7 +86,16 @@ describe Disqussion::Posts do
77
86
  end
78
87
 
79
88
  describe ".listPopular" do
80
- pending
89
+ before do
90
+ stub_get("posts/listPopular.json", :query => { :forum => "bobross"}).
91
+ to_return(:body => fixture("posts/listPopular.json"), :headers => {:content_type => "application/json; charset=utf-8"})
92
+ end
93
+
94
+ it "Returns a list of posts ordered by the number of likes recently." do
95
+ @client.listPopular(:forum => "bobross")
96
+ a_get("posts/listPopular.json", :query => { :forum => "bobross" }).
97
+ should have_been_made
98
+ end
81
99
  end
82
100
 
83
101
  describe ".remove" do
@@ -144,7 +162,20 @@ describe Disqussion::Posts do
144
162
  should have_been_made
145
163
  end
146
164
  end
147
-
165
+
166
+ describe ".update" do
167
+ before do
168
+ stub_post("posts/update.json", :body => { :post => "12345678", :message => "Hello"}).
169
+ to_return(:body => fixture("posts/update.json"), :headers => {:content_type => "application/json; charset=utf-8"})
170
+ end
171
+
172
+ it "Updates information on a post" do
173
+ @client.update(12345678, "Hello")
174
+ a_post("posts/update.json", :body => { :post => "12345678", :message => "Hello"}).
175
+ should have_been_made
176
+ end
177
+ end
178
+
148
179
  describe ".vote" do
149
180
  before do
150
181
  stub_post("posts/vote.json", :body => { :vote => "1", :post => "199088808" }).
@@ -6,6 +6,19 @@ describe Disqussion::Reactions do
6
6
  before do
7
7
  @client = Disqussion::Client.reactions
8
8
  end
9
+
10
+ describe ".details" do
11
+ before do
12
+ stub_get("reactions/details.json", :query => { }).
13
+ to_return(:body => fixture("reactions/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+
16
+ xit "returns reaction details" do
17
+ @client.details()
18
+ a_get("reactions/details.json", :query => { }).
19
+ should have_been_made
20
+ end
21
+ end
9
22
 
10
23
  describe ".domains" do
11
24
  before do
@@ -32,6 +45,19 @@ describe Disqussion::Reactions do
32
45
  should have_been_made
33
46
  end
34
47
  end
48
+
49
+ describe ".list" do
50
+ before do
51
+ stub_get("reactions/list.json", :query => {:forum => "the88"}).
52
+ to_return(:body => fixture("reactions/list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
53
+ end
54
+
55
+ it "returns a list of reactions for a forum" do
56
+ @client.list("the88")
57
+ a_get("reactions/list.json", :query => {:forum => "the88" }).
58
+ should have_been_made
59
+ end
60
+ end
35
61
 
36
62
  describe ".threads" do
37
63
  before do
@@ -6,6 +6,19 @@ describe Disqussion::Threads do
6
6
  before do
7
7
  @client = Disqussion::Client.threads
8
8
  end
9
+
10
+ describe ".create" do
11
+ before do
12
+ stub_post("threads/create.json", :body => { :forum => "bobross", :title => "Hello World" }).
13
+ to_return(:body => fixture("threads/create.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+
16
+ it "creates a new thread" do
17
+ @client.create("bobross","Hello World")
18
+ a_post("threads/create.json", :body => { :forum => "bobross", :title => "Hello World" }).
19
+ should have_been_made
20
+ end
21
+ end
9
22
 
10
23
  describe ".close" do
11
24
  before do
@@ -51,7 +64,16 @@ describe Disqussion::Threads do
51
64
  end
52
65
 
53
66
  describe ".listHot" do
54
- pending
67
+ before do
68
+ stub_get("threads/listHot.json", :query => { :forum => "cnn" }).
69
+ to_return(:body => fixture("threads/listHot.json"), :headers => {:content_type => "application/json; charset=utf-8"})
70
+ end
71
+
72
+ it "returns a list of hot threads of a forum" do
73
+ @client.listHot(:forum => "cnn")
74
+ a_get("threads/listHot.json", :query => { :forum => "cnn" }).
75
+ should have_been_made
76
+ end
55
77
  end
56
78
 
57
79
  describe ".listMostLiked" do
@@ -68,7 +90,16 @@ describe Disqussion::Threads do
68
90
  end
69
91
 
70
92
  describe ".listPopular" do
71
- pending
93
+ before do
94
+ stub_get("threads/listPopular.json", :query => {:forum => "facebook" }).
95
+ to_return(:body => fixture("threads/listPopular.json"), :headers => {:content_type => "application/json; charset=utf-8"})
96
+ end
97
+
98
+ it "returns a list of the most popular posts in a interval" do
99
+ @client.listPopular(:forum => "facebook")
100
+ a_get("threads/listPopular.json", :query => { :forum => "facebook"}).
101
+ should have_been_made
102
+ end
72
103
  end
73
104
 
74
105
  describe ".listPosts" do
@@ -126,9 +157,42 @@ describe Disqussion::Threads do
126
157
  should have_been_made
127
158
  end
128
159
  end
129
-
160
+
161
+ describe ".set" do
162
+ it "get the correct resource" do
163
+ stub_get("threads/set.json", :query => { :thread => "12345678" }).
164
+ to_return(:body => fixture("threads/set.json"), :headers => {:content_type => "application/json; charset=utf-8"})
165
+
166
+ @client.set(12345678)
167
+
168
+ a_get("threads/set.json", :query => { :thread => "12345678"}).should have_been_made
169
+ end
170
+ end
171
+
172
+ describe ".subscribe" do
173
+ before do
174
+ stub_post("threads/subscribe.json", :body => { :thread => "12345678" }).
175
+ to_return(:body => fixture("threads/subscribe.json"), :headers => {:content_type => "application/json; charset=utf-8"})
176
+ end
177
+
178
+ xit "subscribes to thread" do
179
+ @client.subscribe(12345678)
180
+ a_post("threads/subscribe.json", :body => { :thread => "12345678"}).
181
+ should have_been_made
182
+ end
183
+ end
184
+
130
185
  describe ".update" do
131
- pending
186
+ before do
187
+ stub_post("threads/update.json", :body => { :thread => "1", :title => "Hello World" }).
188
+ to_return(:body => fixture("threads/update.json"), :headers => {:content_type => "application/json; charset=utf-8"})
189
+ end
190
+
191
+ xit "updates a thread" do
192
+ @client.update(1, "Hello World")
193
+ a_post("threads/update.json", :body => { :thread => "1", :title => "Hello World" }).
194
+ should have_been_made
195
+ end
132
196
  end
133
197
 
134
198
  describe ".vote" do
@@ -6,6 +6,17 @@ describe Disqussion::Users do
6
6
  before do
7
7
  @client = Disqussion::Client.users
8
8
  end
9
+
10
+ describe ".checkUsername" do
11
+ it "checks username" do
12
+ stub_post("users/checkUsername.json", :body => {:username => "saxonbeat"}).
13
+ to_return(:body => fixture("users/checkUsername.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+
15
+ @client.checkUsername("saxonbeat")
16
+
17
+ a_post("users/checkUsername.json", :body => {:username => "saxonbeat"}).should have_been_made
18
+ end
19
+ end
9
20
 
10
21
  describe ".details" do
11
22
  it "get the correct resource" do
@@ -63,15 +74,29 @@ describe Disqussion::Users do
63
74
  end
64
75
 
65
76
  describe ".listFollowers" do
66
- pending
77
+ it "gets a list of users followers." do
78
+ stub_get("users/listFollowers.json", :query => { :user => "1234"}).
79
+ to_return(:body => fixture("users/listFollowers.json"), :headers => {:content_type => "application/json; charset=utf-8"})
80
+
81
+ @client.listFollowers(:user => 1234)
82
+
83
+ a_get("users/listFollowers.json", :query => { :user => "1234"}).should have_been_made
84
+ end
67
85
  end
68
86
 
69
87
  describe ".listFollowing" do
70
- pending
88
+ it "gets a list of users the user is following on Disqus." do
89
+ stub_get("users/listFollowing.json", :query => { :user => "1"}).
90
+ to_return(:body => fixture("users/listFollowing.json"), :headers => {:content_type => "application/json; charset=utf-8"})
91
+
92
+ @client.listFollowing(:user => 1)
93
+
94
+ a_get("users/listFollowing.json", :query => { :user => "1"}).should have_been_made
95
+ end
71
96
  end
72
97
 
73
98
  describe ".listForums" do
74
- it "get list of users forums." do
99
+ it "gets list of users forums." do
75
100
  stub_get("users/listForums.json", :query => { :user => "1234" }).
76
101
  to_return(:body => fixture("users/listForums.json"), :headers => {:content_type => "application/json; charset=utf-8"})
77
102
 
@@ -82,7 +107,14 @@ describe Disqussion::Users do
82
107
  end
83
108
 
84
109
  describe "listMostActiveForums" do
85
- pending
110
+ it "gets list of forums the user is most active on" do
111
+ stub_get("users/listMostActiveForums.json", :query => { :user => "1" }).
112
+ to_return(:body => fixture("users/listMostActiveForums.json"), :headers => {:content_type => "application/json; charset=utf-8"})
113
+
114
+ @client.listMostActiveForums(:user => 1)
115
+
116
+ a_get("users/listMostActiveForums.json", :query => { :user => "1"}).should have_been_made
117
+ end
86
118
  end
87
119
 
88
120
  describe ".listPosts" do
@@ -0,0 +1,39 @@
1
+ {
2
+ "code": 0,
3
+ "response": [
4
+ {
5
+ "id": "630382",
6
+ "forum": "the88",
7
+ "user": {
8
+ "username": "the88",
9
+ "about": "",
10
+ "name": "the88",
11
+ "url": "",
12
+ "isAnonymous": false,
13
+ "rep": 1.232862,
14
+ "isFollowing": false,
15
+ "isFollowedBy": false,
16
+ "profileUrl": "http://disqus.com/the88/",
17
+ "emailHash": "bb59f077c9689d923dd856c31dba3098",
18
+ "reputation": 1.232862,
19
+ "location": "",
20
+ "isPrimary": true,
21
+ "joinedAt": "2010-12-28T23:00:03",
22
+ "id": "6138058",
23
+ "avatar": {
24
+ "small": {
25
+ "permalink": "http://disqus.com/api/users/avatars/the88.jpg",
26
+ "cache": "http://mediacdn.disqus.com/1361595726/images/noavatar32.png"
27
+ },
28
+ "isCustom": false,
29
+ "permalink": "http://disqus.com/api/users/avatars/the88.jpg",
30
+ "cache": "http://mediacdn.disqus.com/1361595726/images/noavatar92.png",
31
+ "large": {
32
+ "permalink": "http://disqus.com/api/users/avatars/the88.jpg",
33
+ "cache": "http://mediacdn.disqus.com/1361595726/images/noavatar92.png"
34
+ }
35
+ }
36
+ }
37
+ }
38
+ ]
39
+ }