Class: Esi::Client
- Inherits:
-
Object
- Object
- Esi::Client
- Defined in:
- lib/esi/client.rb
Constant Summary collapse
- MAX_ATTEMPTS =
5
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#refresh_callback ⇒ Object
Returns the value of attribute refresh_callback.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
Instance Method Summary collapse
- #debug(message) ⇒ Object
-
#initialize(token: nil, refresh_token: nil, expires_at: nil) ⇒ Client
constructor
A new instance of Client.
- #log(message) ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(token: nil, refresh_token: nil, expires_at: nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 |
# File 'lib/esi/client.rb', line 8 def initialize(token: nil, refresh_token: nil, expires_at: nil) @logger = Esi.logger @token = token @refresh_token = refresh_token @expires_at = expires_at end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/esi/client.rb', line 15 def method_missing(name, *args, &block) klass = nil ActiveSupport::Notifications.instrument('esi.client.detect_call') do class_name = name.to_s.split('_').map(&:capitalize).join begin klass = Esi::Calls.const_get(class_name) rescue NameError super(name, *args, &block) end end call = klass.new(*args) call.paginated? ? request_paginated(call, &block) : request(call, &block) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/esi/client.rb', line 5 def access_token @access_token end |
#expires_at ⇒ Object
Returns the value of attribute expires_at.
5 6 7 |
# File 'lib/esi/client.rb', line 5 def expires_at @expires_at end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/esi/client.rb', line 6 def logger @logger end |
#refresh_callback ⇒ Object
Returns the value of attribute refresh_callback.
5 6 7 |
# File 'lib/esi/client.rb', line 5 def refresh_callback @refresh_callback end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
5 6 7 |
# File 'lib/esi/client.rb', line 5 def refresh_token @refresh_token end |
Instance Method Details
#debug(message) ⇒ Object
34 35 36 |
# File 'lib/esi/client.rb', line 34 def debug() logger.debug end |
#log(message) ⇒ Object
30 31 32 |
# File 'lib/esi/client.rb', line 30 def log() logger.info end |