Class: ShellDataReportingApIs::Client
- Inherits:
-
Object
- Object
- ShellDataReportingApIs::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/shell_data_reporting_ap_is/client.rb
Overview
shell_data_reporting_ap_is client class.
Instance Attribute Summary collapse
-
#auth_managers ⇒ Object
readonly
Returns the value of attribute auth_managers.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
Instance Method Summary collapse
-
#bearer_token ⇒ Object
Returns the configured authentication BearerToken instance.
-
#customer ⇒ CustomerController
Access to customer controller.
-
#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, proxy_settings: nil, environment: Environment::SIT, o_auth_client_id: nil, o_auth_client_secret: nil, o_auth_token: nil, client_credentials_auth_credentials: nil, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
-
#invoice ⇒ InvoiceController
Access to invoice controller.
-
#o_auth_authorization ⇒ OAuthAuthorizationController
Access to o_auth_authorization controller.
-
#transaction ⇒ TransactionController
Access to transaction controller.
- #user_agent_detail ⇒ Object
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, proxy_settings: nil, environment: Environment::SIT, o_auth_client_id: nil, o_auth_client_secret: nil, o_auth_token: nil, client_credentials_auth_credentials: nil, config: nil) ⇒ Client
Returns a new instance of Client.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 45 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, proxy_settings: nil, environment: Environment::SIT, o_auth_client_id: nil, o_auth_client_secret: nil, o_auth_token: nil, client_credentials_auth_credentials: nil, config: nil ) @config = if config.nil? 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, proxy_settings: proxy_settings, environment: environment, o_auth_client_id: o_auth_client_id, o_auth_client_secret: o_auth_client_secret, o_auth_token: o_auth_token, client_credentials_auth_credentials: client_credentials_auth_credentials ) else config end @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseController::GLOBAL_ERRORS) .user_agent(BaseController.user_agent) initialize_auth_managers(@global_configuration) @global_configuration = @global_configuration.auth_managers(@auth_managers) end |
Instance Attribute Details
#auth_managers ⇒ Object (readonly)
Returns the value of attribute auth_managers.
10 11 12 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 10 def auth_managers @auth_managers end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 10 def config @config end |
Class Method Details
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
92 93 94 95 96 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 92 def self.from_env(**overrides) default_config = Configuration.build_default_config_from_env new_config = default_config.clone_with(**overrides) new(config: new_config) end |
Instance Method Details
#bearer_token ⇒ Object
Returns the configured authentication BearerToken instance.
17 18 19 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 17 def bearer_token @auth_managers['BearerToken'] end |
#customer ⇒ CustomerController
Access to customer controller.
23 24 25 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 23 def customer @customer ||= CustomerController.new @global_configuration end |
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
82 83 84 85 86 87 88 89 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 82 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[BearerToken].each { |auth| @auth_managers[auth] = nil } @auth_managers['BearerToken'] = OAuth2.new( http_client_config.client_credentials_auth_credentials, global_config ) end |
#invoice ⇒ InvoiceController
Access to invoice controller.
35 36 37 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 35 def invoice @invoice ||= InvoiceController.new @global_configuration end |
#o_auth_authorization ⇒ OAuthAuthorizationController
Access to o_auth_authorization controller.
41 42 43 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 41 def @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration end |
#transaction ⇒ TransactionController
Access to transaction controller.
29 30 31 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 29 def transaction @transaction ||= TransactionController.new @global_configuration end |
#user_agent_detail ⇒ Object
12 13 14 |
# File 'lib/shell_data_reporting_ap_is/client.rb', line 12 def user_agent_detail config.user_agent_detail end |