loyalty-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +187 -0
- data/bin/console +15 -0
- data/lib/loyalty_ap_is/api_helper.rb +10 -0
- data/lib/loyalty_ap_is/apis/authorization_api.rb +116 -0
- data/lib/loyalty_ap_is/apis/balances_api.rb +96 -0
- data/lib/loyalty_ap_is/apis/base_api.rb +67 -0
- data/lib/loyalty_ap_is/apis/oauth_authorization_api.rb +44 -0
- data/lib/loyalty_ap_is/apis/offer_api.rb +164 -0
- data/lib/loyalty_ap_is/apis/profile_management_api.rb +44 -0
- data/lib/loyalty_ap_is/apis/redemption_api.rb +107 -0
- data/lib/loyalty_ap_is/apis/transaction_api.rb +143 -0
- data/lib/loyalty_ap_is/client.rb +137 -0
- data/lib/loyalty_ap_is/configuration.rb +238 -0
- data/lib/loyalty_ap_is/exceptions/api_exception.rb +21 -0
- data/lib/loyalty_ap_is/exceptions/common_error_exception.rb +98 -0
- data/lib/loyalty_ap_is/exceptions/consumers_balances400_error_exception.rb +57 -0
- data/lib/loyalty_ap_is/exceptions/consumers_balances401_error_exception.rb +57 -0
- data/lib/loyalty_ap_is/exceptions/consumers_balances404_error_exception.rb +57 -0
- data/lib/loyalty_ap_is/exceptions/consumers_balances422_error_exception.rb +57 -0
- data/lib/loyalty_ap_is/exceptions/error_response_exception.rb +57 -0
- data/lib/loyalty_ap_is/exceptions/json_api_error_exception.rb +60 -0
- data/lib/loyalty_ap_is/exceptions/oauth_provider_exception.rb +64 -0
- data/lib/loyalty_ap_is/exceptions/resource_not_found_error_exception.rb +57 -0
- data/lib/loyalty_ap_is/http/api_response.rb +19 -0
- data/lib/loyalty_ap_is/http/auth/client_authorization_token.rb +148 -0
- data/lib/loyalty_ap_is/http/auth/customer_header.rb +52 -0
- data/lib/loyalty_ap_is/http/auth/private_basic_token.rb +52 -0
- data/lib/loyalty_ap_is/http/auth/public_basic_token.rb +52 -0
- data/lib/loyalty_ap_is/http/auth/public_bearer_token.rb +53 -0
- data/lib/loyalty_ap_is/http/http_call_back.rb +10 -0
- data/lib/loyalty_ap_is/http/http_method_enum.rb +10 -0
- data/lib/loyalty_ap_is/http/http_request.rb +10 -0
- data/lib/loyalty_ap_is/http/http_response.rb +10 -0
- data/lib/loyalty_ap_is/http/proxy_settings.rb +22 -0
- data/lib/loyalty_ap_is/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/loyalty_ap_is/logging/sdk_logger.rb +17 -0
- data/lib/loyalty_ap_is/models/access_code_response.rb +87 -0
- data/lib/loyalty_ap_is/models/assign_offer_channel.rb +26 -0
- data/lib/loyalty_ap_is/models/auth_token_request.rb +75 -0
- data/lib/loyalty_ap_is/models/auth_token_response.rb +106 -0
- data/lib/loyalty_ap_is/models/bad_request_error.rb +63 -0
- data/lib/loyalty_ap_is/models/balance_amount.rb +84 -0
- data/lib/loyalty_ap_is/models/balance_amount_detail.rb +141 -0
- data/lib/loyalty_ap_is/models/balance_currency_amount.rb +93 -0
- data/lib/loyalty_ap_is/models/balance_currency_type.rb +60 -0
- data/lib/loyalty_ap_is/models/balance_state.rb +72 -0
- data/lib/loyalty_ap_is/models/base_model.rb +110 -0
- data/lib/loyalty_ap_is/models/client_auth_token_request.rb +78 -0
- data/lib/loyalty_ap_is/models/currency_data.rb +101 -0
- data/lib/loyalty_ap_is/models/customer_balances.rb +84 -0
- data/lib/loyalty_ap_is/models/error_base_container.rb +82 -0
- data/lib/loyalty_ap_is/models/error_info.rb +84 -0
- data/lib/loyalty_ap_is/models/error_item.rb +105 -0
- data/lib/loyalty_ap_is/models/error_presenter.rb +150 -0
- data/lib/loyalty_ap_is/models/error_source.rb +75 -0
- data/lib/loyalty_ap_is/models/ev_charging_details.rb +151 -0
- data/lib/loyalty_ap_is/models/exchange_access_code_request.rb +77 -0
- data/lib/loyalty_ap_is/models/fault.rb +85 -0
- data/lib/loyalty_ap_is/models/fault_detail.rb +76 -0
- data/lib/loyalty_ap_is/models/json_api_version.rb +75 -0
- data/lib/loyalty_ap_is/models/loyalty_card_info.rb +76 -0
- data/lib/loyalty_ap_is/models/m200_user_partners.rb +109 -0
- data/lib/loyalty_ap_is/models/method_not_allowed_error.rb +62 -0
- data/lib/loyalty_ap_is/models/not_found_error.rb +62 -0
- data/lib/loyalty_ap_is/models/not_found_error_response.rb +90 -0
- data/lib/loyalty_ap_is/models/oauth_provider_error.rb +62 -0
- data/lib/loyalty_ap_is/models/oauth_token.rb +96 -0
- data/lib/loyalty_ap_is/models/offer.rb +155 -0
- data/lib/loyalty_ap_is/models/offer_assignment.rb +172 -0
- data/lib/loyalty_ap_is/models/offer_base.rb +101 -0
- data/lib/loyalty_ap_is/models/offer_info.rb +156 -0
- data/lib/loyalty_ap_is/models/offer_language.rb +100 -0
- data/lib/loyalty_ap_is/models/points_to_cash.rb +99 -0
- data/lib/loyalty_ap_is/models/product_type.rb +53 -0
- data/lib/loyalty_ap_is/models/redeemed_item.rb +221 -0
- data/lib/loyalty_ap_is/models/redeemed_item_product.rb +131 -0
- data/lib/loyalty_ap_is/models/redemption_item.rb +109 -0
- data/lib/loyalty_ap_is/models/redemption_request.rb +107 -0
- data/lib/loyalty_ap_is/models/redemption_response.rb +118 -0
- data/lib/loyalty_ap_is/models/redemption_response_item.rb +111 -0
- data/lib/loyalty_ap_is/models/refresh_token_request.rb +75 -0
- data/lib/loyalty_ap_is/models/refresh_token_response.rb +93 -0
- data/lib/loyalty_ap_is/models/sale_item.rb +262 -0
- data/lib/loyalty_ap_is/models/sale_item_product.rb +135 -0
- data/lib/loyalty_ap_is/models/site_data.rb +121 -0
- data/lib/loyalty_ap_is/models/transaction.rb +351 -0
- data/lib/loyalty_ap_is/models/transaction_balance.rb +91 -0
- data/lib/loyalty_ap_is/models/transaction_balance_amount.rb +82 -0
- data/lib/loyalty_ap_is/models/transaction_balance_state.rb +64 -0
- data/lib/loyalty_ap_is/models/transaction_currency_type.rb +56 -0
- data/lib/loyalty_ap_is/models/transaction_detail_type.rb +53 -0
- data/lib/loyalty_ap_is/models/transaction_type_filter.rb +40 -0
- data/lib/loyalty_ap_is/models/transaction_voucher.rb +109 -0
- data/lib/loyalty_ap_is/models/transactions_response.rb +118 -0
- data/lib/loyalty_ap_is/models/unauthorized_error.rb +62 -0
- data/lib/loyalty_ap_is/models/unit_measure.rb +40 -0
- data/lib/loyalty_ap_is/models/unprocessable_entity_error_response.rb +90 -0
- data/lib/loyalty_ap_is/models/voucher_item.rb +99 -0
- data/lib/loyalty_ap_is/utilities/date_time_helper.rb +11 -0
- data/lib/loyalty_ap_is/utilities/file_wrapper.rb +28 -0
- data/lib/loyalty_ap_is.rb +128 -0
- metadata +189 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# JSON API Error class.
|
|
8
|
+
class JsonApiErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [JsonApiVersion]
|
|
14
|
+
attr_accessor :jsonapi
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for this method
|
|
17
|
+
# @return [Array[ErrorItem]]
|
|
18
|
+
attr_accessor :errors
|
|
19
|
+
|
|
20
|
+
# The constructor.
|
|
21
|
+
# @param [String] reason The reason for raising an exception.
|
|
22
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
23
|
+
def initialize(reason, response)
|
|
24
|
+
super(reason, response)
|
|
25
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
26
|
+
unbox(hash)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Populates this object by extracting properties from a hash.
|
|
30
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
31
|
+
# response body.
|
|
32
|
+
def unbox(hash)
|
|
33
|
+
return nil unless hash
|
|
34
|
+
|
|
35
|
+
@jsonapi = JsonApiVersion.from_hash(hash['jsonapi']) if hash['jsonapi']
|
|
36
|
+
# Parameter is an array, so we need to iterate through it
|
|
37
|
+
@errors = nil
|
|
38
|
+
unless hash['errors'].nil?
|
|
39
|
+
@errors = []
|
|
40
|
+
hash['errors'].each do |structure|
|
|
41
|
+
@errors << (ErrorItem.from_hash(structure) if structure)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@errors = SKIP unless hash.key?('errors')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Provides a human-readable string representation of the object.
|
|
49
|
+
def to_s
|
|
50
|
+
class_name = self.class.name.split('::').last
|
|
51
|
+
"<#{class_name} jsonapi: #{@jsonapi}, errors: #{@errors}>"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
55
|
+
def inspect
|
|
56
|
+
class_name = self.class.name.split('::').last
|
|
57
|
+
"<#{class_name} jsonapi: #{@jsonapi.inspect}, errors: #{@errors.inspect}>"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# OAuth 2 Authorization endpoint exception.
|
|
8
|
+
class OauthProviderException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Gets or sets error code.
|
|
13
|
+
# @return [OauthProviderError]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# Gets or sets human-readable text providing additional information on
|
|
17
|
+
# error.
|
|
18
|
+
# Used to assist the client developer in understanding the error that
|
|
19
|
+
# occurred.
|
|
20
|
+
# @return [String]
|
|
21
|
+
attr_accessor :error_description
|
|
22
|
+
|
|
23
|
+
# Gets or sets a URI identifying a human-readable web page with information
|
|
24
|
+
# about the error, used to provide the client developer with additional
|
|
25
|
+
# information about the error.
|
|
26
|
+
# @return [String]
|
|
27
|
+
attr_accessor :error_uri
|
|
28
|
+
|
|
29
|
+
# The constructor.
|
|
30
|
+
# @param [String] reason The reason for raising an exception.
|
|
31
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
32
|
+
def initialize(reason, response)
|
|
33
|
+
super(reason, response)
|
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
35
|
+
unbox(hash)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Populates this object by extracting properties from a hash.
|
|
39
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
40
|
+
# response body.
|
|
41
|
+
def unbox(hash)
|
|
42
|
+
return nil unless hash
|
|
43
|
+
|
|
44
|
+
@error = hash.key?('error') ? hash['error'] : nil
|
|
45
|
+
@error_description =
|
|
46
|
+
hash.key?('error_description') ? hash['error_description'] : SKIP
|
|
47
|
+
@error_uri = hash.key?('error_uri') ? hash['error_uri'] : SKIP
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Provides a human-readable string representation of the object.
|
|
51
|
+
def to_s
|
|
52
|
+
class_name = self.class.name.split('::').last
|
|
53
|
+
"<#{class_name} error: #{@error}, error_description: #{@error_description}, error_uri:"\
|
|
54
|
+
" #{@error_uri}>"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
58
|
+
def inspect
|
|
59
|
+
class_name = self.class.name.split('::').last
|
|
60
|
+
"<#{class_name} error: #{@error.inspect}, error_description: #{@error_description.inspect},"\
|
|
61
|
+
" error_uri: #{@error_uri.inspect}>"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Resource Not Found Error class.
|
|
8
|
+
class ResourceNotFoundErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# HTTP error status code
|
|
13
|
+
# @return [Float]
|
|
14
|
+
attr_accessor :error_code
|
|
15
|
+
|
|
16
|
+
# HTTP error status message
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :message
|
|
19
|
+
|
|
20
|
+
# HTTP error status message
|
|
21
|
+
# @return [ErrorInfo]
|
|
22
|
+
attr_accessor :error
|
|
23
|
+
|
|
24
|
+
# The constructor.
|
|
25
|
+
# @param [String] reason The reason for raising an exception.
|
|
26
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
27
|
+
def initialize(reason, response)
|
|
28
|
+
super(reason, response)
|
|
29
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
30
|
+
unbox(hash)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Populates this object by extracting properties from a hash.
|
|
34
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
35
|
+
# response body.
|
|
36
|
+
def unbox(hash)
|
|
37
|
+
return nil unless hash
|
|
38
|
+
|
|
39
|
+
@error_code = hash.key?('errorCode') ? hash['errorCode'] : nil
|
|
40
|
+
@message = hash.key?('message') ? hash['message'] : nil
|
|
41
|
+
@error = ErrorInfo.from_hash(hash['error']) if hash['error']
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Provides a human-readable string representation of the object.
|
|
45
|
+
def to_s
|
|
46
|
+
class_name = self.class.name.split('::').last
|
|
47
|
+
"<#{class_name} error_code: #{@error_code}, message: #{@message}, error: #{@error}>"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
51
|
+
def inspect
|
|
52
|
+
class_name = self.class.name.split('::').last
|
|
53
|
+
"<#{class_name} error_code: #{@error_code.inspect}, message: #{@message.inspect}, error:"\
|
|
54
|
+
" #{@error.inspect}>"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Http response received.
|
|
8
|
+
class ApiResponse < CoreLibrary::ApiResponse
|
|
9
|
+
# The constructor
|
|
10
|
+
# @param [HttpResponse] http_response The original, raw response from the api.
|
|
11
|
+
# @param [Object] data The data field specified for the response.
|
|
12
|
+
# @param [Array<String>] errors Any errors returned by the server.
|
|
13
|
+
def initialize(http_response,
|
|
14
|
+
data: nil,
|
|
15
|
+
errors: nil)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class ClientAuthorizationToken < CoreLibrary::HeaderAuth
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
# Display error message on occurrence of authentication failure.
|
|
11
|
+
# @returns [String] The oAuth error message.
|
|
12
|
+
def error_message
|
|
13
|
+
'ClientAuthorizationToken: OAuthToken is undefined or expired.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(client_authorization_token_credentials, config)
|
|
18
|
+
@_oauth_client_id = client_authorization_token_credentials.oauth_client_id unless
|
|
19
|
+
client_authorization_token_credentials.nil? || client_authorization_token_credentials.oauth_client_id.nil?
|
|
20
|
+
@_oauth_client_secret = client_authorization_token_credentials.oauth_client_secret unless
|
|
21
|
+
client_authorization_token_credentials.nil? || client_authorization_token_credentials.oauth_client_secret.nil?
|
|
22
|
+
@_oauth_token = client_authorization_token_credentials.oauth_token unless
|
|
23
|
+
client_authorization_token_credentials.nil? || client_authorization_token_credentials.oauth_token.nil?
|
|
24
|
+
@_oauth_clock_skew = client_authorization_token_credentials.oauth_clock_skew unless
|
|
25
|
+
client_authorization_token_credentials.nil? || client_authorization_token_credentials.oauth_clock_skew.nil?
|
|
26
|
+
@_oauth_token_provider = client_authorization_token_credentials.oauth_token_provider unless
|
|
27
|
+
client_authorization_token_credentials.nil? || client_authorization_token_credentials.oauth_token_provider.nil?
|
|
28
|
+
@_oauth_on_token_update = client_authorization_token_credentials.oauth_on_token_update unless
|
|
29
|
+
client_authorization_token_credentials.nil? || client_authorization_token_credentials.oauth_on_token_update.nil?
|
|
30
|
+
@_o_auth_api = OauthAuthorizationApi.new(config)
|
|
31
|
+
super({})
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Validates the oAuth token.
|
|
35
|
+
# @return [Boolean] true if the token is present and not expired.
|
|
36
|
+
def valid
|
|
37
|
+
@_oauth_token = get_token_from_provider
|
|
38
|
+
@_oauth_token.is_a?(OAuthToken) && !token_expired?(@_oauth_token)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
|
42
|
+
# @return [String] The value of the Authentication header.
|
|
43
|
+
def build_basic_auth_header
|
|
44
|
+
"Basic #{AuthHelper.get_base64_encoded_value(@_oauth_client_id, @_oauth_client_secret)}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Fetches the token.
|
|
48
|
+
# @param [Hash] additional_params Any additional form parameters.
|
|
49
|
+
# @return [OAuthToken] The oAuth token instance.
|
|
50
|
+
def fetch_token(additional_params: nil)
|
|
51
|
+
token = @_o_auth_api.request_token_client_authorization_token(
|
|
52
|
+
build_basic_auth_header,
|
|
53
|
+
_field_parameters: additional_params
|
|
54
|
+
).data
|
|
55
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
|
56
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
|
57
|
+
end
|
|
58
|
+
token
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Checks if OAuth token has expired.
|
|
62
|
+
# @param [OAuthToken] token The oAuth token instance.
|
|
63
|
+
# @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
|
|
64
|
+
def token_expired?(token)
|
|
65
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry, @_oauth_clock_skew)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def apply(http_request)
|
|
69
|
+
auth_params = { 'Authorization' => "Bearer #{@_oauth_token.access_token}" }
|
|
70
|
+
AuthHelper.apply(auth_params, http_request.method(:add_header))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
# This provides the OAuth Token from either the user configured callbacks or from default provider.
|
|
76
|
+
# @return [OAuthToken] The fetched oauth token.
|
|
77
|
+
def get_token_from_provider
|
|
78
|
+
return @_oauth_token if @_oauth_token && !token_expired?(@_oauth_token)
|
|
79
|
+
|
|
80
|
+
if @_o_auth_token_provider
|
|
81
|
+
o_auth_token = @_o_auth_token_provider.call(@_oauth_token, self)
|
|
82
|
+
@_o_auth_on_token_update&.call(o_auth_token)
|
|
83
|
+
return o_auth_token
|
|
84
|
+
end
|
|
85
|
+
begin
|
|
86
|
+
o_auth_token = fetch_token
|
|
87
|
+
@_o_auth_on_token_update&.call(o_auth_token)
|
|
88
|
+
o_auth_token
|
|
89
|
+
rescue ApiException
|
|
90
|
+
@_o_auth_token
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Data class for ClientAuthorizationTokenCredentials.
|
|
96
|
+
class ClientAuthorizationTokenCredentials
|
|
97
|
+
attr_reader :oauth_client_id, :oauth_client_secret, :oauth_token,
|
|
98
|
+
:oauth_token_provider, :oauth_on_token_update, :oauth_clock_skew
|
|
99
|
+
|
|
100
|
+
def initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil,
|
|
101
|
+
oauth_token_provider: nil, oauth_on_token_update: nil,
|
|
102
|
+
oauth_clock_skew: 0)
|
|
103
|
+
raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil?
|
|
104
|
+
raise ArgumentError, 'oauth_client_secret cannot be nil' if oauth_client_secret.nil?
|
|
105
|
+
|
|
106
|
+
@oauth_client_id = oauth_client_id
|
|
107
|
+
@oauth_client_secret = oauth_client_secret
|
|
108
|
+
@oauth_token = oauth_token
|
|
109
|
+
@oauth_token_provider = oauth_token_provider
|
|
110
|
+
@oauth_on_token_update = oauth_on_token_update
|
|
111
|
+
@oauth_clock_skew = oauth_clock_skew
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def self.from_env
|
|
115
|
+
oauth_client_id = ENV['CLIENT_AUTHORIZATION_TOKEN_OAUTH_CLIENT_ID']
|
|
116
|
+
oauth_client_secret = ENV['CLIENT_AUTHORIZATION_TOKEN_OAUTH_CLIENT_SECRET']
|
|
117
|
+
oauth_clock_skew = ENV['CLIENT_AUTHORIZATION_TOKEN_OAUTH_CLOCK_SKEW']
|
|
118
|
+
all_nil = [
|
|
119
|
+
oauth_client_id,
|
|
120
|
+
oauth_client_secret
|
|
121
|
+
].all?(&:nil?)
|
|
122
|
+
return nil if all_nil
|
|
123
|
+
|
|
124
|
+
new(oauth_client_id: oauth_client_id,
|
|
125
|
+
oauth_client_secret: oauth_client_secret,
|
|
126
|
+
oauth_clock_skew: oauth_clock_skew)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def clone_with(oauth_client_id: nil, oauth_client_secret: nil,
|
|
130
|
+
oauth_token: nil, oauth_token_provider: nil,
|
|
131
|
+
oauth_on_token_update: nil, oauth_clock_skew: nil)
|
|
132
|
+
oauth_client_id ||= self.oauth_client_id
|
|
133
|
+
oauth_client_secret ||= self.oauth_client_secret
|
|
134
|
+
oauth_token ||= self.oauth_token
|
|
135
|
+
oauth_token_provider ||= self.oauth_token_provider
|
|
136
|
+
oauth_on_token_update ||= self.oauth_on_token_update
|
|
137
|
+
oauth_clock_skew ||= self.oauth_clock_skew
|
|
138
|
+
|
|
139
|
+
ClientAuthorizationTokenCredentials.new(
|
|
140
|
+
oauth_client_id: oauth_client_id,
|
|
141
|
+
oauth_client_secret: oauth_client_secret, oauth_token: oauth_token,
|
|
142
|
+
oauth_token_provider: oauth_token_provider,
|
|
143
|
+
oauth_on_token_update: oauth_on_token_update,
|
|
144
|
+
oauth_clock_skew: oauth_clock_skew
|
|
145
|
+
)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Utility class for custom header authorization.
|
|
8
|
+
class CustomerHeader < CoreLibrary::HeaderAuth
|
|
9
|
+
# Display error message on occurrence of authentication failure.
|
|
10
|
+
# @returns [String] The oAuth error message.
|
|
11
|
+
def error_message
|
|
12
|
+
'CustomerHeader: authorization_token is undefined.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Initialization constructor.
|
|
16
|
+
def initialize(customer_header_credentials)
|
|
17
|
+
auth_params = {}
|
|
18
|
+
auth_params['Authorization-Token'] = customer_header_credentials.authorization_token unless
|
|
19
|
+
customer_header_credentials.nil? || customer_header_credentials.authorization_token.nil?
|
|
20
|
+
|
|
21
|
+
super auth_params
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Data class for CustomerHeaderCredentials.
|
|
26
|
+
# Data class for CustomerHeaderCredentials.
|
|
27
|
+
class CustomerHeaderCredentials
|
|
28
|
+
attr_reader :authorization_token
|
|
29
|
+
|
|
30
|
+
def initialize(authorization_token:)
|
|
31
|
+
raise ArgumentError, 'authorization_token cannot be nil' if authorization_token.nil?
|
|
32
|
+
|
|
33
|
+
@authorization_token = authorization_token
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_env
|
|
37
|
+
authorization_token = ENV['CUSTOMER_HEADER_AUTHORIZATION_TOKEN']
|
|
38
|
+
all_nil = [
|
|
39
|
+
authorization_token
|
|
40
|
+
].all?(&:nil?)
|
|
41
|
+
return nil if all_nil
|
|
42
|
+
|
|
43
|
+
new(authorization_token: authorization_token)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clone_with(authorization_token: nil)
|
|
47
|
+
authorization_token ||= self.authorization_token
|
|
48
|
+
|
|
49
|
+
CustomerHeaderCredentials.new(authorization_token: authorization_token)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Utility class for custom header authorization.
|
|
8
|
+
class PrivateBasicToken < CoreLibrary::HeaderAuth
|
|
9
|
+
# Display error message on occurrence of authentication failure.
|
|
10
|
+
# @returns [String] The oAuth error message.
|
|
11
|
+
def error_message
|
|
12
|
+
'PrivateBasicToken: public_basic_token is undefined.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Initialization constructor.
|
|
16
|
+
def initialize(private_basic_token_credentials)
|
|
17
|
+
auth_params = {}
|
|
18
|
+
auth_params['Public Basic Token'] = private_basic_token_credentials.public_basic_token unless
|
|
19
|
+
private_basic_token_credentials.nil? || private_basic_token_credentials.public_basic_token.nil?
|
|
20
|
+
|
|
21
|
+
super auth_params
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Data class for PrivateBasicTokenCredentials.
|
|
26
|
+
# Data class for PrivateBasicTokenCredentials.
|
|
27
|
+
class PrivateBasicTokenCredentials
|
|
28
|
+
attr_reader :public_basic_token
|
|
29
|
+
|
|
30
|
+
def initialize(public_basic_token:)
|
|
31
|
+
raise ArgumentError, 'public_basic_token cannot be nil' if public_basic_token.nil?
|
|
32
|
+
|
|
33
|
+
@public_basic_token = public_basic_token
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_env
|
|
37
|
+
public_basic_token = ENV['PRIVATE_BASIC_TOKEN_PUBLIC_BASIC_TOKEN']
|
|
38
|
+
all_nil = [
|
|
39
|
+
public_basic_token
|
|
40
|
+
].all?(&:nil?)
|
|
41
|
+
return nil if all_nil
|
|
42
|
+
|
|
43
|
+
new(public_basic_token: public_basic_token)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clone_with(public_basic_token: nil)
|
|
47
|
+
public_basic_token ||= self.public_basic_token
|
|
48
|
+
|
|
49
|
+
PrivateBasicTokenCredentials.new(public_basic_token: public_basic_token)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Utility class for custom header authorization.
|
|
8
|
+
class PublicBasicToken < CoreLibrary::HeaderAuth
|
|
9
|
+
# Display error message on occurrence of authentication failure.
|
|
10
|
+
# @returns [String] The oAuth error message.
|
|
11
|
+
def error_message
|
|
12
|
+
'PublicBasicToken: public_basic_token is undefined.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Initialization constructor.
|
|
16
|
+
def initialize(public_basic_token_credentials)
|
|
17
|
+
auth_params = {}
|
|
18
|
+
auth_params['Public Basic Token'] = public_basic_token_credentials.public_basic_token unless
|
|
19
|
+
public_basic_token_credentials.nil? || public_basic_token_credentials.public_basic_token.nil?
|
|
20
|
+
|
|
21
|
+
super auth_params
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Data class for PublicBasicTokenCredentials.
|
|
26
|
+
# Data class for PublicBasicTokenCredentials.
|
|
27
|
+
class PublicBasicTokenCredentials
|
|
28
|
+
attr_reader :public_basic_token
|
|
29
|
+
|
|
30
|
+
def initialize(public_basic_token:)
|
|
31
|
+
raise ArgumentError, 'public_basic_token cannot be nil' if public_basic_token.nil?
|
|
32
|
+
|
|
33
|
+
@public_basic_token = public_basic_token
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_env
|
|
37
|
+
public_basic_token = ENV['PUBLIC_BASIC_TOKEN_PUBLIC_BASIC_TOKEN']
|
|
38
|
+
all_nil = [
|
|
39
|
+
public_basic_token
|
|
40
|
+
].all?(&:nil?)
|
|
41
|
+
return nil if all_nil
|
|
42
|
+
|
|
43
|
+
new(public_basic_token: public_basic_token)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clone_with(public_basic_token: nil)
|
|
47
|
+
public_basic_token ||= self.public_basic_token
|
|
48
|
+
|
|
49
|
+
PublicBasicTokenCredentials.new(public_basic_token: public_basic_token)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class PublicBearerToken < CoreLibrary::HeaderAuth
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
# Display error message on occurrence of authentication failure.
|
|
11
|
+
# @returns [String] The oAuth error message.
|
|
12
|
+
def error_message
|
|
13
|
+
'PublicBearerToken: access_token is undefined.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(public_bearer_token_credentials)
|
|
18
|
+
auth_params = {}
|
|
19
|
+
@_access_token = public_bearer_token_credentials.access_token unless
|
|
20
|
+
public_bearer_token_credentials.nil? || public_bearer_token_credentials.access_token.nil?
|
|
21
|
+
auth_params[:Authorization] = "Bearer #{@_access_token}" unless @_access_token.nil?
|
|
22
|
+
|
|
23
|
+
super auth_params
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Data class for PublicBearerTokenCredentials.
|
|
28
|
+
class PublicBearerTokenCredentials
|
|
29
|
+
attr_reader :access_token
|
|
30
|
+
|
|
31
|
+
def initialize(access_token:)
|
|
32
|
+
raise ArgumentError, 'access_token cannot be nil' if access_token.nil?
|
|
33
|
+
|
|
34
|
+
@access_token = access_token
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.from_env
|
|
38
|
+
access_token = ENV['PUBLIC_BEARER_TOKEN_ACCESS_TOKEN']
|
|
39
|
+
all_nil = [
|
|
40
|
+
access_token
|
|
41
|
+
].all?(&:nil?)
|
|
42
|
+
return nil if all_nil
|
|
43
|
+
|
|
44
|
+
new(access_token: access_token)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def clone_with(access_token: nil)
|
|
48
|
+
access_token ||= self.access_token
|
|
49
|
+
|
|
50
|
+
PublicBearerTokenCredentials.new(access_token: access_token)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# loyalty_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module LoyaltyApIs
|
|
7
|
+
##
|
|
8
|
+
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
|
9
|
+
# including optional basic authentication.
|
|
10
|
+
#
|
|
11
|
+
class ProxySettings < CoreLibrary::ProxySettings
|
|
12
|
+
def self.from_env
|
|
13
|
+
address = ENV['PROXY_ADDRESS']
|
|
14
|
+
port = ENV['PROXY_PORT']
|
|
15
|
+
username = ENV['PROXY_USERNAME']
|
|
16
|
+
password = ENV['PROXY_PASSWORD']
|
|
17
|
+
return nil if address.nil? || address.strip.empty?
|
|
18
|
+
|
|
19
|
+
new(address: address, port: port, username: username, password: password)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|