Class: Esi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/esi/client.rb

Constant Summary collapse

MAX_ATTEMPTS =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject

Returns the value of attribute access_token.



5
6
7
# File 'lib/esi/client.rb', line 5

def access_token
  @access_token
end

#expires_atObject

Returns the value of attribute expires_at.



5
6
7
# File 'lib/esi/client.rb', line 5

def expires_at
  @expires_at
end

#loggerObject (readonly)

Returns the value of attribute logger.



6
7
8
# File 'lib/esi/client.rb', line 6

def logger
  @logger
end

#refresh_callbackObject

Returns the value of attribute refresh_callback.



5
6
7
# File 'lib/esi/client.rb', line 5

def refresh_callback
  @refresh_callback
end

#refresh_tokenObject

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(message)
  logger.debug message
end

#log(message) ⇒ Object



30
31
32
# File 'lib/esi/client.rb', line 30

def log(message)
  logger.info message
end