Class: Revolut::Configuration
- Inherits:
-
Object
- Object
- Revolut::Configuration
- Defined in:
- lib/revolut/configuration.rb
Overview
A class responsible for all configurations.
Constant Summary collapse
- PRODUCTION_API_ENDPOINT =
'https://b2b.revolut.com/api/1.0'
- SANDBOX_API_ENDPOINT =
'https://sandbox-b2b.revolut.com/api/1.0'
- AVAILABLE_ENVIRONMENTS =
%i[production sandbox].freeze
- DEFAULT_ENVIRONMENT =
:production
- USER_AGENT =
"Revolut Ruby v#{Revolut::VERSION}"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#url ⇒ String
Takes url provided from configuration or uses default one.
-
#user_agent ⇒ String
Takes user agent from configuration or uses default one.
Instance Method Summary collapse
-
#environment ⇒ Symbol
Takes environment from configuration or uses default one.
-
#environment=(environment) ⇒ Symbol
Sets environment which will be used for url.
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/revolut/configuration.rb', line 12 def api_key @api_key end |
#url ⇒ String
Takes url provided from configuration or uses default one.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/revolut/configuration.rb', line 18 def url return @url if @url case environment when :production PRODUCTION_API_ENDPOINT when :sandbox SANDBOX_API_ENDPOINT end end |
#user_agent ⇒ String
Takes user agent from configuration or uses default one.
32 33 34 |
# File 'lib/revolut/configuration.rb', line 32 def user_agent @user_agent || USER_AGENT end |
Instance Method Details
#environment ⇒ Symbol
Takes environment from configuration or uses default one. It will be used to set url automatically.
40 41 42 |
# File 'lib/revolut/configuration.rb', line 40 def environment @environment || DEFAULT_ENVIRONMENT end |
#environment=(environment) ⇒ Symbol
Sets environment which will be used for url.
47 48 49 50 51 52 53 |
# File 'lib/revolut/configuration.rb', line 47 def environment=(environment) env_sym = environment.is_a?(String) ? environment.to_sym : environment raise Revolut::Error, 'Invalid environment provided.' unless AVAILABLE_ENVIRONMENTS.include?(env_sym) @environment = env_sym end |