Class: TVDB::Authorization
- Inherits:
-
Object
- Object
- TVDB::Authorization
- Defined in:
- lib/tvdb_client/authorization.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(options) ⇒ Authorization
constructor
A new instance of Authorization.
- #login ⇒ Object
- #refresh_token ⇒ Object
Constructor Details
#initialize(options) ⇒ Authorization
Returns a new instance of Authorization.
8 9 10 11 12 13 |
# File 'lib/tvdb_client/authorization.rb', line 8 def initialize( ) @username = .fetch( :username ) { nil } @password = .fetch( :userpass ) { nil } @api_key = .fetch( :apikey ) { Settings.tvdb.apikey } @connection = .fetch( :connection ) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/tvdb_client/authorization.rb', line 5 def api_key @api_key end |
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/tvdb_client/authorization.rb', line 6 def connection @connection end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/tvdb_client/authorization.rb', line 5 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/tvdb_client/authorization.rb', line 5 def username @username end |
Instance Method Details
#login ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tvdb_client/authorization.rb', line 15 def login credentials = { :username => username, :userpass => password, :apikey => api_key } response = connection.post( "/login", body: credentials ) handle_response( response ) end |
#refresh_token ⇒ Object
27 28 29 30 31 |
# File 'lib/tvdb_client/authorization.rb', line 27 def refresh_token response = connection.get( '/refresh_token' ) handle_response( response ) end |