Class: ShellSmartPayApi::Client

Inherits:
Object
  • Object
show all
Includes:
CoreLibrary
Defined in:
lib/shell_smart_pay_api/client.rb

Overview

shell_smart_pay_api client class.

Instance Attribute Summary collapse

Instance Method Summary collapse

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, config: nil) ⇒ Client

Returns a new instance of Client.



42
43
44
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
# File 'lib/shell_smart_pay_api/client.rb', line 42

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, 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,
                environment: environment,
                mpp_token_credentials: mpp_token_credentials,
                o_auth_token_post_credentials: o_auth_token_post_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_managersObject (readonly)

Returns the value of attribute auth_managers.



10
11
12
# File 'lib/shell_smart_pay_api/client.rb', line 10

def auth_managers
  @auth_managers
end

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/shell_smart_pay_api/client.rb', line 10

def config
  @config
end

Instance Method Details

#digital_payment_enablementDigitalPaymentEnablementController

Access to digital_payment_enablement controller.

Returns:



20
21
22
# File 'lib/shell_smart_pay_api/client.rb', line 20

def digital_payment_enablement
  @digital_payment_enablement ||= DigitalPaymentEnablementController.new @global_configuration
end

#fuelingFuelingController

Access to fueling controller.

Returns:



32
33
34
# File 'lib/shell_smart_pay_api/client.rb', line 32

def fueling
  @fueling ||= FuelingController.new @global_configuration
end

#initialize_auth_managers(global_config) ⇒ Object

Initializes the auth managers hash used for authenticating API calls.

Parameters:

  • global_config (GlobalConfiguration)

    The global configuration of the SDK)



76
77
78
79
80
81
82
83
84
# File 'lib/shell_smart_pay_api/client.rb', line 76

def initialize_auth_managers(global_config)
  @auth_managers = {}
  http_client_config = global_config.client_configuration
  %w[MppToken oAuthTokenPost].each { |auth| @auth_managers[auth] = nil }
  @auth_managers['MppToken'] = MppToken.new(http_client_config.mpp_token_credentials)
  @auth_managers['oAuthTokenPost'] = OAuthTokenPost.new(
    http_client_config.o_auth_token_post_credentials
  )
end

#partner_notificationPartnerNotificationController

Access to partner_notification controller.

Returns:



38
39
40
# File 'lib/shell_smart_pay_api/client.rb', line 38

def partner_notification
  @partner_notification ||= PartnerNotificationController.new @global_configuration
end

#shell_api_platform_security_authenticationShellAPIPlatformSecurityAuthenticationController

Access to shell_api_platform_security_authentication controller.

Returns:



14
15
16
# File 'lib/shell_smart_pay_api/client.rb', line 14

def shell_api_platform_security_authentication
  @shell_api_platform_security_authentication ||= ShellAPIPlatformSecurityAuthenticationController.new @global_configuration
end

#station_locatorStationLocatorController

Access to station_locator controller.

Returns:



26
27
28
# File 'lib/shell_smart_pay_api/client.rb', line 26

def station_locator
  @station_locator ||= StationLocatorController.new @global_configuration
end