redditkit 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -4
  3. data/lib/redditkit.rb +4 -3
  4. data/lib/redditkit/client.rb +6 -8
  5. data/lib/redditkit/client/apps.rb +8 -8
  6. data/lib/redditkit/client/captcha.rb +2 -2
  7. data/lib/redditkit/client/comments.rb +2 -2
  8. data/lib/redditkit/client/flair.rb +10 -8
  9. data/lib/redditkit/client/links.rb +24 -20
  10. data/lib/redditkit/client/miscellaneous.rb +10 -10
  11. data/lib/redditkit/client/moderation.rb +23 -21
  12. data/lib/redditkit/client/multireddits.rb +4 -4
  13. data/lib/redditkit/client/private_messages.rb +6 -4
  14. data/lib/redditkit/client/search.rb +1 -1
  15. data/lib/redditkit/client/subreddits.rb +11 -7
  16. data/lib/redditkit/client/users.rb +17 -14
  17. data/lib/redditkit/client/utilities.rb +10 -8
  18. data/lib/redditkit/client/voting.rb +5 -5
  19. data/lib/redditkit/client/wiki.rb +4 -0
  20. data/lib/redditkit/comment.rb +4 -4
  21. data/lib/redditkit/error.rb +3 -3
  22. data/lib/redditkit/link.rb +14 -14
  23. data/lib/redditkit/moderator_action.rb +4 -4
  24. data/lib/redditkit/multireddit.rb +2 -2
  25. data/lib/redditkit/multireddit_description.rb +2 -2
  26. data/lib/redditkit/private_message.rb +2 -2
  27. data/lib/redditkit/response/parse_json.rb +7 -1
  28. data/lib/redditkit/response/raise_error.rb +4 -5
  29. data/lib/redditkit/subreddit.rb +13 -10
  30. data/lib/redditkit/thing.rb +1 -0
  31. data/lib/redditkit/user.rb +12 -8
  32. data/lib/redditkit/version.rb +1 -5
  33. data/lib/redditkit/votable.rb +2 -2
  34. data/redditkit.gemspec +1 -1
  35. data/spec/cassettes/RedditKit_Client_Flair/_flair_list/returns_the_list_of_flair.yml +51 -4
  36. data/spec/cassettes/RedditKit_Client_Moderation/_ban/requests_the_correct_resource.yml +70 -23
  37. data/spec/cassettes/RedditKit_Client_Moderation/_contributors_to_subreddit/requests_the_correct_resource.yml +52 -5
  38. data/spec/cassettes/RedditKit_Client_Moderation/_moderation_log/returns_RedditKit_ModeratorAction_objects.yml +150 -109
  39. data/spec/cassettes/RedditKit_Client_Moderation/_moderators_of_subreddit/requests_the_correct_resource.yml +53 -6
  40. data/spec/cassettes/RedditKit_Client_Moderation/_unban/requests_the_correct_resource.yml +61 -14
  41. data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit/without_a_path/returns_a_multireddit.yml +49 -7
  42. data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit_description/with_a_multireddit/returns_a_multireddit_description.yml +102 -11
  43. data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit_description/with_a_username_and_multireddit_name/returns_a_multireddit_description.yml +54 -5
  44. data/spec/cassettes/RedditKit_Client_Search/_search/restricts_searches_to_a_specific_subreddit.yml +925 -0
  45. data/spec/cassettes/RedditKit_Client_Search/_search/returns_a_specific_number_of_results.yml +116 -0
  46. data/spec/cassettes/RedditKit_Client_Search/_search/returns_search_results.yml +884 -0
  47. data/spec/cassettes/RedditKit_Client_Wiki/_add_wiki_editor/requests_the_correct_resource.yml +58 -4
  48. data/spec/cassettes/RedditKit_Client_Wiki/_edit_wiki_page/requests_the_correct_resource.yml +58 -4
  49. data/spec/cassettes/RedditKit_Client_Wiki/_hide_wiki_revision/requests_the_correct_resource.yml +58 -4
  50. data/spec/cassettes/RedditKit_Client_Wiki/_remove_wiki_editor/requests_the_correct_resource.yml +58 -4
  51. data/spec/cassettes/RedditKit_Client_Wiki/_revert_to_revision/requests_the_correct_resource.yml +58 -4
  52. data/spec/redditkit/comment_spec.rb +6 -6
  53. data/spec/redditkit/link_spec.rb +38 -7
  54. data/spec/redditkit/thing_spec.rb +8 -0
  55. data/spec/redditkit/user_spec.rb +14 -0
  56. data/spec/spec_helper.rb +0 -4
  57. metadata +7 -11
