redditkit 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/redditkit.rb +4 -3
- data/lib/redditkit/client.rb +6 -8
- data/lib/redditkit/client/apps.rb +8 -8
- data/lib/redditkit/client/captcha.rb +2 -2
- data/lib/redditkit/client/comments.rb +2 -2
- data/lib/redditkit/client/flair.rb +10 -8
- data/lib/redditkit/client/links.rb +24 -20
- data/lib/redditkit/client/miscellaneous.rb +10 -10
- data/lib/redditkit/client/moderation.rb +23 -21
- data/lib/redditkit/client/multireddits.rb +4 -4
- data/lib/redditkit/client/private_messages.rb +6 -4
- data/lib/redditkit/client/search.rb +1 -1
- data/lib/redditkit/client/subreddits.rb +11 -7
- data/lib/redditkit/client/users.rb +17 -14
- data/lib/redditkit/client/utilities.rb +10 -8
- data/lib/redditkit/client/voting.rb +5 -5
- data/lib/redditkit/client/wiki.rb +4 -0
- data/lib/redditkit/comment.rb +4 -4
- data/lib/redditkit/error.rb +3 -3
- data/lib/redditkit/link.rb +14 -14
- data/lib/redditkit/moderator_action.rb +4 -4
- data/lib/redditkit/multireddit.rb +2 -2
- data/lib/redditkit/multireddit_description.rb +2 -2
- data/lib/redditkit/private_message.rb +2 -2
- data/lib/redditkit/response/parse_json.rb +7 -1
- data/lib/redditkit/response/raise_error.rb +4 -5
- data/lib/redditkit/subreddit.rb +13 -10
- data/lib/redditkit/thing.rb +1 -0
- data/lib/redditkit/user.rb +12 -8
- data/lib/redditkit/version.rb +1 -5
- data/lib/redditkit/votable.rb +2 -2
- data/redditkit.gemspec +1 -1
- data/spec/cassettes/RedditKit_Client_Flair/_flair_list/returns_the_list_of_flair.yml +51 -4
- data/spec/cassettes/RedditKit_Client_Moderation/_ban/requests_the_correct_resource.yml +70 -23
- data/spec/cassettes/RedditKit_Client_Moderation/_contributors_to_subreddit/requests_the_correct_resource.yml +52 -5
- data/spec/cassettes/RedditKit_Client_Moderation/_moderation_log/returns_RedditKit_ModeratorAction_objects.yml +150 -109
- data/spec/cassettes/RedditKit_Client_Moderation/_moderators_of_subreddit/requests_the_correct_resource.yml +53 -6
- data/spec/cassettes/RedditKit_Client_Moderation/_unban/requests_the_correct_resource.yml +61 -14
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit/without_a_path/returns_a_multireddit.yml +49 -7
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit_description/with_a_multireddit/returns_a_multireddit_description.yml +102 -11
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit_description/with_a_username_and_multireddit_name/returns_a_multireddit_description.yml +54 -5
- data/spec/cassettes/RedditKit_Client_Search/_search/restricts_searches_to_a_specific_subreddit.yml +925 -0
- data/spec/cassettes/RedditKit_Client_Search/_search/returns_a_specific_number_of_results.yml +116 -0
- data/spec/cassettes/RedditKit_Client_Search/_search/returns_search_results.yml +884 -0
- data/spec/cassettes/RedditKit_Client_Wiki/_add_wiki_editor/requests_the_correct_resource.yml +58 -4
- data/spec/cassettes/RedditKit_Client_Wiki/_edit_wiki_page/requests_the_correct_resource.yml +58 -4
- data/spec/cassettes/RedditKit_Client_Wiki/_hide_wiki_revision/requests_the_correct_resource.yml +58 -4
- data/spec/cassettes/RedditKit_Client_Wiki/_remove_wiki_editor/requests_the_correct_resource.yml +58 -4
- data/spec/cassettes/RedditKit_Client_Wiki/_revert_to_revision/requests_the_correct_resource.yml +58 -4
- data/spec/redditkit/comment_spec.rb +6 -6
- data/spec/redditkit/link_spec.rb +38 -7
- data/spec/redditkit/thing_spec.rb +8 -0
- data/spec/redditkit/user_spec.rb +14 -0
- data/spec/spec_helper.rb +0 -4
- metadata +7 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cebc62a3ed2c61e757d97c82eb5476eba7a1c74
|
4
|
+
data.tar.gz: c47a8e01b50625a3015eeab55c6a2a9e4960e7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ac50a6beb64a4a57d0e3c476381f70d264c14c0650889710ffb323c0cf3e65f0ce1a7844ae6ca776d851a07c8d079b086d0b34696fd444abc846989cf699f68
|
7
|
+
data.tar.gz: fa09d0b525b8e94b2caf567e595bd1a8894288a073387e1f0a828fe165d8086c6da05c3bd840c2e41820bacbea9605d5d46ccbf690208673b986d766615f07b2
|
data/README.md
CHANGED
@@ -2,19 +2,25 @@
|
|
2
2
|
|
3
3
|
RedditKit.rb is a [reddit API](http://www.reddit.com/dev/api) wrapper, written in Ruby.
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/redditkit.png)][rubygem]
|
5
6
|
[![Build Status](https://travis-ci.org/samsymons/RedditKit.rb.png?branch=master)][travis]
|
6
7
|
[![Code Climate](https://codeclimate.com/github/samsymons/RedditKit.rb.png)][codeclimate]
|
7
8
|
[![Coverage Status](https://coveralls.io/repos/samsymons/RedditKit.rb/badge.png?branch=master)][coveralls]
|
8
9
|
|
9
|
-
[
|
10
|
+
[rubygem]: https://rubygems.org/gems/redditkit
|
11
|
+
[travis]: https://travis-ci.org/samsymons/RedditKit.rb
|
10
12
|
[codeclimate]: https://codeclimate.com/github/samsymons/RedditKit.rb
|
11
13
|
[coveralls]: https://coveralls.io/r/samsymons/RedditKit.rb
|
12
14
|
|
15
|
+
## Documentation
|
16
|
+
|
17
|
+
[http://rdoc.info/gems/redditkit/](http://rdoc.info/gems/redditkit/)
|
18
|
+
|
13
19
|
## Installation
|
14
20
|
|
15
21
|
Add this to your Gemfile:
|
16
22
|
|
17
|
-
gem 'redditkit', '~> 1.0'
|
23
|
+
gem 'redditkit', '~> 1.0.1'
|
18
24
|
|
19
25
|
Or install it directly:
|
20
26
|
|
@@ -92,8 +98,6 @@ paginated_response.each do |link|
|
|
92
98
|
end
|
93
99
|
```
|
94
100
|
|
95
|
-
## Multiple Accounts
|
96
|
-
|
97
101
|
## Configuration
|
98
102
|
|
99
103
|
You can configure various aspects of RedditKit.rb's operation, including its default API endpoint and user agent, by setting attributes on `RedditKit::Client`.
|
data/lib/redditkit.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'redditkit/client'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
# The main RedditKit module.
|
4
5
|
module RedditKit
|
5
6
|
class << self
|
6
7
|
|
7
|
-
# A RedditKit::Client, used when calling methods on the RedditKit module itself.
|
8
|
+
# A RedditKit::Client, used when calling methods on the RedditKit module itself.
|
8
9
|
#
|
9
10
|
# @return [RedditKit::Client]
|
10
11
|
def client
|
@@ -13,7 +14,7 @@ module RedditKit
|
|
13
14
|
|
14
15
|
def respond_to?(method_name, include_private = false)
|
15
16
|
client.respond_to?(method_name, include_private) || super
|
16
|
-
end
|
17
|
+
end
|
17
18
|
|
18
19
|
private
|
19
20
|
|
@@ -21,6 +22,6 @@ module RedditKit
|
|
21
22
|
return super unless client.respond_to?(method_name)
|
22
23
|
client.send(method_name, *args, &block)
|
23
24
|
end
|
24
|
-
|
25
|
+
|
25
26
|
end
|
26
27
|
end
|
data/lib/redditkit/client.rb
CHANGED
@@ -58,9 +58,7 @@ module RedditKit
|
|
58
58
|
@cookie = nil
|
59
59
|
@modhash = nil
|
60
60
|
|
61
|
-
unless
|
62
|
-
sign_in @username, @password
|
63
|
-
end
|
61
|
+
sign_in(username, password) unless username.nil? || password.nil?
|
64
62
|
end
|
65
63
|
|
66
64
|
def api_endpoint
|
@@ -76,7 +74,7 @@ module RedditKit
|
|
76
74
|
end
|
77
75
|
|
78
76
|
def middleware
|
79
|
-
@middleware ||= Faraday::
|
77
|
+
@middleware ||= Faraday::RackBuilder.new do |builder|
|
80
78
|
builder.use Faraday::Request::UrlEncoded
|
81
79
|
builder.use RedditKit::Response::RaiseError
|
82
80
|
builder.use RedditKit::Response::ParseJSON
|
@@ -113,14 +111,14 @@ module RedditKit
|
|
113
111
|
else
|
114
112
|
request_connection.send(method.to_sym, path, parameters).env
|
115
113
|
end
|
116
|
-
rescue Faraday::Error::ClientError
|
114
|
+
rescue Faraday::Error::ClientError
|
117
115
|
raise RedditKit::RequestError
|
118
116
|
end
|
119
117
|
|
120
118
|
def authenticated_request_configuration(method, path, parameters)
|
121
|
-
|
119
|
+
fail RedditKit::NotAuthenticated unless signed_in?
|
122
120
|
|
123
|
-
|
121
|
+
proc do |request|
|
124
122
|
request.headers['Cookie'] = "reddit_session=#{@cookie}"
|
125
123
|
request.headers['X-Modhash'] = @modhash
|
126
124
|
end
|
@@ -135,7 +133,7 @@ module RedditKit
|
|
135
133
|
end
|
136
134
|
|
137
135
|
def connection_with_url(url)
|
138
|
-
Faraday.new
|
136
|
+
Faraday.new url, :builder => middleware
|
139
137
|
end
|
140
138
|
|
141
139
|
end
|
@@ -3,7 +3,7 @@ module RedditKit
|
|
3
3
|
|
4
4
|
# Methods for operating on apps in the current user's account.
|
5
5
|
module Apps
|
6
|
-
|
6
|
+
|
7
7
|
# Create or update an app.
|
8
8
|
#
|
9
9
|
# @param name [String] The app's name.
|
@@ -20,35 +20,35 @@ module RedditKit
|
|
20
20
|
|
21
21
|
post('api/updateapp', parameters)
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
alias_method :update_app, :create_app
|
24
|
+
|
25
25
|
# Delete an app.
|
26
26
|
#
|
27
27
|
# @param app_identifier [String] The identifier of the app.
|
28
28
|
def delete_app(app_identifier)
|
29
|
-
post
|
29
|
+
post 'api/deleteapp', :client_id => app_identifier
|
30
30
|
end
|
31
31
|
|
32
32
|
# Revoke an app.
|
33
33
|
#
|
34
34
|
# @param app_identifier [String] The identifier of the app.
|
35
35
|
def revoke_app(app_identifier)
|
36
|
-
post
|
36
|
+
post 'api/revokeapp', :client_id => app_identifier
|
37
37
|
end
|
38
38
|
|
39
39
|
# Add a user as a developer of an app.
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# @param user [String, RedditKit::User] The username of the user to add, or a RedditKit::User.
|
42
42
|
# @param app_identifier [String] The identifier of the app.
|
43
43
|
def add_developer(user, app_identifier)
|
44
44
|
username = extract_string user, :username
|
45
45
|
parameters = { :name => username, :client_id => app_identifier }
|
46
46
|
|
47
|
-
post
|
47
|
+
post 'api/adddeveloper', parameters
|
48
48
|
end
|
49
49
|
|
50
50
|
# Remove an app's developer.
|
51
|
-
#
|
51
|
+
#
|
52
52
|
# @param user [String, RedditKit::User] The username of the user to add, or a RedditKit::User.
|
53
53
|
# @param app_identifier [String] The identifier of the app.
|
54
54
|
def remove_developer(user, app_identifier)
|
@@ -8,7 +8,7 @@ module RedditKit
|
|
8
8
|
#
|
9
9
|
# @return [Boolean]
|
10
10
|
def needs_captcha?
|
11
|
-
response = get
|
11
|
+
response = get 'api/needs_captcha.json'
|
12
12
|
needs_captcha = response[:body]
|
13
13
|
|
14
14
|
needs_captcha.to_s == 'true'
|
@@ -18,7 +18,7 @@ module RedditKit
|
|
18
18
|
#
|
19
19
|
# @return [String] The CAPTCHA identifier.
|
20
20
|
def new_captcha_identifier
|
21
|
-
response = post
|
21
|
+
response = post 'api/new_captcha', :api_type => :json
|
22
22
|
data = response[:body][:json][:data]
|
23
23
|
|
24
24
|
data[:iden]
|
@@ -16,7 +16,7 @@ module RedditKit
|
|
16
16
|
comments.first
|
17
17
|
end
|
18
18
|
|
19
|
-
# Get comments on a link.
|
19
|
+
# Get comments on a link.
|
20
20
|
#
|
21
21
|
# @param link [String, RedditKit::Link] The identifier of the link, or a RedditKit::Link.
|
22
22
|
# @option options [Integer] :limit The number of comments to return.
|
@@ -45,7 +45,7 @@ module RedditKit
|
|
45
45
|
full_comment_data = response_data[:things].first
|
46
46
|
comment_data = full_comment_data[:data]
|
47
47
|
comment_full_name = comment_data[:id]
|
48
|
-
|
48
|
+
|
49
49
|
comment comment_full_name
|
50
50
|
end
|
51
51
|
|
@@ -6,11 +6,11 @@ module RedditKit
|
|
6
6
|
# Methods for interacting with flair in subreddits.
|
7
7
|
module Flair
|
8
8
|
|
9
|
-
# Lists users and their flair in a subreddit.
|
9
|
+
# Lists users and their flair in a subreddit.
|
10
10
|
#
|
11
11
|
# @param subreddit [String, RedditKit::Subreddit] A subreddit's name, or a RedditKit::Subreddit.
|
12
12
|
# @option options [1..1000] :limit The number of items to return.
|
13
|
-
# @option options [String] :before Only return objects before this id.
|
13
|
+
# @option options [String] :before Only return objects before this id.
|
14
14
|
# @option options [String] :after Only return objects after this id.
|
15
15
|
def flair_list(subreddit, options = {})
|
16
16
|
subreddit_name = extract_string(subreddit, :display_name)
|
@@ -19,7 +19,7 @@ module RedditKit
|
|
19
19
|
|
20
20
|
users.collect { |user| OpenStruct.new(user) }
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
# Creates a flair template in a subreddit.
|
24
24
|
#
|
25
25
|
# @param subreddit [String, RedditKit::Subreddit] A subreddit's name, or a RedditKit::Subreddit.
|
@@ -48,12 +48,12 @@ module RedditKit
|
|
48
48
|
post('api/deleteflairtemplate', parameters)
|
49
49
|
end
|
50
50
|
|
51
|
-
# Toggles flair for a subreddit.
|
51
|
+
# Toggles flair for a subreddit.
|
52
52
|
#
|
53
53
|
# @param subreddit [String, RedditKit::Subreddit] A subreddit's name, or a RedditKit::Subreddit.
|
54
|
-
# @param flair_enabled [Boolean] Whether to enable flair for the subreddit.
|
54
|
+
# @param flair_enabled [Boolean] Whether to enable flair for the subreddit.
|
55
55
|
def toggle_flair(subreddit, flair_enabled)
|
56
|
-
post('api/setflairenabled', { :r => subreddit, :flair_enabled => flair_enabled })
|
56
|
+
post('api/setflairenabled', { :r => subreddit, :flair_enabled => flair_enabled })
|
57
57
|
end
|
58
58
|
|
59
59
|
# Sets flair on a link or user.
|
@@ -132,15 +132,17 @@ module RedditKit
|
|
132
132
|
#
|
133
133
|
# @param subreddit [String, RedditKit::Subreddit] A subreddit's name, or a RedditKit::Subreddit.
|
134
134
|
# @option options [Boolean] flair_enabled Whether to enable flair for the subreddit.
|
135
|
-
# @option options [left, right] flair_position The position of user flair.
|
135
|
+
# @option options [left, right] flair_position The position of user flair.
|
136
136
|
# @option options [left, right] link_flair_position The position of link flair.
|
137
137
|
# @option options [Boolean] flair_self_assign_enabled Whether users may assign their own flair.
|
138
138
|
# @option options [Boolean] link_flair_self_assign_enabled Whether users may assign their own link flair.
|
139
139
|
def set_flair_options(subreddit, options = {})
|
140
|
+
options = options.clone
|
141
|
+
|
140
142
|
subreddit_name = extract_string(subreddit, :display_name)
|
141
143
|
options.merge!({ :r => subreddit_name, :uh => @modhash })
|
142
144
|
|
143
|
-
post('api/flairconfig', options)
|
145
|
+
post('api/flairconfig', options)
|
144
146
|
end
|
145
147
|
|
146
148
|
end
|
@@ -5,13 +5,13 @@ module RedditKit
|
|
5
5
|
|
6
6
|
# Methods for retrieving, submitting and interacting with links.
|
7
7
|
module Links
|
8
|
-
|
8
|
+
|
9
9
|
# Gets the links currently on the front page.
|
10
10
|
#
|
11
|
-
# @option options [hot, new, rising, controversial, top] :category The category from which to retrieve links.
|
11
|
+
# @option options [hot, new, rising, controversial, top, ads] :category The category from which to retrieve links.
|
12
12
|
# @option options [hour, day, week, month, year, all] :time The time from which to retrieve links. Defaults to all time.
|
13
13
|
# @option options [1..100] :limit The number of links to return.
|
14
|
-
# @option options [String] :before Only return links before this identifier.
|
14
|
+
# @option options [String] :before Only return links before this identifier.
|
15
15
|
# @option options [String] :after Only return links after this identifier.
|
16
16
|
# @return [RedditKit::PaginatedResponse]
|
17
17
|
def front_page(options = {})
|
@@ -21,13 +21,15 @@ module RedditKit
|
|
21
21
|
# Gets an array of links from a specific subreddit.
|
22
22
|
#
|
23
23
|
# @param subreddit [String, RedditKit::Subreddit] The display name of the subreddit, or a RedditKit::Subreddit.
|
24
|
-
# @option options [hot, new, rising, controversial, top] :category The category from which to retrieve links.
|
24
|
+
# @option options [hot, new, rising, controversial, top, ads] :category The category from which to retrieve links.
|
25
25
|
# @option options [hour, day, week, month, year, all] :time The time from which to retrieve links. Defaults to all time.
|
26
26
|
# @option options [1..100] :limit The number of links to return.
|
27
|
-
# @option options [String] :before Only return links before this identifier.
|
27
|
+
# @option options [String] :before Only return links before this identifier.
|
28
28
|
# @option options [String] :after Only return links after this identifier.
|
29
29
|
# @return [RedditKit::PaginatedResponse]
|
30
30
|
def links(subreddit, options = {})
|
31
|
+
options = options.clone
|
32
|
+
|
31
33
|
subreddit_name = extract_string(subreddit, :display_name) if subreddit
|
32
34
|
category = options[:category] || :hot
|
33
35
|
|
@@ -50,16 +52,18 @@ module RedditKit
|
|
50
52
|
links.first
|
51
53
|
end
|
52
54
|
|
53
|
-
# Gets links with a specific domain.
|
55
|
+
# Gets links with a specific domain.
|
54
56
|
#
|
55
57
|
# @param domain [String] The domain for which to get links.
|
56
58
|
# @option options [hour, day, week, month, year] :time The time from which to retrieve links. Defaults to all time.
|
57
59
|
# @option options [1..100] :limit The number of links to return.
|
58
|
-
# @option options [String] :before Only return links before this identifier.
|
60
|
+
# @option options [String] :before Only return links before this identifier.
|
59
61
|
# @option options [String] :after Only return links after this identifier.
|
60
62
|
# @return [RedditKit::PaginatedResponse]
|
61
63
|
# @example links = RedditKit.links_with_domain "github.com"
|
62
64
|
def links_with_domain(domain, options = {})
|
65
|
+
options = options.clone
|
66
|
+
|
63
67
|
parameters = { :url => domain, :t => options[:time] }
|
64
68
|
options.merge! parameters
|
65
69
|
options.delete :t
|
@@ -67,10 +71,10 @@ module RedditKit
|
|
67
71
|
objects_from_response(:get, 'api/info.json', options)
|
68
72
|
end
|
69
73
|
|
70
|
-
# Submits a link or self post to reddit.
|
74
|
+
# Submits a link or self post to reddit.
|
71
75
|
#
|
72
76
|
# @param title [String] The title of the post.
|
73
|
-
# @param subreddit [String, RedditKit::Subreddit] A subreddit's display name, or a RedditKit::Subreddit.
|
77
|
+
# @param subreddit [String, RedditKit::Subreddit] A subreddit's display name, or a RedditKit::Subreddit.
|
74
78
|
# @option options [String] :url The URL for the post. Note that if this value is present, :text will be ignored.
|
75
79
|
# @option options [String] :text The text value for the post, as Markdown.
|
76
80
|
# @option options [String] :captcha_identifier An identifier for a CAPTCHA, if the current user is required to fill one out.
|
@@ -85,7 +89,7 @@ module RedditKit
|
|
85
89
|
:captcha => options[:captcha_value],
|
86
90
|
:save => options[:save]
|
87
91
|
}
|
88
|
-
|
92
|
+
|
89
93
|
if options[:url]
|
90
94
|
parameters[:url] = options[:url]
|
91
95
|
parameters[:kind] = 'link'
|
@@ -94,36 +98,36 @@ module RedditKit
|
|
94
98
|
parameters[:kind] = 'self'
|
95
99
|
end
|
96
100
|
|
97
|
-
post
|
101
|
+
post 'api/submit', parameters
|
98
102
|
end
|
99
103
|
|
100
104
|
# Marks a link as not safe for work.
|
101
105
|
#
|
102
|
-
# @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
|
106
|
+
# @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
|
103
107
|
def mark_nsfw(link)
|
104
|
-
post
|
108
|
+
post 'api/marknsfw', :id => extract_full_name(link)
|
105
109
|
end
|
106
110
|
|
107
111
|
# Marks a link as safe for work.
|
108
112
|
#
|
109
|
-
# @param link [String, RedditKit::Subreddit] A link's full name, or a RedditKit::Link.
|
113
|
+
# @param link [String, RedditKit::Subreddit] A link's full name, or a RedditKit::Link.
|
110
114
|
def mark_sfw(link)
|
111
|
-
post
|
115
|
+
post 'api/unmarknsfw', :id => extract_full_name(link)
|
112
116
|
end
|
113
|
-
|
117
|
+
alias_method :unmark_nsfw, :mark_sfw
|
114
118
|
|
115
119
|
# Hides a link.
|
116
120
|
#
|
117
|
-
# @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
|
121
|
+
# @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
|
118
122
|
def hide(link)
|
119
|
-
post
|
123
|
+
post 'api/hide', :id => extract_full_name(link)
|
120
124
|
end
|
121
125
|
|
122
126
|
# Unhides a link.
|
123
127
|
#
|
124
|
-
# @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
|
128
|
+
# @param link [String, RedditKit::Link] A link's full name, or a RedditKit::Link.
|
125
129
|
def unhide(link)
|
126
|
-
post
|
130
|
+
post 'api/unhide', :id => extract_full_name(link)
|
127
131
|
end
|
128
132
|
|
129
133
|
# Gets a random link.
|
@@ -6,7 +6,7 @@ module RedditKit
|
|
6
6
|
|
7
7
|
# Edit the text or a self post or comment.
|
8
8
|
#
|
9
|
-
# @param object [String, RedditKit::Comment, RedditKit::Link] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
9
|
+
# @param object [String, RedditKit::Comment, RedditKit::Link] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
10
10
|
# @option options [String] text The new text for the link or comment.
|
11
11
|
def edit(object, options)
|
12
12
|
parameters = { :text => options[:text], :thing_id => extract_full_name(object) }
|
@@ -15,36 +15,36 @@ module RedditKit
|
|
15
15
|
|
16
16
|
# Deletes a link or comment.
|
17
17
|
#
|
18
|
-
# @param object [String, RedditKit::Comment, RedditKit::Link] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
18
|
+
# @param object [String, RedditKit::Comment, RedditKit::Link] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
19
19
|
def delete(object)
|
20
20
|
full_name = extract_full_name object
|
21
|
-
post
|
21
|
+
post 'api/del', :id => full_name
|
22
22
|
end
|
23
23
|
|
24
24
|
# Saves a link or comment.
|
25
25
|
#
|
26
|
-
# @param object [String, RedditKit::Link, RedditKit::Subreddit] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
26
|
+
# @param object [String, RedditKit::Link, RedditKit::Subreddit] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
27
27
|
def save(object)
|
28
28
|
full_name = extract_full_name object
|
29
|
-
post
|
29
|
+
post 'api/save', :id => full_name
|
30
30
|
end
|
31
31
|
|
32
32
|
# Unsaves a link or comment.
|
33
33
|
#
|
34
|
-
# @param object [String, RedditKit::Link, RedditKit::Subreddit] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
34
|
+
# @param object [String, RedditKit::Link, RedditKit::Subreddit] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
35
35
|
def unsave(object)
|
36
36
|
full_name = extract_full_name object
|
37
|
-
post
|
37
|
+
post 'api/unsave', :id => full_name
|
38
38
|
end
|
39
39
|
|
40
40
|
# Reports a link or comment. The reddit API will also hide the link or comment.
|
41
41
|
#
|
42
|
-
# @param object [String, RedditKit::Link, RedditKit::Comment] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
42
|
+
# @param object [String, RedditKit::Link, RedditKit::Comment] A link or comment's full name, a RedditKit::Link, or a RedditKit::Subreddit.
|
43
43
|
def report(object)
|
44
44
|
full_name = extract_full_name object
|
45
|
-
post
|
45
|
+
post 'api/report', :id => full_name
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|