disqussion 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/.gitignore +9 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +80 -0
  4. data/HISTORY.mkd +5 -0
  5. data/LICENSE.mkd +20 -0
  6. data/README.mkd +139 -0
  7. data/Rakefile +23 -0
  8. data/disqussion.gemspec +37 -0
  9. data/lib/disqussion/api.rb +21 -0
  10. data/lib/disqussion/client/.DS_Store +0 -0
  11. data/lib/disqussion/client/applications.rb +20 -0
  12. data/lib/disqussion/client/blacklists.rb +4 -0
  13. data/lib/disqussion/client/categories.rb +4 -0
  14. data/lib/disqussion/client/exports.rb +4 -0
  15. data/lib/disqussion/client/forums.rb +122 -0
  16. data/lib/disqussion/client/imports.rb +4 -0
  17. data/lib/disqussion/client/posts.rb +217 -0
  18. data/lib/disqussion/client/reactions.rb +79 -0
  19. data/lib/disqussion/client/reports.rb +4 -0
  20. data/lib/disqussion/client/threads.rb +199 -0
  21. data/lib/disqussion/client/trends.rb +23 -0
  22. data/lib/disqussion/client/users.rb +103 -0
  23. data/lib/disqussion/client/utils.rb +90 -0
  24. data/lib/disqussion/client/whitelists.rb +4 -0
  25. data/lib/disqussion/client.rb +46 -0
  26. data/lib/disqussion/configuration.rb +121 -0
  27. data/lib/disqussion/connection.rb +36 -0
  28. data/lib/disqussion/error.rb +51 -0
  29. data/lib/disqussion/request.rb +38 -0
  30. data/lib/disqussion/version.rb +3 -0
  31. data/lib/disqussion/view_helpers.rb +9 -0
  32. data/lib/disqussion/widget.rb +183 -0
  33. data/lib/disqussion.rb +25 -0
  34. data/lib/faraday/response/raise_http_4xx.rb +41 -0
  35. data/lib/faraday/response/raise_http_5xx.rb +20 -0
  36. data/spec/disqussion/api_spec.rb +63 -0
  37. data/spec/disqussion/client/.DS_Store +0 -0
  38. data/spec/disqussion/client/applications_spec.rb +24 -0
  39. data/spec/disqussion/client/forums_spec.rb +80 -0
  40. data/spec/disqussion/client/posts_spec.rb +154 -0
  41. data/spec/disqussion/client/reactions_spec.rb +63 -0
  42. data/spec/disqussion/client/threads_spec.rb +128 -0
  43. data/spec/disqussion/client/trends_spec.rb +24 -0
  44. data/spec/disqussion/client/users_spec.rb +33 -0
  45. data/spec/disqussion/client_spec.rb +15 -0
  46. data/spec/disqussion_spec.rb +101 -0
  47. data/spec/faraday/response_spec.rb +30 -0
  48. data/spec/fixtures/applications/listUsage.json +129 -0
  49. data/spec/fixtures/forums/create.json +12 -0
  50. data/spec/fixtures/forums/details.json +12 -0
  51. data/spec/fixtures/forums/listCategories.json +21 -0
  52. data/spec/fixtures/forums/listPosts.json +859 -0
  53. data/spec/fixtures/forums/listThreads.json +533 -0
  54. data/spec/fixtures/posts/approve.json +6 -0
  55. data/spec/fixtures/posts/create.json +6 -0
  56. data/spec/fixtures/posts/details.json +35 -0
  57. data/spec/fixtures/posts/highlight.json +6 -0
  58. data/spec/fixtures/posts/list.json +247 -0
  59. data/spec/fixtures/posts/remove.json +6 -0
  60. data/spec/fixtures/posts/report.json +6 -0
  61. data/spec/fixtures/posts/restore.json +6 -0
  62. data/spec/fixtures/posts/spam.json +6 -0
  63. data/spec/fixtures/posts/unhighlight.json +6 -0
  64. data/spec/fixtures/posts/vote.json +6 -0
  65. data/spec/fixtures/reactions/domains.json +4 -0
  66. data/spec/fixtures/reactions/ips.json +131 -0
  67. data/spec/fixtures/reactions/threads.json +4 -0
  68. data/spec/fixtures/reactions/users.json +124 -0
  69. data/spec/fixtures/threads/close.json +4 -0
  70. data/spec/fixtures/threads/create.json +22 -0
  71. data/spec/fixtures/threads/details.json +24 -0
  72. data/spec/fixtures/threads/list.json +531 -0
  73. data/spec/fixtures/threads/listMostLiked.json +530 -0
  74. data/spec/fixtures/threads/listPosts.json +87 -0
  75. data/spec/fixtures/threads/open.json +8 -0
  76. data/spec/fixtures/threads/remove.json +4 -0
  77. data/spec/fixtures/threads/restore.json +4 -0
  78. data/spec/fixtures/threads/vote.json +4 -0
  79. data/spec/fixtures/trends/listTreads.json +283 -0
  80. data/spec/fixtures/users/details.json +19 -0
  81. data/spec/fixtures/users/follow.json +4 -0
  82. data/spec/helper.rb +47 -0
  83. metadata +348 -0