@@ -28,7 +28,7 @@ module RedditKit
28
28
  # @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
29
29
  def approve(link)
30
30
  full_name = extract_full_name link
31
- post('api/approve', { :id => full_name, :api_type => :json })
31
+ post 'api/approve', { :id => full_name, :api_type => :json }
32
32
  end
33
33
 
34
34
  # Removes a link or comment.
@@ -36,7 +36,7 @@ module RedditKit
36
36
  # @param object [String, RedditKit::Comment, RedditKit::Link] The full name of a link/comment, a RedditKit::Comment, or a RedditKit::Link.
37
37
  def remove(object)
38
38
  full_name = extract_full_name object
39
- post('api/remove', { :id => full_name, :api_type => :json })
39
+ post 'api/remove', { :id => full_name, :api_type => :json }
40
40
  end
41
41
 
42
42
  # Ignores the reports on a link or comment.
@@ -44,7 +44,7 @@ module RedditKit
44
44
  # @param object [String, RedditKit::Comment, RedditKit::Link] The full name of a link/comment, a RedditKit::Comment, or a RedditKit::Link.
45
45
  def ignore_reports(object)
46
46
  full_name = extract_full_name object
47
- post('api/ignore_reports', { :id => full_name, :api_type => :json })
47
+ post 'api/ignore_reports', { :id => full_name, :api_type => :json }
48
48
  end
49
49
 
50
50
  # Unignores the reports on a link or comment.
@@ -52,7 +52,7 @@ module RedditKit
52
52
  # @param object [String, RedditKit::Comment, RedditKit::Link] The full name of a link/comment, a RedditKit::Comment, or a RedditKit::Link.
53
53
  def unignore_reports(object)
54
54
  full_name = extract_full_name object
55
- post('api/unignore_reports', { :id => full_name, :api_type => :json })
55
+ post 'api/unignore_reports', { :id => full_name, :api_type => :json }
56
56
  end
57
57
 
58
58
  # Distinguishes a comment as being posted by a moderator or admin.
@@ -64,7 +64,7 @@ module RedditKit
64
64
  full_name = extract_full_name comment
65
65
  parameters = { :id => full_name, :api_type => :json }
66
66
 
67
- post("api/distinguish/#{how}", parameters)
67
+ post "api/distinguish/#{how}", parameters
68
68
  end
69
69
 
70
70
  # Sets a post as have its contest mode enabled or disabled.
@@ -72,25 +72,19 @@ module RedditKit
72
72
  # @param link [String, RedditKit::Link] The full name of a link, or a RedditKit::Link.
73
73
  # @param contest_mode [Boolean] Whether to enable contest mode for the link's comments. Defaults to true.
74
74
  def set_contest_mode(link, contest_mode = true)
75
- full_name = extract_full_name link
76
- set_as_contest = contest_mode ? 'True' : 'False'
77
-
78
- post('api/set_contest_mode', { :id => full_name, :state => set_as_contest, :api_type => :json })
75
+ set_boolean_on_link 'api/set_contest_mode', link, contest_mode
79
76
  end
80
-
77
+
81
78
  # Sets a post as sticky within its parent subreddit. This will replace the existing sticky post, if there is one.
82
79
  #
83
80
  # @param link [String, RedditKit::Link] The full name of a link, or a RedditKit::Link.
84
81
  # @param sticky [Boolean] Whether to mark the post as sticky or unsticky. Defaults to true.
85
82
  def set_sticky_post(link, sticky = true)
86
- full_name = extract_full_name link
87
- set_as_sticky = sticky ? 'True' : 'False'
88
-
89
- post('api/set_subreddit_sticky', { :id => full_name, :state => set_as_sticky, :api_type => :json })
83
+ set_boolean_on_link 'api/set_subreddit_sticky', link, sticky
90
84
  end
91
85
 
92
86
  # Get the moderators of a subreddit.
93
- #
87
+ #
94
88
  # @param subreddit [String, RedditKit::Subreddit] The display name of a subreddit, or a RedditKit::Subreddit.
95
89
  # @return [Array<OpenStruct>]
96
90
  def moderators_of_subreddit(subreddit)
@@ -98,7 +92,7 @@ module RedditKit
98
92
  end
99
93
 
100
94
  # Get the contributors to a subreddit.
101
- #
95
+ #
102
96
  # @param subreddit [String, RedditKit::Subreddit] The display name of a subreddit, or a RedditKit::Subreddit.
