Class: StocksExchangeApiClient::Configuration
- Inherits:
-
Object
- Object
- StocksExchangeApiClient::Configuration
- Defined in:
- lib/stocks_exchange_api_client/configuration.rb
Constant Summary collapse
- URL_V3 =
'https://api3.stex.com'.freeze
Instance Attribute Summary collapse
-
#option ⇒ Object
Returns the value of attribute option.
-
#s2s ⇒ Object
Returns the value of attribute s2s.
-
#url ⇒ Object
Returns the value of attribute url.
-
#use_version ⇒ Object
Returns the value of attribute use_version.
Instance Method Summary collapse
-
#initialize(url: URL_V3, option: {}, use_version: 3, s2s: false) ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize(url: URL_V3, option: {}, use_version: 3, s2s: false) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 |
# File 'lib/stocks_exchange_api_client/configuration.rb', line 8 def initialize(url: URL_V3, option: {}, use_version: 3, s2s: false) @url||= url @option||= option @use_version||= use_version @s2s||= s2s end |
Instance Attribute Details
#option ⇒ Object
Returns the value of attribute option.
6 7 8 |
# File 'lib/stocks_exchange_api_client/configuration.rb', line 6 def option @option end |
#s2s ⇒ Object
Returns the value of attribute s2s.
6 7 8 |
# File 'lib/stocks_exchange_api_client/configuration.rb', line 6 def s2s @s2s end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/stocks_exchange_api_client/configuration.rb', line 6 def url @url end |
#use_version ⇒ Object
Returns the value of attribute use_version.
6 7 8 |
# File 'lib/stocks_exchange_api_client/configuration.rb', line 6 def use_version @use_version end |
Instance Method Details
#validate! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stocks_exchange_api_client/configuration.rb', line 15 def validate! if use_version == 2 raise 'Disabled supporting version 2 API' end if use_version == 3 && !s2s unless option[:client_id] && option[:client_secret] && option[:token_object][:access_token] && option[:token_object][:refresh_token] raise Errors::ConfigurationError end end if use_version == 3 && s2s unless option[:token_object][:access_token] raise Errors::ConfigurationError end end end |