paze-apimatic-sdk 1.0.0
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 +147 -0
- data/bin/console +15 -0
- data/lib/paze_checkout_api/api_helper.rb +10 -0
- data/lib/paze_checkout_api/client.rb +97 -0
- data/lib/paze_checkout_api/configuration.rb +221 -0
- data/lib/paze_checkout_api/controllers/base_controller.rb +60 -0
- data/lib/paze_checkout_api/controllers/checkout_session_controller.rb +108 -0
- data/lib/paze_checkout_api/controllers/identity_controller.rb +43 -0
- data/lib/paze_checkout_api/controllers/merchant_onboarding_controller.rb +39 -0
- data/lib/paze_checkout_api/controllers/o_auth_authorization_controller.rb +42 -0
- data/lib/paze_checkout_api/exceptions/api_error_response_exception.rb +67 -0
- data/lib/paze_checkout_api/exceptions/api_exception.rb +21 -0
- data/lib/paze_checkout_api/exceptions/base_response_exception.rb +75 -0
- data/lib/paze_checkout_api/exceptions/o_auth_provider_exception.rb +64 -0
- data/lib/paze_checkout_api/exceptions/simple_error_exception.rb +46 -0
- data/lib/paze_checkout_api/http/auth/o_auth2.rb +149 -0
- data/lib/paze_checkout_api/http/http_call_back.rb +10 -0
- data/lib/paze_checkout_api/http/http_method_enum.rb +10 -0
- data/lib/paze_checkout_api/http/http_request.rb +10 -0
- data/lib/paze_checkout_api/http/http_response.rb +10 -0
- data/lib/paze_checkout_api/http/proxy_settings.rb +22 -0
- data/lib/paze_checkout_api/models/api_response_metadata.rb +87 -0
- data/lib/paze_checkout_api/models/base_model.rb +110 -0
- data/lib/paze_checkout_api/models/billing_preference_enum.rb +36 -0
- data/lib/paze_checkout_api/models/checkout_session_complete_request.rb +70 -0
- data/lib/paze_checkout_api/models/checkout_session_complete_response.rb +97 -0
- data/lib/paze_checkout_api/models/checkout_session_create_request.rb +70 -0
- data/lib/paze_checkout_api/models/checkout_session_create_response.rb +97 -0
- data/lib/paze_checkout_api/models/checkout_session_review_request.rb +70 -0
- data/lib/paze_checkout_api/models/checkout_session_review_response.rb +97 -0
- data/lib/paze_checkout_api/models/client.rb +80 -0
- data/lib/paze_checkout_api/models/client_assertion_type_enum.rb +27 -0
- data/lib/paze_checkout_api/models/complete_session_data.rb +131 -0
- data/lib/paze_checkout_api/models/complete_session_response_data.rb +71 -0
- data/lib/paze_checkout_api/models/consumer.rb +100 -0
- data/lib/paze_checkout_api/models/create_session_data.rb +134 -0
- data/lib/paze_checkout_api/models/create_session_response_data.rb +71 -0
- data/lib/paze_checkout_api/models/data.rb +62 -0
- data/lib/paze_checkout_api/models/ecommerce_data.rb +109 -0
- data/lib/paze_checkout_api/models/enhanced_transaction_data.rb +71 -0
- data/lib/paze_checkout_api/models/error_detail.rb +81 -0
- data/lib/paze_checkout_api/models/error_message.rb +88 -0
- data/lib/paze_checkout_api/models/grant_type_enum.rb +26 -0
- data/lib/paze_checkout_api/models/intent_enum.rb +40 -0
- data/lib/paze_checkout_api/models/links.rb +74 -0
- data/lib/paze_checkout_api/models/masked_card.rb +107 -0
- data/lib/paze_checkout_api/models/merchant_address.rb +97 -0
- data/lib/paze_checkout_api/models/merchant_onboard_data.rb +115 -0
- data/lib/paze_checkout_api/models/merchant_onboard_request.rb +70 -0
- data/lib/paze_checkout_api/models/merchant_profile.rb +83 -0
- data/lib/paze_checkout_api/models/merchant_response.rb +122 -0
- data/lib/paze_checkout_api/models/o_auth_provider_error_enum.rb +62 -0
- data/lib/paze_checkout_api/models/o_auth_token.rb +96 -0
- data/lib/paze_checkout_api/models/o_auth_token_request.rb +75 -0
- data/lib/paze_checkout_api/models/o_auth_token_response.rb +78 -0
- data/lib/paze_checkout_api/models/onboard_merchant_key.rb +112 -0
- data/lib/paze_checkout_api/models/payload_type_indicator_enum.rb +36 -0
- data/lib/paze_checkout_api/models/payment_card_brand_enum.rb +40 -0
- data/lib/paze_checkout_api/models/payment_card_type_enum.rb +36 -0
- data/lib/paze_checkout_api/models/phone.rb +72 -0
- data/lib/paze_checkout_api/models/processing_network_enum.rb +40 -0
- data/lib/paze_checkout_api/models/review_session_data.rb +68 -0
- data/lib/paze_checkout_api/models/review_session_response_data.rb +100 -0
- data/lib/paze_checkout_api/models/shipping_address.rb +101 -0
- data/lib/paze_checkout_api/models/transaction_options.rb +87 -0
- data/lib/paze_checkout_api/models/transaction_type_enum.rb +36 -0
- data/lib/paze_checkout_api/models/transaction_value.rb +72 -0
- data/lib/paze_checkout_api/models/travel_data.rb +110 -0
- data/lib/paze_checkout_api/utilities/date_time_helper.rb +11 -0
- data/lib/paze_checkout_api/utilities/file_wrapper.rb +28 -0
- data/lib/paze_checkout_api.rb +93 -0
- metadata +157 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# CheckoutSessionController
|
|
8
|
+
class CheckoutSessionController < BaseController
|
|
9
|
+
# Creates the checkout session required to launch the Paze checkout UX
|
|
10
|
+
# inside a merchant mobile application.
|
|
11
|
+
# @param [CheckoutSessionCreateRequest] body Required parameter: TODO: type
|
|
12
|
+
# description here
|
|
13
|
+
# @return [CheckoutSessionCreateResponse] Response from the API call.
|
|
14
|
+
def create_checkout_session(body)
|
|
15
|
+
@api_call
|
|
16
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
17
|
+
'/v1/checkout/sessions/create',
|
|
18
|
+
Server::DEFAULT)
|
|
19
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
20
|
+
.body_param(new_parameter(body))
|
|
21
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
22
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
23
|
+
.auth(Single.new('OAuth2')))
|
|
24
|
+
.response(new_response_handler
|
|
25
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
26
|
+
.deserialize_into(CheckoutSessionCreateResponse.method(:from_hash))
|
|
27
|
+
.local_error('400',
|
|
28
|
+
'Invalid request',
|
|
29
|
+
ApiErrorResponseException)
|
|
30
|
+
.local_error('401',
|
|
31
|
+
'Unauthorized',
|
|
32
|
+
SimpleErrorException)
|
|
33
|
+
.local_error('422',
|
|
34
|
+
'Unprocessable entity',
|
|
35
|
+
ApiErrorResponseException)
|
|
36
|
+
.local_error('500',
|
|
37
|
+
'Server error',
|
|
38
|
+
ApiErrorResponseException))
|
|
39
|
+
.execute
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Retrieves information about the card and consumer selected in the Paze
|
|
43
|
+
# checkout experience.
|
|
44
|
+
# @param [CheckoutSessionReviewRequest] body Required parameter: TODO: type
|
|
45
|
+
# description here
|
|
46
|
+
# @return [CheckoutSessionReviewResponse] Response from the API call.
|
|
47
|
+
def review_checkout_session(body)
|
|
48
|
+
@api_call
|
|
49
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
50
|
+
'/v1/checkout/sessions/review',
|
|
51
|
+
Server::DEFAULT)
|
|
52
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
53
|
+
.body_param(new_parameter(body))
|
|
54
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
55
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
56
|
+
.auth(Single.new('OAuth2')))
|
|
57
|
+
.response(new_response_handler
|
|
58
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
59
|
+
.deserialize_into(CheckoutSessionReviewResponse.method(:from_hash))
|
|
60
|
+
.local_error('400',
|
|
61
|
+
'Invalid request',
|
|
62
|
+
ApiErrorResponseException)
|
|
63
|
+
.local_error('401',
|
|
64
|
+
'Unauthorized',
|
|
65
|
+
SimpleErrorException)
|
|
66
|
+
.local_error('422',
|
|
67
|
+
'Processing error',
|
|
68
|
+
ApiErrorResponseException)
|
|
69
|
+
.local_error('500',
|
|
70
|
+
'Server error',
|
|
71
|
+
ApiErrorResponseException))
|
|
72
|
+
.execute
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Closes the merchant and consumer session and returns a payload identifier
|
|
76
|
+
# and optionally a secure payload used for payment processing.
|
|
77
|
+
# @param [CheckoutSessionCompleteRequest] body Required parameter: TODO:
|
|
78
|
+
# type description here
|
|
79
|
+
# @return [CheckoutSessionCompleteResponse] Response from the API call.
|
|
80
|
+
def complete_checkout_session(body)
|
|
81
|
+
@api_call
|
|
82
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
83
|
+
'/v1/checkout/sessions/complete',
|
|
84
|
+
Server::DEFAULT)
|
|
85
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
86
|
+
.body_param(new_parameter(body))
|
|
87
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
88
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
89
|
+
.auth(Single.new('OAuth2')))
|
|
90
|
+
.response(new_response_handler
|
|
91
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
92
|
+
.deserialize_into(CheckoutSessionCompleteResponse.method(:from_hash))
|
|
93
|
+
.local_error('400',
|
|
94
|
+
'Invalid request',
|
|
95
|
+
ApiErrorResponseException)
|
|
96
|
+
.local_error('401',
|
|
97
|
+
'Unauthorized',
|
|
98
|
+
SimpleErrorException)
|
|
99
|
+
.local_error('422',
|
|
100
|
+
'Unprocessable entity',
|
|
101
|
+
ApiErrorResponseException)
|
|
102
|
+
.local_error('500',
|
|
103
|
+
'Server error',
|
|
104
|
+
ApiErrorResponseException))
|
|
105
|
+
.execute
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# IdentityController
|
|
8
|
+
class IdentityController < BaseController
|
|
9
|
+
# Creates an OAuth access token using a JWT client assertion as defined in
|
|
10
|
+
# RFC7523. The token is valid for 30 minutes.
|
|
11
|
+
# @param [GrantTypeEnum] grant_type Required parameter: TODO: type
|
|
12
|
+
# description here
|
|
13
|
+
# @param [String] client_assertion Required parameter: JWT client
|
|
14
|
+
# assertion
|
|
15
|
+
# @param [ClientAssertionTypeEnum] client_assertion_type Required parameter:
|
|
16
|
+
# TODO: type description here
|
|
17
|
+
# @return [OAuthTokenResponse] Response from the API call.
|
|
18
|
+
def create_o_auth_token(grant_type,
|
|
19
|
+
client_assertion,
|
|
20
|
+
client_assertion_type)
|
|
21
|
+
@api_call
|
|
22
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
23
|
+
'/token',
|
|
24
|
+
Server::DEFAULT)
|
|
25
|
+
.form_param(new_parameter(grant_type, key: 'grant_type'))
|
|
26
|
+
.form_param(new_parameter(client_assertion, key: 'client_assertion'))
|
|
27
|
+
.form_param(new_parameter(client_assertion_type, key: 'client_assertion_type'))
|
|
28
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
29
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
30
|
+
.auth(Single.new('OAuth2')))
|
|
31
|
+
.response(new_response_handler
|
|
32
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
33
|
+
.deserialize_into(OAuthTokenResponse.method(:from_hash))
|
|
34
|
+
.local_error('400',
|
|
35
|
+
'Invalid grant',
|
|
36
|
+
SimpleErrorException)
|
|
37
|
+
.local_error('401',
|
|
38
|
+
'Unauthorized client assertion',
|
|
39
|
+
SimpleErrorException))
|
|
40
|
+
.execute
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# MerchantOnboardingController
|
|
8
|
+
class MerchantOnboardingController < BaseController
|
|
9
|
+
# Creates a new merchant entity in the Merchant System of Record and returns
|
|
10
|
+
# a unique Merchant ID used by Paze.
|
|
11
|
+
# @param [MerchantOnboardRequest] body Required parameter: TODO: type
|
|
12
|
+
# description here
|
|
13
|
+
# @return [MerchantResponse] Response from the API call.
|
|
14
|
+
def create_merchant(body)
|
|
15
|
+
@api_call
|
|
16
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
17
|
+
'/wallet/merchantonboarding/v1',
|
|
18
|
+
Server::DEFAULT)
|
|
19
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
20
|
+
.body_param(new_parameter(body))
|
|
21
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
22
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
23
|
+
.auth(Single.new('OAuth2')))
|
|
24
|
+
.response(new_response_handler
|
|
25
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
26
|
+
.deserialize_into(MerchantResponse.method(:from_hash))
|
|
27
|
+
.local_error('404',
|
|
28
|
+
'Resource not found',
|
|
29
|
+
BaseResponseException)
|
|
30
|
+
.local_error('409',
|
|
31
|
+
'Conflict',
|
|
32
|
+
BaseResponseException)
|
|
33
|
+
.local_error('500',
|
|
34
|
+
'Internal server error',
|
|
35
|
+
BaseResponseException))
|
|
36
|
+
.execute
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# OAuthAuthorizationController
|
|
8
|
+
class OAuthAuthorizationController < BaseController
|
|
9
|
+
# Create a new OAuth 2 token.
|
|
10
|
+
# @param [String] authorization Required parameter: Authorization header in
|
|
11
|
+
# Basic auth format
|
|
12
|
+
# @param [String] scope Optional parameter: Requested scopes as a
|
|
13
|
+
# space-delimited list.
|
|
14
|
+
# @param [Hash] _field_parameters Additional optional form parameters are
|
|
15
|
+
# supported by this endpoint.
|
|
16
|
+
# @return [OAuthToken] Response from the API call.
|
|
17
|
+
def request_token(authorization,
|
|
18
|
+
scope: nil,
|
|
19
|
+
_field_parameters: nil)
|
|
20
|
+
@api_call
|
|
21
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
22
|
+
'/token',
|
|
23
|
+
Server::ACCESS_TOKEN_SERVER)
|
|
24
|
+
.form_param(new_parameter('client_credentials', key: 'grant_type'))
|
|
25
|
+
.header_param(new_parameter(authorization, key: 'Authorization'))
|
|
26
|
+
.form_param(new_parameter(scope, key: 'scope'))
|
|
27
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
28
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
29
|
+
.additional_form_params(_field_parameters))
|
|
30
|
+
.response(new_response_handler
|
|
31
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
32
|
+
.deserialize_into(OAuthToken.method(:from_hash))
|
|
33
|
+
.local_error('400',
|
|
34
|
+
'OAuth 2 provider returned an error.',
|
|
35
|
+
OAuthProviderException)
|
|
36
|
+
.local_error('401',
|
|
37
|
+
'OAuth 2 provider says client authentication failed.',
|
|
38
|
+
OAuthProviderException))
|
|
39
|
+
.execute
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
module PazeCheckoutApi
|
|
8
|
+
# ApiErrorResponse class.
|
|
9
|
+
class ApiErrorResponseException < APIException
|
|
10
|
+
SKIP = Object.new
|
|
11
|
+
private_constant :SKIP
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for this method
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :client_context
|
|
16
|
+
|
|
17
|
+
# TODO: Write general description for this method
|
|
18
|
+
# @return [String]
|
|
19
|
+
attr_accessor :ew_sid
|
|
20
|
+
|
|
21
|
+
# TODO: Write general description for this method
|
|
22
|
+
# @return [DateTime]
|
|
23
|
+
attr_accessor :timestamp_iso8601
|
|
24
|
+
|
|
25
|
+
# TODO: Write general description for this method
|
|
26
|
+
# @return [ErrorMessage]
|
|
27
|
+
attr_accessor :error
|
|
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
|
+
@client_context =
|
|
45
|
+
hash.key?('clientContext') ? hash['clientContext'] : SKIP
|
|
46
|
+
@ew_sid = hash.key?('ewSID') ? hash['ewSID'] : nil
|
|
47
|
+
@timestamp_iso8601 = if hash.key?('timestampISO8601')
|
|
48
|
+
(DateTimeHelper.from_rfc3339(hash['timestampISO8601']) if hash['timestampISO8601'])
|
|
49
|
+
end
|
|
50
|
+
@error = ErrorMessage.from_hash(hash['error']) if hash['error']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Provides a human-readable string representation of the object.
|
|
54
|
+
def to_s
|
|
55
|
+
class_name = self.class.name.split('::').last
|
|
56
|
+
"<#{class_name} client_context: #{@client_context}, ew_sid: #{@ew_sid}, timestamp_iso8601:"\
|
|
57
|
+
" #{@timestamp_iso8601}, error: #{@error}>"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
61
|
+
def inspect
|
|
62
|
+
class_name = self.class.name.split('::').last
|
|
63
|
+
"<#{class_name} client_context: #{@client_context.inspect}, ew_sid: #{@ew_sid.inspect},"\
|
|
64
|
+
" timestamp_iso8601: #{@timestamp_iso8601.inspect}, error: #{@error.inspect}>"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
module PazeCheckoutApi
|
|
8
|
+
# BaseResponse class.
|
|
9
|
+
class BaseResponseException < APIException
|
|
10
|
+
SKIP = Object.new
|
|
11
|
+
private_constant :SKIP
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for this method
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :client_context
|
|
16
|
+
|
|
17
|
+
# TODO: Write general description for this method
|
|
18
|
+
# @return [String]
|
|
19
|
+
attr_accessor :ew_sid
|
|
20
|
+
|
|
21
|
+
# TODO: Write general description for this method
|
|
22
|
+
# @return [DateTime]
|
|
23
|
+
attr_accessor :timestamp_iso8601
|
|
24
|
+
|
|
25
|
+
# TODO: Write general description for this method
|
|
26
|
+
# @return [String]
|
|
27
|
+
attr_accessor :status_code
|
|
28
|
+
|
|
29
|
+
# TODO: Write general description for this method
|
|
30
|
+
# @return [String]
|
|
31
|
+
attr_accessor :status_text
|
|
32
|
+
|
|
33
|
+
# The constructor.
|
|
34
|
+
# @param [String] reason The reason for raising an exception.
|
|
35
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
36
|
+
def initialize(reason, response)
|
|
37
|
+
super(reason, response)
|
|
38
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
39
|
+
unbox(hash)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Populates this object by extracting properties from a hash.
|
|
43
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
44
|
+
# response body.
|
|
45
|
+
def unbox(hash)
|
|
46
|
+
return nil unless hash
|
|
47
|
+
|
|
48
|
+
@client_context =
|
|
49
|
+
hash.key?('clientContext') ? hash['clientContext'] : SKIP
|
|
50
|
+
@ew_sid = hash.key?('ewSID') ? hash['ewSID'] : SKIP
|
|
51
|
+
@timestamp_iso8601 = if hash.key?('timestampISO8601')
|
|
52
|
+
(DateTimeHelper.from_rfc3339(hash['timestampISO8601']) if hash['timestampISO8601'])
|
|
53
|
+
else
|
|
54
|
+
SKIP
|
|
55
|
+
end
|
|
56
|
+
@status_code = hash.key?('statusCode') ? hash['statusCode'] : SKIP
|
|
57
|
+
@status_text = hash.key?('statusText') ? hash['statusText'] : SKIP
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Provides a human-readable string representation of the object.
|
|
61
|
+
def to_s
|
|
62
|
+
class_name = self.class.name.split('::').last
|
|
63
|
+
"<#{class_name} client_context: #{@client_context}, ew_sid: #{@ew_sid}, timestamp_iso8601:"\
|
|
64
|
+
" #{@timestamp_iso8601}, status_code: #{@status_code}, status_text: #{@status_text}>"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
68
|
+
def inspect
|
|
69
|
+
class_name = self.class.name.split('::').last
|
|
70
|
+
"<#{class_name} client_context: #{@client_context.inspect}, ew_sid: #{@ew_sid.inspect},"\
|
|
71
|
+
" timestamp_iso8601: #{@timestamp_iso8601.inspect}, status_code: #{@status_code.inspect},"\
|
|
72
|
+
" status_text: #{@status_text.inspect}>"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
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 [OAuthProviderErrorEnum]
|
|
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,46 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# SimpleError class.
|
|
8
|
+
class SimpleErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@error = hash.key?('error') ? hash['error'] : nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} error: #{@error}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} error: #{@error.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class OAuth2 < 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
|
+
'ClientCredentialsAuth: OAuthToken is undefined or expired.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(client_credentials_auth_credentials, config)
|
|
18
|
+
@_o_auth_client_id = client_credentials_auth_credentials.o_auth_client_id unless
|
|
19
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_client_id.nil?
|
|
20
|
+
@_o_auth_client_secret = client_credentials_auth_credentials.o_auth_client_secret unless
|
|
21
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_client_secret.nil?
|
|
22
|
+
@_o_auth_token = client_credentials_auth_credentials.o_auth_token unless
|
|
23
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_token.nil?
|
|
24
|
+
@_o_auth_clock_skew = client_credentials_auth_credentials.o_auth_clock_skew unless
|
|
25
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_clock_skew.nil?
|
|
26
|
+
@_o_auth_token_provider = client_credentials_auth_credentials.o_auth_token_provider unless
|
|
27
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_token_provider.nil?
|
|
28
|
+
@_o_auth_on_token_update = client_credentials_auth_credentials.o_auth_on_token_update unless
|
|
29
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_on_token_update.nil?
|
|
30
|
+
@_o_auth_api = OAuthAuthorizationController.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
|
+
@_o_auth_token = get_token_from_provider
|
|
38
|
+
@_o_auth_token.is_a?(OAuthToken) && !token_expired?(@_o_auth_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(@_o_auth_client_id, @_o_auth_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(
|
|
52
|
+
build_basic_auth_header,
|
|
53
|
+
_field_parameters: additional_params
|
|
54
|
+
)
|
|
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, @_o_auth_clock_skew)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def apply(http_request)
|
|
69
|
+
auth_params = { 'Authorization' => "Bearer #{@_o_auth_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 @_o_auth_token if @_o_auth_token && !token_expired?(@_o_auth_token)
|
|
79
|
+
|
|
80
|
+
if @_o_auth_token_provider
|
|
81
|
+
o_auth_token = @_o_auth_token_provider.call(@_o_auth_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 ClientCredentialsAuthCredentials.
|
|
96
|
+
class ClientCredentialsAuthCredentials
|
|
97
|
+
attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_token,
|
|
98
|
+
:o_auth_token_provider, :o_auth_on_token_update,
|
|
99
|
+
:o_auth_clock_skew
|
|
100
|
+
|
|
101
|
+
def initialize(o_auth_client_id:, o_auth_client_secret:, o_auth_token: nil,
|
|
102
|
+
o_auth_token_provider: nil, o_auth_on_token_update: nil,
|
|
103
|
+
o_auth_clock_skew: 0)
|
|
104
|
+
raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
|
|
105
|
+
raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
|
|
106
|
+
|
|
107
|
+
@o_auth_client_id = o_auth_client_id
|
|
108
|
+
@o_auth_client_secret = o_auth_client_secret
|
|
109
|
+
@o_auth_token = o_auth_token
|
|
110
|
+
@o_auth_token_provider = o_auth_token_provider
|
|
111
|
+
@o_auth_on_token_update = o_auth_on_token_update
|
|
112
|
+
@o_auth_clock_skew = o_auth_clock_skew
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.from_env
|
|
116
|
+
o_auth_client_id = ENV['O_AUTH_CLIENT_ID']
|
|
117
|
+
o_auth_client_secret = ENV['O_AUTH_CLIENT_SECRET']
|
|
118
|
+
o_auth_clock_skew = ENV['O_AUTH_CLOCK_SKEW']
|
|
119
|
+
all_nil = [
|
|
120
|
+
o_auth_client_id,
|
|
121
|
+
o_auth_client_secret
|
|
122
|
+
].all?(&:nil?)
|
|
123
|
+
return nil if all_nil
|
|
124
|
+
|
|
125
|
+
new(o_auth_client_id: o_auth_client_id,
|
|
126
|
+
o_auth_client_secret: o_auth_client_secret,
|
|
127
|
+
o_auth_clock_skew: o_auth_clock_skew)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
|
|
131
|
+
o_auth_token: nil, o_auth_token_provider: nil,
|
|
132
|
+
o_auth_on_token_update: nil, o_auth_clock_skew: nil)
|
|
133
|
+
o_auth_client_id ||= self.o_auth_client_id
|
|
134
|
+
o_auth_client_secret ||= self.o_auth_client_secret
|
|
135
|
+
o_auth_token ||= self.o_auth_token
|
|
136
|
+
o_auth_token_provider ||= self.o_auth_token_provider
|
|
137
|
+
o_auth_on_token_update ||= self.o_auth_on_token_update
|
|
138
|
+
o_auth_clock_skew ||= self.o_auth_clock_skew
|
|
139
|
+
|
|
140
|
+
ClientCredentialsAuthCredentials.new(
|
|
141
|
+
o_auth_client_id: o_auth_client_id,
|
|
142
|
+
o_auth_client_secret: o_auth_client_secret, o_auth_token: o_auth_token,
|
|
143
|
+
o_auth_token_provider: o_auth_token_provider,
|
|
144
|
+
o_auth_on_token_update: o_auth_on_token_update,
|
|
145
|
+
o_auth_clock_skew: o_auth_clock_skew
|
|
146
|
+
)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# paze_checkout_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
|
4
|
+
# ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PazeCheckoutApi
|
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
|
9
|
+
end
|
|
10
|
+
end
|