snoo 0.1.0.pre.2 → 0.1.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/snoo/subreddits.rb +10 -10
- data/lib/snoo/utilities.rb +16 -22
- data/lib/snoo/version.rb +1 -1
- metadata +3 -3
data/lib/snoo/subreddits.rb
CHANGED
@@ -163,7 +163,7 @@ module Snoo
|
|
163
163
|
# @param (see #delete_header)
|
164
164
|
# @return (see #clear_sessions)
|
165
165
|
def add_moderator container, user, subreddit
|
166
|
-
friend_wrapper
|
166
|
+
friend_wrapper container: container, name: user, r: subreddit, type: "moderator"
|
167
167
|
end
|
168
168
|
|
169
169
|
# Add a contributor to the subreddit
|
@@ -171,7 +171,7 @@ module Snoo
|
|
171
171
|
# @param (see #add_moderator)
|
172
172
|
# @return (see #clear_sessions)
|
173
173
|
def add_contributor container, user, subreddit
|
174
|
-
friend_wrapper
|
174
|
+
friend_wrapper container: container, name: user, r: subreddit, type: "contributor"
|
175
175
|
end
|
176
176
|
|
177
177
|
# Ban a user from a subreddit
|
@@ -179,7 +179,7 @@ module Snoo
|
|
179
179
|
# @param (see #add_moderator)
|
180
180
|
# @return (see #clear_sessions)
|
181
181
|
def ban_user container, user, subreddit
|
182
|
-
friend_wrapper
|
182
|
+
friend_wrapper container: container, name: user, r: subreddit, type: "banned"
|
183
183
|
end
|
184
184
|
|
185
185
|
# Remove a moderator from a subreddit
|
@@ -187,24 +187,24 @@ module Snoo
|
|
187
187
|
# @param id [String] The user id
|
188
188
|
# @param (see #add_moderator)
|
189
189
|
# @return (see #clear_sessions)
|
190
|
-
def remove_moderator
|
191
|
-
unfriend_wrapper
|
190
|
+
def remove_moderator container, user, subreddit
|
191
|
+
unfriend_wrapper container: container, name: user, r: subreddit, type: "moderator"
|
192
192
|
end
|
193
193
|
|
194
194
|
# Remove a contributor from a subreddit
|
195
195
|
#
|
196
196
|
# @param (see #remove_moderator)
|
197
197
|
# @return (see #clear_sessions)
|
198
|
-
def remove_contributor
|
199
|
-
unfriend_wrapper
|
198
|
+
def remove_contributor container, user, subreddit
|
199
|
+
unfriend_wrapper container: container, name: user, r: subreddit, type: "contributor"
|
200
200
|
end
|
201
201
|
|
202
202
|
# Unban a user from a subreddit
|
203
203
|
#
|
204
204
|
# @param (see #remove_moderator)
|
205
205
|
# @return (see #clear_sessions)
|
206
|
-
def unban_user
|
207
|
-
unfriend_wrapper
|
206
|
+
def unban_user container, user, subreddit
|
207
|
+
unfriend_wrapper container: container, name: user, r: subreddit, type: "banned"
|
208
208
|
end
|
209
209
|
|
210
210
|
# List moderators of a subreddit
|
@@ -234,7 +234,7 @@ module Snoo
|
|
234
234
|
end
|
235
235
|
|
236
236
|
# Accept a moderatorship
|
237
|
-
#
|
237
|
+
#
|
238
238
|
# @param subreddit [String] The subreddit to accept in. You must have been invited
|
239
239
|
def accept_moderator subreddit
|
240
240
|
logged_in?
|
data/lib/snoo/utilities.rb
CHANGED
@@ -36,38 +36,32 @@ module Snoo
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Posts to '/api/friend'. This method exists because there are tons of things that use this
|
39
|
+
# See http://www.reddit.com/dev/api#POST_api_friend for details
|
39
40
|
#
|
40
|
-
# @param
|
41
|
-
# @
|
42
|
-
# @
|
43
|
-
# @
|
44
|
-
# @
|
41
|
+
# @param opts [Hash] an options hash
|
42
|
+
# @option opts [String] :type The type of action to add.
|
43
|
+
# @option opts [String] :container The id of the containing user/object/thing
|
44
|
+
# @options opt [String] :note The reddit gold user node
|
45
|
+
# @option opts [String] :name The name of a reddit user
|
45
46
|
# @return [HTTParty::Response] The response object.
|
46
|
-
def friend_wrapper
|
47
|
+
def friend_wrapper opts = {}
|
47
48
|
logged_in?
|
48
|
-
params = {
|
49
|
-
params
|
50
|
-
params[:name] = api_name if api_name
|
51
|
-
params[:note] = api_note if api_note
|
52
|
-
params[:r] = api_subreddit if api_subreddit
|
49
|
+
params = {uh: @modhash}
|
50
|
+
params.merge! opts
|
53
51
|
post('/api/friend', body: params)
|
54
52
|
end
|
55
53
|
|
56
54
|
# Posts to '/api/unfriend'. This method exists because there are a ton of things that use this.
|
57
55
|
#
|
58
|
-
# @param
|
59
|
-
# @
|
60
|
-
# @
|
61
|
-
# @
|
62
|
-
# @param api_subreddit [String] Subreddit name
|
56
|
+
# @param opts [Hash] an options hash
|
57
|
+
# @option opts [String] :type The type of action to add.
|
58
|
+
# @option opts [String] :container The id of the containing user/object/thing
|
59
|
+
# @option opts [String] :name The name of a reddit user
|
63
60
|
# @return (see #friend_wrapper)
|
64
|
-
def unfriend_wrapper
|
61
|
+
def unfriend_wrapper opts = {}
|
65
62
|
logged_in?
|
66
|
-
params = {
|
67
|
-
params
|
68
|
-
params[:name] = api_name if api_name
|
69
|
-
params[:id] = api_id if api_id
|
70
|
-
params[:r] = api_subreddit if api_subreddit
|
63
|
+
params = { uh: @modhash}
|
64
|
+
params.merge! opts
|
71
65
|
post('/api/unfriend', body: params)
|
72
66
|
end
|
73
67
|
end
|
data/lib/snoo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: 1.3.1
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.8.
|
120
|
+
rubygems_version: 1.8.23
|
121
121
|
signing_key:
|
122
122
|
specification_version: 3
|
123
123
|
summary: A simple reddit api wrapper
|