Class: ShellSmartPayApi::Configuration
- Inherits:
-
CoreLibrary::HttpClientConfiguration
- Object
- CoreLibrary::HttpClientConfiguration
- ShellSmartPayApi::Configuration
- Defined in:
- lib/shell_smart_pay_api/configuration.rb
Overview
All configuration including auth info and base URI for the API access are configured in this class.
Constant Summary collapse
- ENVIRONMENTS =
All the environments the SDK can run in.
{ Environment::TEST => { Server::SHELL => 'https://api-test.shell.com/ShellDigitalCommerceServices/Payments/B2B/Partner' }, Environment::PRODUCTION => { Server::SHELL => 'https://api.shell.com/ShellDigitalCommerceServices/Payments/B2B/Partner' } }.freeze
Class Attribute Summary collapse
-
.environments ⇒ Object
readonly
Returns the value of attribute environments.
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
The attribute readers for properties.
-
#mpp_token_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#o_auth_token_post_credentials ⇒ Object
readonly
The attribute readers for properties.
Instance Method Summary collapse
- #clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, mpp_token_credentials: nil, o_auth_token_post_credentials: nil) ⇒ Object
-
#get_base_uri(server = Server::SHELL) ⇒ String
Generates the appropriate base URI for the environment and the server.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::TEST, mpp_token_credentials: nil, o_auth_token_post_credentials: nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::TEST, mpp_token_credentials: nil, o_auth_token_post_credentials: nil) ⇒ Configuration
Returns a new instance of Configuration.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 33 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: i[get put], http_callback: nil, environment: Environment::TEST, mpp_token_credentials: nil, o_auth_token_post_credentials: nil ) super connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback # Current API environment @environment = String(environment) # The object holding Custom Header Signature credentials @mpp_token_credentials = mpp_token_credentials # The object holding Custom Header Signature credentials @o_auth_token_post_credentials = o_auth_token_post_credentials # The Http Client to use for making requests. set_http_client CoreLibrary::FaradayClient.new(self) end |
Class Attribute Details
.environments ⇒ Object (readonly)
Returns the value of attribute environments.
30 31 32 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 30 def environments @environments end |
Instance Attribute Details
#environment ⇒ Object (readonly)
The attribute readers for properties.
26 27 28 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 26 def environment @environment end |
#mpp_token_credentials ⇒ Object (readonly)
The attribute readers for properties.
26 27 28 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 26 def mpp_token_credentials @mpp_token_credentials end |
#o_auth_token_post_credentials ⇒ Object (readonly)
The attribute readers for properties.
26 27 28 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 26 def o_auth_token_post_credentials @o_auth_token_post_credentials end |
Instance Method Details
#clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, mpp_token_credentials: nil, o_auth_token_post_credentials: nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 60 def clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, mpp_token_credentials: nil, o_auth_token_post_credentials: nil) connection ||= self.connection adapter ||= self.adapter timeout ||= self.timeout max_retries ||= self.max_retries retry_interval ||= self.retry_interval backoff_factor ||= self.backoff_factor retry_statuses ||= self.retry_statuses retry_methods ||= self.retry_methods http_callback ||= self.http_callback environment ||= self.environment mpp_token_credentials ||= self.mpp_token_credentials o_auth_token_post_credentials ||= self.o_auth_token_post_credentials Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, environment: environment, mpp_token_credentials: mpp_token_credentials, o_auth_token_post_credentials: o_auth_token_post_credentials ) end |
#get_base_uri(server = Server::SHELL) ⇒ String
Generates the appropriate base URI for the environment and the server. required.
103 104 105 |
# File 'lib/shell_smart_pay_api/configuration.rb', line 103 def get_base_uri(server = Server::SHELL) ENVIRONMENTS[environment][server].clone end |