103
97
  # @return [Array<OpenStruct>]
104
98
  def contributors_to_subreddit(subreddit)
@@ -110,7 +104,7 @@ module RedditKit
110
104
  # @param subreddit [String, RedditKit::Subreddit] The display name of the subreddit, or a RedditKit::Subreddit.
111
105
  def accept_moderator_invitation(subreddit)
112
106
  subreddit_name = extract_string(subreddit, :display_name)
113
- post('api/accept_moderator_invite', { :r => subreddit_name })
107
+ post 'api/accept_moderator_invite', :r => subreddit_name
114
108
  end
115
109
 
116
110
  # Resign as a contributor to a subreddit.
@@ -118,15 +112,15 @@ module RedditKit
118
112
  # @param subreddit [String, RedditKit::Subreddit] A subreddit's full name, or a RedditKit::Subreddit.
119
113
  def resign_as_contributor(subreddit)
120
114
  full_name = extract_full_name subreddit
121
- post('api/leavecontributor', { :id => full_name })
115
+ post 'api/leavecontributor', :id => full_name
122
116
  end
123
-
117
+
124
118
  # Resign as a moderator of a subreddit.
125
119
  #
126
120
  # @param subreddit [String, RedditKit::Subreddit] A subreddit's full name, or a RedditKit::Subreddit.
127
121
  def resign_as_moderator(subreddit)
128
122
  full_name = extract_full_name subreddit
129
- post('api/leavemoderator', { :id => full_name })
123
+ post 'api/leavemoderator', :id => full_name
130
124
  end
131
125
 
132
126
  # Resets a subreddit's header image.
@@ -134,7 +128,7 @@ module RedditKit
134
128
  # @param subreddit [String, RedditKit::Subreddit] The display name of the subreddit, or a RedditKit::Subreddit.
135
129
  def reset_subreddit_header(subreddit)
136
130
  subreddit_name = extract_string(subreddit, :display_name)
137
- post('api/delete_sr_header', { :r => subreddit_name })
131
+ post 'api/delete_sr_header', :r => subreddit_name
138
132
  end
139
133
 
140
134
  # Gets the moderation log for a subreddit.
@@ -173,6 +167,14 @@ module RedditKit
173
167
  members.collect { |member| OpenStruct.new(member) }
174
168
  end
175
169
 
170
+
171
+ def set_boolean_on_link(path, link, boolean)
172
+ full_name = extract_full_name link
173
+ boolean_as_string = boolean ? 'True' : 'False'
174
+
175
+ post path, { :id => full_name, :state => boolean_as_string, :api_type => :json }
176
+ end
177
+
176
178
  end
177
179
  end
178
180
  end
@@ -24,7 +24,7 @@ module RedditKit
24
24
  # @param multireddit_name [String] The multireddit's name.
25
25
  # @return [RedditKit::Multireddit]
26
26
  def multireddit(*args)
27
- path = "api/multi"
27
+ path = 'api/multi'
28
28
 
29
29
  if args.length == 1
30
30
  path << args.first
@@ -93,7 +93,7 @@ module RedditKit
93
93
  # @param subreddits [Array] An array of subreddit names or RedditKit::Subreddit objects.
94
94
  # @param visibility [public, private] An array of subreddit names to be added to the multireddit.
95
95
  def update_multireddit(multireddit, subreddits = [], visibility = 'private')
96
- create_or_update_multireddit(:put, multireddit, subreddits, visibility)
96
+ create_or_update_multireddit :put, multireddit, subreddits, visibility
97
97
  end
98
98
 
99
99
  # Copies a multireddit.
@@ -162,7 +162,7 @@ module RedditKit
162
162
  path = "api/multi#{multireddit_path}/r/#{subreddit_name}"
163
163
  model = { :name => subreddit_name }
164
164
 
165
- put(path, { :model => model.to_json })
165
+ put path, :model => model.to_json
166
166
  end
167
167
 
168
168
  # Removes a subreddit from a multireddit owned by the current user.
@@ -198,7 +198,7 @@ module RedditKit
198
198
 
199
199
  model = { :visibility => visibility, :subreddits => subreddit_hashes }
200
200
  parameters = { :multipath => multireddit_path, :model => model.to_json }
201
-
201
+
202
202
  request(method, path, parameters, connection)
203
203
  end
204
204
 
@@ -2,7 +2,7 @@ require 'redditkit/private_message'
2
2
 
3
3
  module RedditKit
4
4
  class Client
