Class: Redd::Clients::Script
Overview
The client for an account you own (e.g. bots).
Constant Summary
Constants included from Base::Utilities
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Attributes inherited from Base
#access, #api_endpoint, #auth_endpoint, #rate_limit, #user_agent
Instance Method Summary collapse
-
#authorize! ⇒ Access
(also: #refresh_access!)
Authorize using the given data.
-
#initialize(client_id, secret, username, password, **options) ⇒ Script
constructor
A new instance of Script.
Methods inherited from Base
#delete, #get, #patch, #post, #put, #revoke_access!, #with
Methods included from Base::Wikiread
Methods included from Base::Stream
Methods included from Base::Submit
Methods included from Base::Read
#from_fullname, #from_url, #get_comments, #get_controversial, #get_hot, #get_new, #get_top, #multi_from_path, #my_multis, #search, #subreddit_from_name, #user_from_name
Methods included from Base::Privatemessages
#my_messages, #read_all_messages
Methods included from Base::None
#captcha_url, #needs_captcha?, #new_captcha
Methods included from Base::Identity
Methods included from Base::Account
Methods included from Base::Utilities
#append_to_listing, #flat_comments, #object_from_body, #property, #request_object
Constructor Details
#initialize(client_id, secret, username, password, **options) ⇒ Script
Returns a new instance of Script.
16 17 18 19 20 21 22 |
# File 'lib/redd/clients/script.rb', line 16 def initialize(client_id, secret, username, password, **) @client_id = client_id @secret = secret @username = username @password = password super(**) end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/redd/clients/script.rb', line 8 def client_id @client_id end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
11 12 13 |
# File 'lib/redd/clients/script.rb', line 11 def username @username end |
Instance Method Details
#authorize! ⇒ Access Also known as: refresh_access!
Authorize using the given data.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/redd/clients/script.rb', line 26 def # reset the connection for when the access token is refreshed @connection = nil response = auth_connection.post( '/api/v1/access_token', grant_type: 'password', username: @username, password: @password ) @access = Access.new(response.body) end |