Class: MastercardCoreSdk::Client::ApiClient
- Inherits:
-
Object
- Object
- MastercardCoreSdk::Client::ApiClient
- Defined in:
- lib/mastercard_core_sdk/client/api_client.rb
Constant Summary collapse
- @@logger =
Logging.logger[self]
Instance Attribute Summary collapse
-
#api_config ⇒ Object
The ApiConfig object holding environment configurations.
-
#api_tracker ⇒ Hash
Defines the api_tracker to be added in request header having parameters.
-
#config ⇒ Object
The Configuration object holding settings to be used in the API client.
-
#default_headers ⇒ Hash
Defines the headers to be used in HTTP requests of all API calls by default.
-
#error_handler ⇒ Object
Defines the object that would handle error for all the requests.
-
#mastercard_authenticator ⇒ Object
Returns the value of attribute mastercard_authenticator.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(path, service_request, http_method, return_type) ⇒ String
Execute Typhoeus request.
-
#initialize(api_config = nil) ⇒ ApiClient
constructor
Initializing Api Client with user-agent, configuration and default headers.
Constructor Details
#initialize(api_config = nil) ⇒ ApiClient
Initializing Api Client with user-agent, configuration and default headers. Validating MasterCardApiConfiguration and calling interceptor for Authorization signature and logger.
45 46 47 48 49 50 51 52 53 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 45 def initialize(api_config = nil) @config = Configuration.default @user_agent = @config.user_agent @default_headers = @config.default_headers @mastercard_authenticator = MastercardAuthenticator.new @api_config = api_config || MasterCardApiConfiguration.api_config MasterCardApiConfiguration.validate_config(@api_config) end |
Instance Attribute Details
#api_config ⇒ Object
The ApiConfig object holding environment configurations.
26 27 28 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 26 def api_config @api_config end |
#api_tracker ⇒ Hash
Defines the api_tracker to be added in request header having parameters.
36 37 38 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 36 def api_tracker @api_tracker end |
#config ⇒ Object
The Configuration object holding settings to be used in the API client.
23 24 25 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 23 def config @config end |
#default_headers ⇒ Hash
Defines the headers to be used in HTTP requests of all API calls by default.
31 32 33 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 31 def default_headers @default_headers end |
#error_handler ⇒ Object
Defines the object that would handle error for all the requests.
39 40 41 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 39 def error_handler @error_handler end |
#mastercard_authenticator ⇒ Object
Returns the value of attribute mastercard_authenticator.
41 42 43 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 41 def mastercard_authenticator @mastercard_authenticator end |
Class Method Details
Instance Method Details
#call(path, service_request, http_method, return_type) ⇒ String
Execute Typhoeus request.
65 66 67 68 69 70 |
# File 'lib/mastercard_core_sdk/client/api_client.rb', line 65 def call(path, service_request, http_method, return_type) request = build_request(http_method, path, service_request, @api_config) response_body, response_code, response_headers = call_api(request, return_type) return response_body end |