5
-
5
+
6
6
  # Methods for retrieving and sending private messages.
7
7
  module PrivateMessages
8
8
 
@@ -10,11 +10,13 @@ module RedditKit
10
10
  #
11
11
  # @option options [inbox, unread, sent, messages, mentions, moderator, comments, selfreply] :category The category from which to return messages.
12
12
  # @option options [1..100] :limit The number of messages to return.
13
- # @option options [String] :before Only return subreddits before this id.
13
+ # @option options [String] :before Only return subreddits before this id.
14
14
  # @option options [String] :after Only return subreddits after this id.
15
15
  # @option options [Boolean] :mark Whether to mark requested messages as read.
16
16
  # @return [RedditKit::PaginatedResponse]
17
17
  def messages(options = {})
18
+ options = options.clone
19
+
18
20
  category = options[:category] || 'inbox'
19
21
  path = "message/#{category}.json"
20
22
  options.delete :category
@@ -55,7 +57,7 @@ module RedditKit
55
57
  # Blocks the author of a private message or comment.
56
58
  # Users cannot be blocked based on username as reddit only allows you to block those who have harassed you (thus leaving a message in your inbox).
57
59
  #
58
- # @param message [String, RedditKit::PrivateMessage] A private message's full name, or a RedditKit::PrivateMessage.
60
+ # @param message [String, RedditKit::PrivateMessage] A private message's full name, or a RedditKit::PrivateMessage.
59
61
  def block_author_of_message(message)
60
62
  parameters = { :id => extract_full_name(message) }
61
63
  post('api/block', parameters)
@@ -63,7 +65,7 @@ module RedditKit
63
65
 
64
66
  # Unblocks a user.
65
67
  #
66
- # @param user [String, RedditKit::User] A user's username, or a RedditKit::User.
68
+ # @param user [String, RedditKit::User] A user's username, or a RedditKit::User.
67
69
  def unblock(user)
68
70
  enemy_name = extract_string(user, :username)
69
71
  friend_request 'unfriend', :container => current_user.full_name, :name => enemy_name, :type => :enemy
@@ -12,7 +12,7 @@ module RedditKit
12
12
  # @option options [1..100] limit The number of links to return.
13
13
  # @option options [String] count The number of results to return before or after. This is different from `limit`.
14
14
  # @option options [relevance, new, hot, top, comments] sort The sorting order for search results.
15
- # @option options [String] before Only return links before this full name.
15
+ # @option options [String] before Only return links before this full name.
16
16
  # @option options [String] after Only return links after this full name.
17
17
  # @option options [cloudsearch, lucene, plain] syntax Specify the syntax for the search. Learn more: http://www.reddit.com/r/redditdev/comments/1hpicu/whats_this_syntaxcloudsearch_do/cawm0fe
18
18
  # @option options [hour, day, week, month, year, all] time Show results with a specific time period.
@@ -10,10 +10,12 @@ module RedditKit
10
10
  #
11
11
  # @option options [new, popular, banned] category The category of subreddits. Defaults to popular.
12
12
  # @option options [1..100] limit The number of subreddits to return.
13
- # @option options [String] before Only return subreddits before this id.
13
+ # @option options [String] before Only return subreddits before this id.
14
14
  # @option options [String] after Only return subreddits after this id.
15
15
  # @return [RedditKit::PaginatedResponse]
16
16
  def subreddits(options = {})
17
+ options = options.clone
18
+
17
19
  category = options[:category] or 'popular'
18
20
  path = "reddits/#{category}.json"
19
21
  options.delete :category
@@ -21,14 +23,16 @@ module RedditKit
21
23
  objects_from_response(:get, path, options)
22
24
  end
23
25
 
24
- # Gets the current user's subscribed subreddits.
26
+ # Gets the current user's subscribed subreddits.
25
27
  #
26
28
  # @option options [subscriber, contributor, moderator] category The category from which to return subreddits. Defaults to subscriber.
27
29
  # @option options [1..100] limit The number of subreddits to return.
28
- # @option options [String] before Only return subreddits before this id.
30
+ # @option options [String] before Only return subreddits before this id.
29
31
  # @option options [String] after Only return subreddits after this id.
30
32
  # @return [RedditKit::PaginatedResponse]
31
33
  def subscribed_subreddits(options = {})
34
+ options = options.clone
35
+
32
36
  category = options[:category] or 'subscriber'
33
37
  path = "subreddits/mine/#{category}.json"
34
38
  options.delete :category
