Class: LoyaltyApIs::Client
- Inherits:
-
Object
- Object
- LoyaltyApIs::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/loyalty_ap_is/client.rb
Overview
loyalty_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
-
#authorization ⇒ AuthorizationApi
Access to authorization controller.
-
#balances ⇒ BalancesApi
Access to balances controller.
-
#client_authorization_token ⇒ Object
Returns the configured authentication client-authorization-token instance.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, 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, logging_configuration: nil, environment: Environment::SIT, public_bearer_token_credentials: nil, public_basic_token_credentials: nil, private_basic_token_credentials: nil, client_authorization_token_credentials: nil, customer_header_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.
-
#oauth_authorization ⇒ OauthAuthorizationApi
Access to oauth_authorization controller.
-
#offer ⇒ OfferApi
Access to offer controller.
-
#profile_management ⇒ ProfileManagementApi
Access to profile_management controller.
-
#redemption ⇒ RedemptionApi
Access to redemption controller.
-
#transaction ⇒ TransactionApi
Access to transaction controller.
- #user_agent_detail ⇒ Object
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, 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, logging_configuration: nil, environment: Environment::SIT, public_bearer_token_credentials: nil, public_basic_token_credentials: nil, private_basic_token_credentials: nil, client_authorization_token_credentials: nil, customer_header_credentials: nil, config: nil) ⇒ Client
Returns a new instance of Client.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/loyalty_ap_is/client.rb', line 63 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 30, 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, logging_configuration: nil, environment: Environment::SIT, public_bearer_token_credentials: nil, public_basic_token_credentials: nil, private_basic_token_credentials: nil, client_authorization_token_credentials: nil, customer_header_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, logging_configuration: logging_configuration, environment: environment, public_bearer_token_credentials: public_bearer_token_credentials, public_basic_token_credentials: public_basic_token_credentials, private_basic_token_credentials: private_basic_token_credentials, client_authorization_token_credentials: , customer_header_credentials: customer_header_credentials ) else config end user_agent_params = BaseApi.user_agent_parameters @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseApi::GLOBAL_ERRORS) .user_agent(BaseApi.user_agent, agent_parameters: user_agent_params) 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/loyalty_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/loyalty_ap_is/client.rb', line 10 def config @config end |
Class Method Details
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
131 132 133 134 135 |
# File 'lib/loyalty_ap_is/client.rb', line 131 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
#authorization ⇒ AuthorizationApi
Access to authorization controller.
23 24 25 |
# File 'lib/loyalty_ap_is/client.rb', line 23 def @authorization ||= AuthorizationApi.new @global_configuration end |
#balances ⇒ BalancesApi
Access to balances controller.
41 42 43 |
# File 'lib/loyalty_ap_is/client.rb', line 41 def balances @balances ||= BalancesApi.new @global_configuration end |
#client_authorization_token ⇒ Object
Returns the configured authentication client-authorization-token instance.
17 18 19 |
# File 'lib/loyalty_ap_is/client.rb', line 17 def @auth_managers['client-authorization-token'] end |
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/loyalty_ap_is/client.rb', line 107 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[PublicBearerToken PublicBasicToken PrivateBasicToken client-authorization-token customerHeader].each do |auth| @auth_managers[auth] = nil end @auth_managers['PublicBearerToken'] = PublicBearerToken.new( http_client_config.public_bearer_token_credentials ) @auth_managers['PublicBasicToken'] = PublicBasicToken.new( http_client_config.public_basic_token_credentials ) @auth_managers['PrivateBasicToken'] = PrivateBasicToken.new( http_client_config.private_basic_token_credentials ) @auth_managers['client-authorization-token'] = ClientAuthorizationToken.new( http_client_config., global_config ) @auth_managers['customerHeader'] = CustomerHeader.new( http_client_config.customer_header_credentials ) end |
#oauth_authorization ⇒ OauthAuthorizationApi
Access to oauth_authorization controller.
59 60 61 |
# File 'lib/loyalty_ap_is/client.rb', line 59 def @oauth_authorization ||= OauthAuthorizationApi.new @global_configuration end |
#offer ⇒ OfferApi
Access to offer controller.
35 36 37 |
# File 'lib/loyalty_ap_is/client.rb', line 35 def offer @offer ||= OfferApi.new @global_configuration end |
#profile_management ⇒ ProfileManagementApi
Access to profile_management controller.
29 30 31 |
# File 'lib/loyalty_ap_is/client.rb', line 29 def profile_management @profile_management ||= ProfileManagementApi.new @global_configuration end |
#redemption ⇒ RedemptionApi
Access to redemption controller.
47 48 49 |
# File 'lib/loyalty_ap_is/client.rb', line 47 def redemption @redemption ||= RedemptionApi.new @global_configuration end |
#transaction ⇒ TransactionApi
Access to transaction controller.
53 54 55 |
# File 'lib/loyalty_ap_is/client.rb', line 53 def transaction @transaction ||= TransactionApi.new @global_configuration end |
#user_agent_detail ⇒ Object
12 13 14 |
# File 'lib/loyalty_ap_is/client.rb', line 12 def user_agent_detail config.user_agent_detail end |