Class: StocksExchangeApiClient::Configuration

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

Constant Summary collapse

URL_V2 =
'https://app.stocks.exchange/api2'.freeze
URL_V3 =
'https://api3.stex.com'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

def initialize
  @use_version ||= 2
  @url ||= URL_V2
end

Instance Attribute Details

#optionObject

Returns the value of attribute option.



5
6
7
# File 'lib/stocks_exchange_api_client/configuration.rb', line 5

def option
  @option
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/stocks_exchange_api_client/configuration.rb', line 5

def url
  @url
end

#use_versionObject

Returns the value of attribute use_version.



5
6
7
# File 'lib/stocks_exchange_api_client/configuration.rb', line 5

def use_version
  @use_version
end

Instance Method Details

#validate!Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stocks_exchange_api_client/configuration.rb', line 12

def validate!
  if use_version == 2
    unless option[:api_key] && option[:api_secret]
      raise Errors::ConfigurationError
    end
  end
  if use_version == 3
    unless option[:client_id] && option[:client_secret] && option[:token_object][:access_token] && option[:token_object][:refresh_token]
      raise Errors::ConfigurationError
    end
  end
end