@@ -52,7 +56,7 @@ module RedditKit
52
56
  full_name = extract_full_name subreddit
53
57
  parameters = { :action => 'sub', :sr => full_name }
54
58
 
55
- post("api/subscribe", parameters)
59
+ post('api/subscribe', parameters)
56
60
  end
57
61
 
58
62
  # Unsubscribes from a subreddit.
@@ -62,7 +66,7 @@ module RedditKit
62
66
  full_name = extract_full_name subreddit
63
67
  parameters = { :action => 'unsub', :sr => full_name }
64
68
 
65
- post("api/subscribe", parameters)
69
+ post('api/subscribe', parameters)
66
70
  end
67
71
 
68
72
  # Gets a random subreddit.
@@ -97,7 +101,7 @@ module RedditKit
97
101
  response = get('api/subreddits_by_topic.json', parameters)
98
102
  body = response[:body]
99
103
 
100
- body.collect { |subreddit| subreddit[:name] }
104
+ body.map { |subreddit| subreddit[:name] }
101
105
  end
102
106
 
103
107
  # Gets an array of recommended subreddits.
@@ -112,7 +116,7 @@ module RedditKit
112
116
  response = get('api/subreddit_recommendations.json', parameters)
113
117
  body = response[:body]
114
118
 
115
- body.collect { |subreddit| subreddit[:sr_name] }
119
+ body.map { |subreddit| subreddit[:sr_name] }
116
120
  end
117
121
 
118
122
  end
@@ -11,23 +11,25 @@ module RedditKit
11
11
  # @param username [String] A reddit account's username. Gets the current user if this is nil.
12
12
  # @return [RedditKit::User]
13
13
  # @example current_user = client.user
14
- # @example user = client.user 'amberlynns'
14
+ # @example user = client.user 'amberlynns'
15
15
  def user(username = nil)
16
16
  if username
17
17
  object_from_response(:get, "user/#{username}/about.json", nil)
18
18
  else
19
- object_from_response(:get, "api/me.json", nil)
19
+ object_from_response(:get, 'api/me.json', nil)
20
20
  end
21
21
  end
22
22
 
23
- # Gets links and comments for the current user.
23
+ # Gets links and comments for the current user.
24
24
  #
25
25
  # @option options [overview, comments, submitted, liked, disliked] :category The category from which to return links and comments. Defaults to overview.
26
26
  # @option options [1..100] :limit The number of links and comments to return.
27
- # @option options [String] :before Only return links and comments before this id.
27
+ # @option options [String] :before Only return links and comments before this id.
28
28
  # @option options [String] :after Only return links and comments after this id.
29
29
  # @return [RedditKit::PaginatedResponse]
30
30
  def my_content(options = {})
31
+ options = options.clone
32
+
31
33
  category = options[:category] || :overview
32
34
  path = "user/#{@username}/#{category}.json"
33
35
  options.delete :category
@@ -35,15 +37,16 @@ module RedditKit
35
37
  objects_from_response(:get, path, options)
36
38
  end
37
39
 
38
- # Gets links and comments for a user.
40
+ # Gets links and comments for a user.
39
41
  #
40
42
  # @option options [overview, comments, submitted, liked, disliked] :category The category from which to return links and comments. Defaults to overview.
41
43
  # @option options [1..100] :limit The number of links and comments to return.
42
- # @option options [String] :before Only return links and comments before this id.
44
+ # @option options [String] :before Only return links and comments before this id.
43
45
  # @option options [String] :after Only return links and comments after this id.
44
46
  # @return [RedditKit::PaginatedResponse]
45
47
  # @note Public access to the liked and disliked categories is disabled by default, so this will return an empty array for most users.
46
48
  def user_content(user, options = {})
49
+ options = options.clone
47
50
  username = user
48
51
 
49
52
  path = "user/#{username}/%s.json" % (options[:category] if options[:category])
@@ -60,7 +63,7 @@ module RedditKit
60
63
  body = response[:body]
61
64
  friends = body[0][:data][:children]
62
65
 
63
- friends.collect { |friend| OpenStruct.new(friend) }
66
+ friends.map { |friend| OpenStruct.new(friend) }
64
67
  end
65
68
 
66
69
  # Adds a user to the current user's friend list.
@@ -71,25 +74,25 @@ module RedditKit
71
74
  friend_request 'friend', :container => current_user.full_name, :name => friend_name, :type => :friend
72
75
  end
73
76
 
74
- # Removes a user from the current user's friend list.
77
+ # Removes a user from the current user's friend list.
75
78
  #
