Class: EposNowClient::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/epos_now_client/configuration.rb

Constant Summary collapse

DEFAULT_BASE_URL =
'https://api.eposnowhq.com'
DEFAULT_TIMEOUT =
30
DEFAULT_OPEN_TIMEOUT =
10
DEFAULT_MAX_RETRIES =
3
DEFAULT_RETRY_DELAY =
1.0
DEFAULT_PER_PAGE =
200

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/epos_now_client/configuration.rb', line 18

def initialize
  @api_key = nil
  @api_secret = nil
  @base_url = DEFAULT_BASE_URL
  @timeout = DEFAULT_TIMEOUT
  @open_timeout = DEFAULT_OPEN_TIMEOUT
  @max_retries = DEFAULT_MAX_RETRIES
  @retry_delay = DEFAULT_RETRY_DELAY
  @per_page = DEFAULT_PER_PAGE
  @logger = nil
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def api_secret
  @api_secret
end

#base_urlObject

Returns the value of attribute base_url.



9
10
11
# File 'lib/epos_now_client/configuration.rb', line 9

def base_url
  @base_url
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def logger
  @logger
end

#max_retriesObject

Returns the value of attribute max_retries.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def max_retries
  @max_retries
end

#open_timeoutObject

Returns the value of attribute open_timeout.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def open_timeout
  @open_timeout
end

#per_pageObject

Returns the value of attribute per_page.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def per_page
  @per_page
end

#retry_delayObject

Returns the value of attribute retry_delay.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def retry_delay
  @retry_delay
end

#timeoutObject

Returns the value of attribute timeout.



7
8
9
# File 'lib/epos_now_client/configuration.rb', line 7

def timeout
  @timeout
end

Instance Method Details

#auth_tokenObject



30
31
32
33
# File 'lib/epos_now_client/configuration.rb', line 30

def auth_token
  validate!
  Base64.strict_encode64("#{api_key}:#{api_secret}")
end

#validate!Object



35
36
37
38
# File 'lib/epos_now_client/configuration.rb', line 35

def validate!
  raise AuthenticationError, 'API key is required' if api_key.nil? || api_key.empty?
  raise AuthenticationError, 'API secret is required' if api_secret.nil? || api_secret.empty?
end