Class: Redd::Client::Authenticated
- Inherits:
-
Unauthenticated
- Object
- Unauthenticated
- Redd::Client::Authenticated
- Includes:
- Account, Apps, Flair, Gold, LinksComments, Live, Moderation, Multis, PrivateMessages, Subreddits, Users, Wiki
- Defined in:
- lib/redd/client/authenticated.rb,
lib/redd/client/authenticated/apps.rb,
lib/redd/client/authenticated/gold.rb,
lib/redd/client/authenticated/live.rb,
lib/redd/client/authenticated/wiki.rb,
lib/redd/client/authenticated/flair.rb,
lib/redd/client/authenticated/users.rb,
lib/redd/client/authenticated/multis.rb,
lib/redd/client/authenticated/account.rb,
lib/redd/client/authenticated/moderation.rb,
lib/redd/client/authenticated/subreddits.rb,
lib/redd/client/authenticated/links_comments.rb,
lib/redd/client/authenticated/private_messages.rb
Overview
The class that handles requests when authenticated using a username and password.
Direct Known Subclasses
Defined Under Namespace
Modules: Account, Apps, Flair, Gold, LinksComments, Live, Moderation, Multis, PrivateMessages, Subreddits, Users, Wiki
Instance Attribute Summary collapse
-
#cookie ⇒ String
readonly
The cookie used to store the current session.
-
#modhash ⇒ String
readonly
The returned modhash used when making requests.
-
#username ⇒ String
readonly
The username of the logged-in user.
Attributes inherited from Unauthenticated
#api_endpoint, #rate_limit, #user_agent
Instance Method Summary collapse
-
#headers ⇒ Hash
private
The headers that are sent with every request.
-
#initialize(cookie, modhash, options = {}) ⇒ Authenticated
constructor
Set up an authenticated connection to reddit.
- #new_from_credentials(username, password, options = {}) ⇒ Object
Methods included from Subreddits
#edit_subscription, #get_subreddits, #subscribe, #unsubscribe
Methods included from PrivateMessages
#block_message, #compose_message, #mark_as_read, #mark_as_unread, #messages
Methods included from Moderation
#accept_moderator_invite, #approve, #distinguish, #get_modqueue, #get_reports, #get_spam, #get_submissions, #get_unmoderated, #ignore_reports, #leave_contributor_status, #leave_moderator_status, #remove, #undistinguish, #unignore_reports
Methods included from LinksComments
#add_comment, #delete, #downvote, #edit, #hide, #mark_as_nsfw, #report, #save, #submit, #unhide, #unmark_as_nsfw, #unsave, #unvote, #upvote, #vote
Methods included from Flair
#get_flair, #get_flair_list, #set_flair
Methods included from Account
Methods inherited from Unauthenticated
#connection, #delete, #get, #post, #put, #request
Methods included from Unauthenticated::Wiki
Methods included from Unauthenticated::Utilities
#comment_stream, #comments_from_response, #extract_attribute, #extract_fullname, #extract_id, #object_from_body, #object_from_kind, #object_from_response, #objects_from_listing, #submission_stream
Methods included from Unauthenticated::Subreddits
#get_subreddits, #search_subreddits, #subreddit
Methods included from Unauthenticated::Moderation
Methods included from Unauthenticated::Listing
#by_id, #get_comments, #get_controversial, #get_hot, #get_listing, #get_new, #get_random, #get_top
Methods included from Unauthenticated::LinksComments
#get_info, #get_replies, #replace_morecomments, #submission_comments
Methods included from Unauthenticated::Captcha
#captcha_url, #needs_captcha?, #new_captcha
Methods included from Unauthenticated::Account
Constructor Details
#initialize(cookie, modhash, options = {}) ⇒ Authenticated
Set up an authenticated connection to reddit.
59 60 61 62 63 64 65 66 |
# File 'lib/redd/client/authenticated.rb', line 59 def initialize(, modhash, = {}) @cookie = @modhash = modhash @rate_limit = [:rate_limit] || Redd::RateLimit.new @user_agent = [:user_agent] || "Redd/Ruby, v#{Redd::VERSION}" @api_endpoint = [:api_endpoint] || "https://www.reddit.com/" end |
Instance Attribute Details
#cookie ⇒ String (readonly)
Returns The cookie used to store the current session.
38 39 40 |
# File 'lib/redd/client/authenticated.rb', line 38 def @cookie end |
#modhash ⇒ String (readonly)
Returns The returned modhash used when making requests.
42 43 44 |
# File 'lib/redd/client/authenticated.rb', line 42 def modhash @modhash end |
#username ⇒ String (readonly)
Returns The username of the logged-in user.
34 35 36 |
# File 'lib/redd/client/authenticated.rb', line 34 def username @username end |
Instance Method Details
#headers ⇒ Hash (private)
Returns The headers that are sent with every request.
71 72 73 74 75 76 77 |
# File 'lib/redd/client/authenticated.rb', line 71 def headers @headers ||= { "User-Agent" => @user_agent, "Cookie" => "reddit_session=#{@cookie}", "X-Modhash" => @modhash } end |