76
- # @param user [String, RedditKit::User] A user's ID, or a RedditKit::User.
79
+ # @param user [String, RedditKit::User] A user's ID, or a RedditKit::User.
77
80
  def unfriend(user)
78
81
  friend_name = extract_string(user, :username)
79
82
  friend_request 'unfriend', :container => current_user.full_name, :name => friend_name, :type => :friend
80
83
  end
81
84
 
82
- # Checks whether a specific username is available.
85
+ # Checks whether a specific username is available.
83
86
  #
84
87
  # @param username [String] A username for which to check availability.
85
88
  # @return [Boolean]
86
- # @example puts "Username is available" if client.username_available? 'some_username'
89
+ # @example puts "Username is available" if client.username_available? 'some_username'
87
90
  def username_available?(username)
88
91
  response = get('api/username_available.json', :user => username)
89
- available = response[:body]
92
+ response[:body]
90
93
  end
91
94
 
92
- # Registers a new reddit account.
95
+ # Registers a new reddit account.
93
96
  #
94
97
  # @option options [String] username The username to register.
95
98
  # @option options [String] password The password for the account.
@@ -98,7 +101,7 @@ module RedditKit
98
101
  # @option options [String] captcha The user's response to the CAPTCHA challenge.
99
102
  # @option options [Boolean] remember Whether to keep the user's session cookie beyond the current session.
100
103
  def register(username, password, options = {})
101
- parameters = { :user => username, :passwd => password, :passwd2 => password, :captcha => options[:captcha], :iden => options[:captcha_identifier] }
104
+ parameters = { :user => username, :passwd => password, :passwd2 => password, :email => options[:email], :captcha => options[:captcha], :iden => options[:captcha_identifier] }
102
105
  post('api/register', parameters)
103
106
  end
104
107
 
@@ -48,21 +48,21 @@ module RedditKit
48
48
  # @return [Class]
49
49
  def object_class_from_kind(kind)
50
50
  case kind
51
- when "t1"
51
+ when 't1'
52
52
  RedditKit::Comment
53
- when "t2"
53
+ when 't2'
54
54
  RedditKit::User
55
- when "t3"
55
+ when 't3'
56
56
  RedditKit::Link
57
- when "t4"
57
+ when 't4'
58
58
  RedditKit::PrivateMessage
59
- when "t5"
59
+ when 't5'
60
60
  RedditKit::Subreddit
61
- when "LabeledMulti"
61
+ when 'LabeledMulti'
62
62
  RedditKit::Multireddit
63
- when "LabeledMultiDescription"
63
+ when 'LabeledMultiDescription'
64
64
  RedditKit::MultiredditDescription
65
- when "modaction"
65
+ when 'modaction'
66
66
  RedditKit::ModeratorAction
67
67
  end
68
68
  end
@@ -124,6 +124,8 @@ module RedditKit
124
124
  # @param type [friend, unfriend] The type of request.
125
125
  # @param options Any parameters to send with the request.
126
126
  def friend_request(type, options)
127
+ options = options.clone
128
+
127
129
  if options[:subreddit]
128
130
  options[:r] = options[:subreddit]
129
131
  options.delete :subreddit
@@ -6,28 +6,28 @@ module RedditKit
6
6
 
7
7
  # Upvotes a link or comment.
8
8
  #
9
- # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment to upvote.
9
+ # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment to upvote.
10
10
  def upvote(link_or_comment)
11
11
  vote link_or_comment, 1
12
12
  end
13
13
 
14
- # Downvotes a link or comment.
14
+ # Downvotes a link or comment.
15
15
  #
16
- # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment to downvote.
16
+ # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment to downvote.
17
17
  def downvote(link_or_comment)
18
18
  vote link_or_comment, -1
19
19
  end
20
20
 
21
21
  # Withdraws a vote on a link or comment.
22
22
  #
23
- # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment from which to withdraw the vote.
23
+ # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment from which to withdraw the vote.
24
24
  def withdraw_vote(link_or_comment)
25
25
  vote link_or_comment, 0
26
26
  end
27
27
 
28
28
  # Votes on a link or comment.
29
29
  #
30
- # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment from which to withdraw the vote.
30
+ # @param link_or_comment [String, RedditKit::Comment, RedditKit::Link] The link or comment from which to withdraw the vote.
31
31
  # @param direction [-1, 0, 1] Downvote, no vote, and upvote respectively.
32
32
  def vote(link_or_comment, direction)
33
33
  full_name = extract_full_name(link_or_comment)