@@ -0,0 +1,217 @@
1
+ module Disqussion
2
+ class Posts < Client
3
+ # Approves a post.
4
+ # @accessibility: public key, secret key
5
+ # @methods: POST
6
+ # @format: json, jsonp
7
+ # @authenticated: true
8
+ # @limited: false
9
+ # @param post [Array, Integer] allows multiple. Looks up a post by ID. You must be a moderator on the selected post's forum.
10
+ # @return [Hashie::Rash] Approved post id
11
+ # @example Approves post with ID 198230
12
+ # Disqussion::Client.posts.approve(198230)
13
+ # @see: http://disqus.com/api/3.0/posts/approve.json
14
+ def approve(*args)
15
+ options = args.last.is_a?(Hash) ? args.pop : {}
16
+ options[:post] = args.first
17
+ response = post('posts/approve', options)
18
+ end
19
+
20
+ # Creates a new post.
21
+ # @accessibility: public key, secret key
22
+ # @methods: POST
23
+ # @format: json, jsonp
24
+ # @authenticated: false
25
+ # @limited: false
26
+ # @param message [String] Message.
27
+ # @param options [Hash] A customizable set of options.
28
+ # @option options [Integer] :parent Defaults to null. Looks up a post by ID
29
+ # @option options [Integer] :thread Defaults to null. Looks up a thread by ID
30
+ # @option options [String] :author_email Defaults to null. Email address (defined by RFC 5322)
31
+ # @option options [String] :author_name Defaults to null
32
+ # @option options [String] :state Defaults to null. Choices: unapproved, approved, spam, killed
33
+ # @option options [String] :author_url Defaults to null. URL (defined by RFC 3986)
34
+ # @option options [Datetime] :date Defaults to null. Unix timestamp (or ISO datetime standard)
35
+ # @option options [String] :ip_address Defaults to null. IP address (defined by RFC 5322)
36
+ # @return [Hashie::Rash] New post infos
37
+ # @example Creates a new post 'hello world' in 167820 167820
38
+ # Disqussion::Client.posts.create("hello world", :thread => 167820)
39
+ # @see: http://disqus.com/api/3.0/posts/create.json
40
+ def create(*args)
41
+ options = args.last.is_a?(Hash) ? args.pop : {}
42
+ options[:message] = args.first
43
+ response = post('posts/create', options)
44
+ end
45
+
46
+ # Returns post details.
47
+ # @accessibility: public key, secret key
48
+ # @methods: GET
49
+ # @format: json, jsonp
50
+ # @authenticated: false
51
+ # @limited: false
52
+ # @param post [Integer] Post ID
53
+ # @param options [Hash] A customizable set of options.
54
+ # @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread.
55
+ # @return [Hashie::Rash] Details on the requested post.
56
+ # @example Return extended information for post 193673
57
+ # Disqussion::Client.posts.details(193673)
58
+ # @see: http://disqus.com/api/3.0/posts/details.json
59
+ def details(*args)
60
+ options = args.last.is_a?(Hash) ? args.pop : {}
61
+ options[:post] = args.first
62
+ response = get('posts/details', options)
63
+ end
64
+
65
+ # Highlights a post.
66
+ # @accessibility: public key, secret key
67
+ # @methods: POST
68
+ # @format: json, jsonp
69
+ # @authenticated: true
70
+ # @limited: false
71
+ # @param post [Array, Integer] allows multiple. Looks up a post by ID.
72
+ # @return [Hashie::Rash] Highlighted post id
73
+ # @example Highlights post with ID 198230
74
+ # Disqussion::Client.posts.highlight(198230)
75
+ # @see: http://disqus.com/api/3.0/posts/highlight.json
76
+ def highlight(*args)
77
+ options = args.last.is_a?(Hash) ? args.pop : {}
78
+ options[:post] = args.first
79
+ response = post('posts/highlight', options)
80
+ end
81
+
82
+ # Returns a list of posts ordered by the date created.
83
+ # @accessibility: public key, secret key
84
+ # @methods: GET
85
+ # @format: json, jsonp, rss
86
+ # @authenticated: false
87
+ # @limited: false
88
+ # @param options [Hash] A customizable set of options.
89
+ # @option options [Array, String] :category allow multiple. Defaults to null. Looks up a category by ID
90
+ # @option options [Array, String] :thread allow multiple. Defaults to null. Looks up a thread by ID
91
+ # @option options [Array, String] :forum allow multiple. Defaults to null. Defaults to all forums you moderate if no other filters are specified. Looks up a forum by ID (aka short name)
92
+ # @option options [Datetime, Timestamp] :since Defaults to null. Unix timestamp (or ISO datetime standard).
93
+ # @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread
94
+ # @option options [Integer] :cursor. Defaults to null
95
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
96
+ # @option options [Integer] :offset. Defaults to 0. Deprecated: Please see documentation on cursors
97
+ # @option options [Integer] :query. Defaults to null.
98
+ # @option options [String, Array] :include allows multiple. Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged, highlighted
99
+ # @option options [String] :order. Defaults to "desc". Choices: asc, desc
100
+ # @return [Hashie::Rash] Returns a list of posts ordered by the date created..
101
+ # @example Return list of posts for thread 193673
102
+ # Disqussion::Client.posts.list(:thread => 193673)
103
+ # @see: http://disqus.com/api/3.0/posts/list.json
104
+ def list(*args)
105
+ options = args.last.is_a?(Hash) ? args.pop : {}
106
+ response = get('posts/list', options)
107
+ end
108
+
109
+ # Deletes the requested post(s).
110
+ # @accessibility: public key, secret key
111
+ # @methods: POST
112
+ # @format: json, jsonp
113
+ # @authenticated: true
114
+ # @limited: false
115
+ # @param post [Array, Integer] allows multiple. Looks up a post by ID.
116
+ # @return [Hashie::Rash] Removed post id
117
+ # @example Deletes post with ID 198230
118
+ # Disqussion::Client.posts.remove(198230)
119
+ # @see: http://disqus.com/api/3.0/posts/remove.json
120
+ def remove(*args)
121
+ options = args.last.is_a?(Hash) ? args.pop : {}
122
+ options[:post] = args.first
123
+ response = post('posts/remove', options)
124
+ end
125
+
126
+ # Reports a post (flagging).
127
+ # @accessibility: public key, secret key
128
+ # @methods: POST
129
+ # @format: json, jsonp
130
+ # @authenticated: false
131
+ # @limited: false
132
+ # @param post [Integer] Looks up a post by ID.
133
+ # @return [Hashie::Rash] Reported post id
134
+ # @example Deletes post with ID 198230
135
+ # Disqussion::Client.posts.report(198230)
136
+ # @see: http://disqus.com/api/3.0/posts/report.json
137
+ def report(*args)
138
+ options = args.last.is_a?(Hash) ? args.pop : {}
139
+ options[:post] = args.first
140
+ response = post('posts/report', options)
141
+ end
142
+
143
+ # Undeletes the requested post(s).
144
+ # @accessibility: public key, secret key
145
+ # @methods: POST
146
+ # @format: json, jsonp
147
+ # @authenticated: true
148
+ # @limited: false
149
+ # @param post [Array, Integer] allows multiple. Looks up a post by ID.
150
+ # @return [Hashie::Rash] restored post id
151
+ # @example Undeletes post with ID 198230
152
+ # Disqussion::Client.posts.restore(198230)
153
+ # @see: http://disqus.com/api/3.0/posts/restore.json
154
+ def restore(*args)
155
+ options = args.last.is_a?(Hash) ? args.pop : {}
156
+ options[:post] = args.first
157
+ response = post('posts/restore', options)
158
+ end
159
+
160
+ # Marks the requested post(s) as spam.
161
+ # @accessibility: public key, secret key
162
+ # @methods: POST
163
+ # @format: json, jsonp
164
+ # @authenticated: true
165
+ # @limited: false
166
+ # @param post [Array, Integer] allows multiple. Looks up a post by ID.
167
+ # @return [Hashie::Rash] Marked as spam post id
168
+ # @example Reports as spam post with ID 198230
169
+ # Disqussion::Client.posts.spam(198230)
170
+ # @see: http://disqus.com/api/3.0/posts/spam.json
171
+ def spam(*args)
172
+ options = args.last.is_a?(Hash) ? args.pop : {}
173
+ options[:post] = args.first
174
+ response = post('posts/spam', options)
175
+ end
176
+
177
+ # Unhighlights the requested post(s).
178
+ # @accessibility: public key, secret key
179
+ # @methods: POST
180
+ # @format: json, jsonp
181
+ # @authenticated: true
182
+ # @limited: false
183
+ # @param post [Array, Integer] allows multiple. Looks up a post by ID.
184
+ # @return [Hashie::Rash] Unhighlighted post id
185
+ # @example Unhighlights the requested post(s).
186
+ # Disqussion::Client.posts.unhighlight(198230)
187
+ # @see: http://disqus.com/api/3.0/posts/unhighlight.json
188
+ def unhighlight(*args)
189
+ options = args.last.is_a?(Hash) ? args.pop : {}
190
+ options[:post] = args.first
191
+ response = post('posts/unhighlight', options)
192
+ end
193
+
194
+ # Register a vote for a post.
195
+ # @accessibility: public key, secret key
196
+ # @methods: POST
197
+ # @format: json, jsonp
198
+ # @authenticated: true
199
+ # @limited: false
200
+ # @param vote [Integer] Choices: -1, 0, 1
201
+ # @param post [Integer] Looks up a post by ID.
202
+ # @return [Hashie::Rash] Details on the post.
203
+ # @example Vote for post ID 12345678
204
+ # Disqussion::Client.posts.vote(1, 12345678)
205
+ # @see: http://disqus.com/api/3.0/posts/vote.json
206
+ def vote(*args)
207
+ options = args.last.is_a?(Hash) ? args.pop : {}
208
+ if args.length == 2
209
+ options.merge!(:vote => args[0])
210
+ options.merge!(:post => args[1])
211
+ response = post('posts/vote', options)
212
+ else
213
+ puts "#{Kernel.caller.first}: posts.vote expects 2 arguments: vote([-1..1]), posts ID"
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,79 @@
1
+ module Disqussion
2
+ class Reactions < Client
3
+ # Returns ??
4
+ # @accessibility: public key, secret key
5
+ # @methods: GET
6
+ # @format: json, jsonp
7
+ # @authenticated: false
8
+ # @limited: false
9
+ # @param options [Hash] A customizable set of options.
10
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
11
+ # @option options [Integer] :page. Defaults to 0. Maximum length of 10
12
+ # @option options [Array, String] :forum allow multiple. Defaults to null. Defaults to all forums you moderate if no other filters are specified. Looks up a forum by ID (aka short name)
13
+ # @return [Hashie::Rash] Returns ??
14
+ # @example Return ??
15
+ # Disqussion::Client.reactions.domains
16
+ # @see: http://disqus.com/api/3.0/posts/domains.json
17
+ def domains(*args)
18
+ options = args.last.is_a?(Hash) ? args.pop : {}
19
+ response = get('reactions/domains', options)
20
+ end
21
+
22
+ # Returns ??
23
+ # @accessibility: public key, secret key
24
+ # @methods: GET
25
+ # @format: json, jsonp
26
+ # @authenticated: false
27
+ # @limited: false
28
+ # @param options [Hash] A customizable set of options.
29
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
30
+ # @option options [Integer] :page. Defaults to 0. Maximum length of 10
31
+ # @option options [Array, String] :forum allow multiple. Defaults to null. Defaults to all forums you moderate if no other filters are specified. Looks up a forum by ID (aka short name)
32
+ # @return [Hashie::Rash] Returns ??
33
+ # @example Return ??
34
+ # Disqussion::Client.reactions.ips
35
+ # @see: http://disqus.com/api/3.0/posts/ips.json
36
+ def ips(*args)
37
+ options = args.last.is_a?(Hash) ? args.pop : {}
38
+ response = get('reactions/ips', options)
39
+ end
40
+
41
+ # Returns ??
42
+ # @accessibility: public key, secret key
43
+ # @methods: GET
44
+ # @format: json, jsonp
45
+ # @authenticated: false
46
+ # @limited: false
47
+ # @param options [Hash] A customizable set of options.
48
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
49
+ # @option options [Integer] :page. Defaults to 0. Maximum length of 10
50
+ # @option options [Array, String] :forum allow multiple. Defaults to null. Defaults to all forums you moderate if no other filters are specified. Looks up a forum by ID (aka short name)
51
+ # @return [Hashie::Rash] Returns ??
52
+ # @example Return ??
53
+ # Disqussion::Client.reactions.threads
54
+ # @see: http://disqus.com/api/3.0/posts/threads.json
55
+ def threads(*args)
56
+ options = args.last.is_a?(Hash) ? args.pop : {}
57
+ response = get('reactions/threads', options)
58
+ end
59
+
60
+ # Returns ??
61
+ # @accessibility: public key, secret key
62
+ # @methods: GET
63
+ # @format: json, jsonp
64
+ # @authenticated: false
65
+ # @limited: false
66
+ # @param options [Hash] A customizable set of options.
67
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
68
+ # @option options [Integer] :page. Defaults to 0. Maximum length of 10
69
+ # @option options [Array, String] :forum allow multiple. Defaults to null. Defaults to all forums you moderate if no other filters are specified. Looks up a forum by ID (aka short name)
70
+ # @return [Hashie::Rash] Returns ??
71
+ # @example Return ??
72
+ # Disqussion::Client.reactions.users
73
+ # @see: http://disqus.com/api/3.0/posts/users.json
74
+ def users(*args)
75
+ options = args.last.is_a?(Hash) ? args.pop : {}
76
+ response = get('reactions/users', options)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,4 @@
1
+ module Disqussion
2
+ class Reports < Client
3
+ end
4
+ end
@@ -0,0 +1,199 @@
1
+ module Disqussion
2
+ class Threads < Client
3
+ # Closes a thread
4
+ # @accessibility: public key, secret key
5
+ # @methods: POST
6
+ # @format: json, jsonp
7
+ # @authenticated: true
8
+ # @limited: false
9
+ # @param thread [Array, Integer] allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
10
+ # @return [Hashie::Rash] ID of the closed thread.
11
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name). You must be a moderator on the selected forum.
12
+ # @example Closes thread 12345678
13
+ # Disqussion::Client.threads.close(12345678)
14
+ # @see: http://disqus.com/api/3.0/threads/close.json
15
+ def close(*args)
16
+ options = args.last.is_a?(Hash) ? args.pop : {}
17
+ thread = args.first
18
+ options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
19
+ response = post('threads/close', options)
20
+ end
21
+
22
+ # Returns thread details.
23
+ # @accessibility: public key, secret key
24
+ # @methods: GET
25
+ # @format: json, jsonp
26
+ # @authenticated: false
27
+ # @limited: false
28
+ # @return [Hashie::Rash] Details on the requested threads.
29
+ # @param thread [Integer] Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
30
+ # @param options [Hash] A customizable set of options.
31
+ # @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, author, category
32
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name)
33
+ # @example Return extended information for forum 'myforum'
34
+ # Disqussion::Client.threads.details("mythread")
35
+ # @see: http://disqus.com/api/3.0/threads/details.json
36
+ def details(*args)
37
+ options = args.last.is_a?(Hash) ? args.pop : {}
38
+ thread = args.first
39
+ options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
40
+ response = get('threads/details', options)
41
+ end
42
+
43
+ # Returns a list of threads sorted by the date created.
44
+ # @accessibility: public key, secret key
45
+ # @methods: GET
46
+ # @format: json, jsonp, rss
47
+ # @authenticated: false
48
+ # @limited: false
49
+ # @return [Hashie::Rash] List of threads.
50
+ # @param options [Hash] A customizable set of options.
51
+ # @option options [Integer] :category. Defaults to null
52
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name)
53
+ # @option options [Integer] :thread. Defaults to null. Looks up a thread by ID. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
54
+ # @option options [Integer, String] :author. Defaults to null. You may look up a user by username using the 'username' query type.
55
+ # @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
56
+ # @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, author, category
57
+ # @option options [Integer] :cursor. Defaults to null
58
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
59
+ # @option options [String, Array] :include allows multiple. Defaults to ["open", "close"]. Choices: open, closed, killed.
60
+ # @option options [String] :order. Defaults to "asc". Choices: asc, desc
61
+ # @example Return extended information for forum 'myforum'
62
+ # Disqussion::Client.threads.list(:forum => "the88")
63
+ # @see: http://disqus.com/api/3.0/threads/list.json
64
+ def list(*args)
65
+ options = args.last.is_a?(Hash) ? args.pop : {}
66
+ response = get('threads/list', options)
67
+ end
68
+
69
+ # Returns a list of threads sorted by number of likes.
70
+ # @accessibility: public key, secret key
71
+ # @methods: GET
72
+ # @format: json, jsonp, rss
73
+ # @authenticated: false
74
+ # @limited: false
75
+ # @return [Hashie::Rash] List of the most liked threads.
76
+ # @param options [Hash] A customizable set of options.
77
+ # @option options [Integer] :category. Defaults to null
78
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name)
79
+ # @option options [Integer, String] :author. Defaults to null. You may look up a user by username using the 'username' query type.
80
+ # @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, author, category
81
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
82
+ # @option options [String, Array] :include allows multiple. Defaults to ["open", "close"]. Choices: open, closed, killed.
83
+ # @example Return extended information for forum 'myforum'
84
+ # Disqussion::Client.threads.listMostLiked()
85
+ # @see: http://disqus.com/api/3.0/threads/listMostLiked.json
86
+ def listMostLiked(*args)
87
+ options = args.last.is_a?(Hash) ? args.pop : {}
88
+ response = get('threads/listMostLiked', options)
89
+ end
90
+
91
+ # Returns a list of posts within a thread.
92
+ # @accessibility: public key, secret key
93
+ # @methods: GET
94
+ # @format: json, jsonp, rss
95
+ # @authenticated: false
96
+ # @limited: false
97
+ # @return [Hashie::Rash] List of threads post.
98
+ # @param thread [Integer] Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
99
+ # @param options [Hash] A customizable set of options.
100
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name)
101
+ # @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
102
+ # @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum
103
+ # @option options [Integer] :cursor. Defaults to null
104
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
105
+ # @option options [Integer] :query. Defaults to null.
106
+ # @option options [String, Array] :include allows multiple. Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged
107
+ # @option options [String] :order. Defaults to "desc". Choices: asc, desc
108
+ # @example Return extended information for forum 'myforum'
109
+ # Disqussion::Client.threads.list()
110
+ # @see: http://disqus.com/api/3.0/threads/listPosts.json
111
+ def listPosts(*args)
112
+ options = args.last.is_a?(Hash) ? args.pop : {}
113
+ thread = args.first
114
+ options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
115
+ response = get('threads/listPosts', options)
116
+ end
117
+
118
+ # Opens a thread
119
+ # @accessibility: public key, secret key
120
+ # @methods: POST
121
+ # @format: json, jsonp
122
+ # @authenticated: true
123
+ # @limited: false
124
+ # @param thread [Array, Integer] allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
125
+ # @return [Hashie::Rash] ID of the opened thread.
126
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name). You must be a moderator on the selected forum.
127
+ # @example Opens thread 12345678
128
+ # Disqussion::Client.threads.open(12345678)
129
+ # @see: http://disqus.com/api/3.0/threads/open.json
130
+ def open(*args)
131
+ options = args.last.is_a?(Hash) ? args.pop : {}
132
+ thread = args.first
133
+ options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
134
+ response = post('threads/open', options)
135
+ end
136
+
137
+ # Removes a thread
138
+ # @accessibility: public key, secret key
139
+ # @methods: POST
140
+ # @format: json, jsonp
141
+ # @authenticated: true
142
+ # @limited: false
143
+ # @param thread [Array, Integer] allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
144
+ # @return [Hashie::Rash] ID of the deleted thread.
145
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name). You must be a moderator on the selected forum.
146
+ # @example Removes thread 12345678
147
+ # Disqussion::Client.threads.remove(12345678)
148
+ # @see: http://disqus.com/api/3.0/threads/remove.json
149
+ def remove(*args)
150
+ options = args.last.is_a?(Hash) ? args.pop : {}
151
+ thread = args.first
152
+ options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
153
+ response = post('threads/remove', options)
154
+ end
155
+
156
+ # Restores a thread
157
+ # @accessibility: public key, secret key
158
+ # @methods: POST
159
+ # @format: json, jsonp
160
+ # @authenticated: true
161
+ # @limited: false
162
+ # @param thread [Array, Integer] allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
163
+ # @return [Hashie::Rash] ID of the restored thread.
164
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name). You must be a moderator on the selected forum.
165
+ # @example Removes thread 12345678
166
+ # Disqussion::Client.threads.restore(12345678)
167
+ # @see: http://disqus.com/api/3.0/threads/restore.json
168
+ def restore(*args)
169
+ options = args.last.is_a?(Hash) ? args.pop : {}
170
+ thread = args.first
171
+ options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
172
+ response = post('threads/restore', options)
173
+ end
174
+
175
+ # Register a vote on a thread.
176
+ # @accessibility: public key, secret key
177
+ # @methods: POST
178
+ # @format: json, jsonp
179
+ # @authenticated: true
180
+ # @limited: false
181
+ # @param thread [Integer] Choices: -1, 0, 1
182
+ # @param thread [Integer] Looks up a thread by ID. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.
183
+ # @return [Hashie::Rash] Details on the thread.
184
+ # @option options [String] :forum. Defaults to null. Looks up a forum by ID (aka short name). You must be a moderator on the selected forum.
185
+ # @example Removes thread 12345678
186
+ # Disqussion::Client.threads.vote(1, 12345678)
187
+ # @see: http://disqus.com/api/3.0/threads/vote.json
188
+ def vote(*args)
189
+ options = args.last.is_a?(Hash) ? args.pop : {}
190
+ if args.length == 2
191
+ options.merge!(:vote => args[0])
192
+ options.merge!(:thread => args[1]) if ([:ident, :link] & options.keys).empty?
193
+ response = post('threads/vote', options)
194
+ else
195
+ puts "#{Kernel.caller.first}: threads.vote expects 2 arguments: vote([-1..1]), thread (you may pass use the 'ident' or 'link' query types instead of an thread ID by including :forum)"
196
+ end
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,23 @@
1
+ module Disqussion
2
+ class Trends < Client
3
+ # Returns a list of trending threads.
4
+ # @accessibility: public key, secret key
5
+ # @methods: GET
6
+ # @format: json, jsonp, rss
7
+ # @authenticated: false
8
+ # @limited: false
9
+ # @param forum [String] Forum ID (aka short name).
10
+ # @return [Hashie::Rash] Returns list of trending threads.
11
+ # @param options [Hash] A customizable set of options.
12
+ # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
13
+ # @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, author, category
14
+ # @option options [Array, String] :forum allows multiple. Defaults to null. Looks up a forum by ID (aka short name)
15
+ # @example Returns a list of trending threads
16
+ # Disqussion::Client.trends.listTreads()
17
+ # @see: http://disqus.com/api/3.0/trends/listTreads.json
18
+ def listTreads(*args)
19
+ options = args.last.is_a?(Hash) ? args.pop : {}
20
+ response = get('trends/listTreads', options)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,103 @@
1
+ module Disqussion
2
+ class Users < Client
3
+ # Returns details of a user
4
+ # @accessibility: public key, secret key
5
+ # @methods: GET
6
+ # @format: json, jsonp
7
+ # @authenticated: false
8
+ # @limited: false
9
+ # @param user [Integer, String] A Disqus user ID or screen name.
10
+ # @return [Hashie::Rash] Details on the requested user.
11
+ # @example Return extended information for 'the88'
12
+ # Disqussion::Client.user("the88")
13
+ # Disqussion::Client.user(6138058) # Same as above
14
+ # @see: http://disqus.com/api/3.0/users/details.json
15
+ def details(*args)
16
+ options = args.last.is_a?(Hash) ? args.pop : {}
17
+ user = args.first
18
+ merge_user_into_options!(user, options)
19
+ response = get('users/details', options)
20
+ end
21
+
22
+ # Follow a user
23
+ # @accessibility: public key, secret key
24
+ # @methods: POST
25
+ # @format: json, jsonp
26
+ # @authenticated: true
27
+ # @limited: false
28
+ # @param target [Integer, String] A Disqus user ID or screen name.
29
+ # @return [Hashie::Rash] Details on the requested user.
30
+ # @example Return extended information for 'the88'
31
+ # Disqussion::Client.follow("the88")
32
+ # Disqussion::Client.follow(6138058) # Same as above
33
+ # @see: http://disqus.com/api/3.0/users/details.json
34
+ def follow(*args)
35
+ options = args.last.is_a?(Hash) ? args.pop : {}
36
+ target = args.first
37
+ merge_target_into_options!(target, options)
38
+ response = post('users/follow', options)
39
+ end
40
+
41
+ # Returns a list of forums a user has been active on.
42
+ def listActiveForums
43
+
44
+ end
45
+
46
+ # BETA
47
+ # Returns a list of threads a user has participated in sorted by last activity.
48
+ def listActiveThreads
49
+
50
+ end
51
+
52
+ # BETA
53
+ # Returns a list of various activity types made by the user.
54
+ def listActivity
55
+
56
+ end
57
+
58
+ # BETA
59
+ # Returns a list of users a user is being followed by.
60
+ def listFollowers
61
+
62
+ end
63
+
64
+ # BETA
65
+ # Returns a list of users a user is following.
66
+ def listFollowing
67
+
68
+ end
69
+
70
+ # Returns a list of forums a user owns.
71
+ def listForums
72
+
73
+ end
74
+
75
+ # BETA
76
+ # Returns a list of forums a user has been active on recenty, sorted by the user's activity.
77
+ def listMostActiveForums
78
+
79
+ end
80
+
81
+ # Returns a list of posts made by the user.
82
+ def listPosts
83
+
84
+ end
85
+
86
+ # Unfollow a user
87
+ # @accessibility: public key, secret key
88
+ # @methods: GET
89
+ # @format: json, jsonp
90
+ # @authenticated: true
91
+ # @limited: false
92
+ # @param user [Integer, String] A Disqus user ID or screen name.
93
+ # @return [Hashie::Rash] Details on the requested user.
94
+ # @example Return extended information for 'the88'
95
+ # Disqussion::Client.unfollow("the88")
96
+ # Disqussion::Client.unfollow(6138058) # Same as above
97
+ # @see: http://disqus.com/api/3.0/users/details.json
98
+ def unfollow
99
+ merge_user_into_options!(user, options)
100
+ response = post('users/unfollow', options)
101
+ end
102
+ end
103
+ end