splitit-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.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +154 -0
  4. data/bin/console +15 -0
  5. data/lib/splitit_web_api_v4/api_helper.rb +10 -0
  6. data/lib/splitit_web_api_v4/client.rb +83 -0
  7. data/lib/splitit_web_api_v4/configuration.rb +188 -0
  8. data/lib/splitit_web_api_v4/controllers/base_controller.rb +60 -0
  9. data/lib/splitit_web_api_v4/controllers/installment_plan_controller.rb +242 -0
  10. data/lib/splitit_web_api_v4/controllers/o_auth_authorization_controller.rb +42 -0
  11. data/lib/splitit_web_api_v4/exceptions/api_error_response_exception.rb +51 -0
  12. data/lib/splitit_web_api_v4/exceptions/api_exception.rb +21 -0
  13. data/lib/splitit_web_api_v4/exceptions/o_auth_provider_exception.rb +64 -0
  14. data/lib/splitit_web_api_v4/http/auth/api_key.rb +52 -0
  15. data/lib/splitit_web_api_v4/http/auth/o_auth2.rb +156 -0
  16. data/lib/splitit_web_api_v4/http/http_call_back.rb +10 -0
  17. data/lib/splitit_web_api_v4/http/http_method_enum.rb +10 -0
  18. data/lib/splitit_web_api_v4/http/http_request.rb +10 -0
  19. data/lib/splitit_web_api_v4/http/http_response.rb +10 -0
  20. data/lib/splitit_web_api_v4/http/proxy_settings.rb +22 -0
  21. data/lib/splitit_web_api_v4/models/amount_data.rb +70 -0
  22. data/lib/splitit_web_api_v4/models/api_error_model.rb +93 -0
  23. data/lib/splitit_web_api_v4/models/apr_data.rb +70 -0
  24. data/lib/splitit_web_api_v4/models/authorization_status_enum.rb +40 -0
  25. data/lib/splitit_web_api_v4/models/authorize_authorization_data.rb +154 -0
  26. data/lib/splitit_web_api_v4/models/authorize_request.rb +115 -0
  27. data/lib/splitit_web_api_v4/models/authorize_response.rb +221 -0
  28. data/lib/splitit_web_api_v4/models/base_model.rb +110 -0
  29. data/lib/splitit_web_api_v4/models/billing_address_data.rb +111 -0
  30. data/lib/splitit_web_api_v4/models/card_details.rb +108 -0
  31. data/lib/splitit_web_api_v4/models/card_validity_request.rb +62 -0
  32. data/lib/splitit_web_api_v4/models/card_validity_response.rb +80 -0
  33. data/lib/splitit_web_api_v4/models/checkout_url_data.rb +80 -0
  34. data/lib/splitit_web_api_v4/models/content_segment.rb +90 -0
  35. data/lib/splitit_web_api_v4/models/external_provider_types_enum.rb +48 -0
  36. data/lib/splitit_web_api_v4/models/inline_content.rb +71 -0
  37. data/lib/splitit_web_api_v4/models/installment_item.rb +101 -0
  38. data/lib/splitit_web_api_v4/models/installment_plan_details_response.rb +280 -0
  39. data/lib/splitit_web_api_v4/models/installment_plan_search_details_response.rb +71 -0
  40. data/lib/splitit_web_api_v4/models/installment_plan_search_request.rb +79 -0
  41. data/lib/splitit_web_api_v4/models/installment_plan_status_enum.rb +72 -0
  42. data/lib/splitit_web_api_v4/models/installment_status_enum.rb +60 -0
  43. data/lib/splitit_web_api_v4/models/masked_card_details.rb +82 -0
  44. data/lib/splitit_web_api_v4/models/metadata_item.rb +71 -0
  45. data/lib/splitit_web_api_v4/models/o_auth_provider_error_enum.rb +62 -0
  46. data/lib/splitit_web_api_v4/models/o_auth_scope_o_auth2_enum.rb +26 -0
  47. data/lib/splitit_web_api_v4/models/o_auth_token.rb +96 -0
  48. data/lib/splitit_web_api_v4/models/offer_item.rb +164 -0
  49. data/lib/splitit_web_api_v4/models/offers_billing_address.rb +108 -0
  50. data/lib/splitit_web_api_v4/models/offers_card_details.rb +108 -0
  51. data/lib/splitit_web_api_v4/models/offers_merchant_details.rb +82 -0
  52. data/lib/splitit_web_api_v4/models/offers_payment_method.rb +66 -0
  53. data/lib/splitit_web_api_v4/models/offers_payment_method_response.rb +88 -0
  54. data/lib/splitit_web_api_v4/models/offers_request.rb +145 -0
  55. data/lib/splitit_web_api_v4/models/offers_response.rb +156 -0
  56. data/lib/splitit_web_api_v4/models/offers_shopper_details.rb +112 -0
  57. data/lib/splitit_web_api_v4/models/offers_store_location.rb +108 -0
  58. data/lib/splitit_web_api_v4/models/payment_link_request.rb +195 -0
  59. data/lib/splitit_web_api_v4/models/payment_link_response.rb +107 -0
  60. data/lib/splitit_web_api_v4/models/payment_method.rb +66 -0
  61. data/lib/splitit_web_api_v4/models/payment_method_data.rb +78 -0
  62. data/lib/splitit_web_api_v4/models/payment_method_type_enum.rb +26 -0
  63. data/lib/splitit_web_api_v4/models/pis_error_codes_enum.rb +1021 -0
  64. data/lib/splitit_web_api_v4/models/plan_authorization_data.rb +172 -0
  65. data/lib/splitit_web_api_v4/models/plan_links_data.rb +91 -0
  66. data/lib/splitit_web_api_v4/models/plan_status_enum.rb +48 -0
  67. data/lib/splitit_web_api_v4/models/processing_data.rb +63 -0
  68. data/lib/splitit_web_api_v4/models/purchase_method_enum.rb +52 -0
  69. data/lib/splitit_web_api_v4/models/redirect_urls.rb +81 -0
  70. data/lib/splitit_web_api_v4/models/refund_item.rb +136 -0
  71. data/lib/splitit_web_api_v4/models/refund_request.rb +70 -0
  72. data/lib/splitit_web_api_v4/models/refund_response.rb +105 -0
  73. data/lib/splitit_web_api_v4/models/shipping_status_enum.rb +40 -0
  74. data/lib/splitit_web_api_v4/models/shopper_details_data.rb +113 -0
  75. data/lib/splitit_web_api_v4/models/three_ds_authentication_data.rb +90 -0
  76. data/lib/splitit_web_api_v4/models/three_ds_execute.rb +62 -0
  77. data/lib/splitit_web_api_v4/models/three_ds_redirect_data.rb +93 -0
  78. data/lib/splitit_web_api_v4/models/three_ds_request_data.rb +84 -0
  79. data/lib/splitit_web_api_v4/models/update_offers_payment_method.rb +66 -0
  80. data/lib/splitit_web_api_v4/models/update_offers_request.rb +105 -0
  81. data/lib/splitit_web_api_v4/models/update_order_request.rb +104 -0
  82. data/lib/splitit_web_api_v4/models/update_order_response.rb +126 -0
  83. data/lib/splitit_web_api_v4/models/validation_error.rb +71 -0
  84. data/lib/splitit_web_api_v4/utilities/date_time_helper.rb +11 -0
  85. data/lib/splitit_web_api_v4/utilities/file_wrapper.rb +28 -0
  86. data/lib/splitit_web_api_v4.rb +108 -0
  87. metadata +170 -0
@@ -0,0 +1,242 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # InstallmentPlanController
8
+ class InstallmentPlanController < BaseController
9
+ # TODO: type endpoint description here
10
+ # @param [CardValidityRequest] body Required parameter: TODO: type
11
+ # description here
12
+ # @param [String] x_splitit_touch_point Optional parameter: Example:
13
+ # @param [String] x_splitit_idempotency_key Optional parameter: TODO: type
14
+ # description here
15
+ # @return [CardValidityResponse] Response from the API call.
16
+ def installment_plan_check_card_validity(body,
17
+ x_splitit_touch_point: nil,
18
+ x_splitit_idempotency_key: nil)
19
+ @api_call
20
+ .request(new_request_builder(HttpMethodEnum::POST,
21
+ '/api/v1/installmentplans/card-validity',
22
+ Server::DEFAULT)
23
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
24
+ .body_param(new_parameter(body))
25
+ .header_param(new_parameter(x_splitit_touch_point, key: 'X-Splitit-TouchPoint'))
26
+ .header_param(new_parameter(x_splitit_idempotency_key, key: 'X-Splitit-IdempotencyKey'))
27
+ .header_param(new_parameter('application/json', key: 'accept'))
28
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
29
+ .auth(And.new('OAuth2', 'ApiKey')))
30
+ .response(new_response_handler
31
+ .deserializer(APIHelper.method(:custom_type_deserializer))
32
+ .deserialize_into(CardValidityResponse.method(:from_hash))
33
+ .local_error('default',
34
+ 'Error',
35
+ ApiErrorResponseException))
36
+ .execute
37
+ end
38
+
39
+ # TODO: type endpoint description here
40
+ # @param [OffersRequest] body Required parameter: TODO: type description
41
+ # here
42
+ # @return [OffersResponse] Response from the API call.
43
+ def installment_plan_create_offers(body)
44
+ @api_call
45
+ .request(new_request_builder(HttpMethodEnum::POST,
46
+ '/api/v1/installmentplans/offers',
47
+ Server::DEFAULT)
48
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
49
+ .body_param(new_parameter(body))
50
+ .header_param(new_parameter('application/json', key: 'accept'))
51
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
52
+ .auth(And.new('OAuth2', 'ApiKey')))
53
+ .response(new_response_handler
54
+ .deserializer(APIHelper.method(:custom_type_deserializer))
55
+ .deserialize_into(OffersResponse.method(:from_hash))
56
+ .local_error('default',
57
+ 'Error',
58
+ ApiErrorResponseException))
59
+ .execute
60
+ end
61
+
62
+ # TODO: type endpoint description here
63
+ # @param [PaymentLinkRequest] body Required parameter: TODO: type
64
+ # description here
65
+ # @return [PaymentLinkResponse] Response from the API call.
66
+ def installment_plan_generate_payment_link(body)
67
+ @api_call
68
+ .request(new_request_builder(HttpMethodEnum::POST,
69
+ '/api/v1/installmentplans/payment-link/generate',
70
+ Server::DEFAULT)
71
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
72
+ .body_param(new_parameter(body))
73
+ .header_param(new_parameter('application/json', key: 'accept'))
74
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
75
+ .auth(And.new('OAuth2', 'ApiKey')))
76
+ .response(new_response_handler
77
+ .deserializer(APIHelper.method(:custom_type_deserializer))
78
+ .deserialize_into(PaymentLinkResponse.method(:from_hash))
79
+ .local_error('default',
80
+ 'Error',
81
+ ApiErrorResponseException))
82
+ .execute
83
+ end
84
+
85
+ # TODO: type endpoint description here
86
+ # @param [String] installment_plan_number Required parameter: TODO: type
87
+ # description here
88
+ # @param [UpdateOffersRequest] body Required parameter: TODO: type
89
+ # description here
90
+ # @return [OffersResponse] Response from the API call.
91
+ def installment_plan_update_offers(installment_plan_number,
92
+ body)
93
+ @api_call
94
+ .request(new_request_builder(HttpMethodEnum::PUT,
95
+ '/api/v1/installmentplans/offers/{installmentPlanNumber}',
96
+ Server::DEFAULT)
97
+ .template_param(new_parameter(installment_plan_number, key: 'installmentPlanNumber')
98
+ .should_encode(true))
99
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
100
+ .body_param(new_parameter(body))
101
+ .header_param(new_parameter('application/json', key: 'accept'))
102
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
103
+ .auth(And.new('OAuth2', 'ApiKey')))
104
+ .response(new_response_handler
105
+ .deserializer(APIHelper.method(:custom_type_deserializer))
106
+ .deserialize_into(OffersResponse.method(:from_hash))
107
+ .local_error('default',
108
+ 'Error',
109
+ ApiErrorResponseException))
110
+ .execute
111
+ end
112
+
113
+ # TODO: type endpoint description here
114
+ # @param [String] installment_plan_number Required parameter: TODO: type
115
+ # description here
116
+ # @param [AuthorizeRequest] body Required parameter: TODO: type description
117
+ # here
118
+ # @return [AuthorizeResponse] Response from the API call.
119
+ def installment_plan_authorize(installment_plan_number,
120
+ body)
121
+ @api_call
122
+ .request(new_request_builder(HttpMethodEnum::POST,
123
+ '/api/v1/installmentplans/{installmentPlanNumber}/authorize',
124
+ Server::DEFAULT)
125
+ .template_param(new_parameter(installment_plan_number, key: 'installmentPlanNumber')
126
+ .should_encode(true))
127
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
128
+ .body_param(new_parameter(body))
129
+ .header_param(new_parameter('application/json', key: 'accept'))
130
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
131
+ .auth(And.new('OAuth2', 'ApiKey')))
132
+ .response(new_response_handler
133
+ .deserializer(APIHelper.method(:custom_type_deserializer))
134
+ .deserialize_into(AuthorizeResponse.method(:from_hash))
135
+ .local_error('default',
136
+ 'Error',
137
+ ApiErrorResponseException))
138
+ .execute
139
+ end
140
+
141
+ # TODO: type endpoint description here
142
+ # @param [String] installment_plan_number Required parameter: TODO: type
143
+ # description here
144
+ # @param [UpdateOrderRequest] body Required parameter: TODO: type
145
+ # description here
146
+ # @return [UpdateOrderResponse] Response from the API call.
147
+ def installment_plan_update_order(installment_plan_number,
148
+ body)
149
+ @api_call
150
+ .request(new_request_builder(HttpMethodEnum::PUT,
151
+ '/api/v1/installmentplans/{installmentPlanNumber}/updateorder',
152
+ Server::DEFAULT)
153
+ .template_param(new_parameter(installment_plan_number, key: 'installmentPlanNumber')
154
+ .should_encode(true))
155
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
156
+ .body_param(new_parameter(body))
157
+ .header_param(new_parameter('application/json', key: 'accept'))
158
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
159
+ .auth(And.new('OAuth2', 'ApiKey')))
160
+ .response(new_response_handler
161
+ .deserializer(APIHelper.method(:custom_type_deserializer))
162
+ .deserialize_into(UpdateOrderResponse.method(:from_hash))
163
+ .local_error('default',
164
+ 'Error',
165
+ ApiErrorResponseException))
166
+ .execute
167
+ end
168
+
169
+ # TODO: type endpoint description here
170
+ # @param [String] installment_plan_number Required parameter: TODO: type
171
+ # description here
172
+ # @return [InstallmentPlanDetailsResponse] Response from the API call.
173
+ def installment_plan_get_by_installment_plan_number(installment_plan_number)
174
+ @api_call
175
+ .request(new_request_builder(HttpMethodEnum::GET,
176
+ '/api/v1/installmentplans/{installmentPlanNumber}',
177
+ Server::DEFAULT)
178
+ .template_param(new_parameter(installment_plan_number, key: 'installmentPlanNumber')
179
+ .should_encode(true))
180
+ .header_param(new_parameter('application/json', key: 'accept'))
181
+ .auth(And.new('OAuth2', 'ApiKey')))
182
+ .response(new_response_handler
183
+ .deserializer(APIHelper.method(:custom_type_deserializer))
184
+ .deserialize_into(InstallmentPlanDetailsResponse.method(:from_hash))
185
+ .local_error('default',
186
+ 'Error',
187
+ ApiErrorResponseException))
188
+ .execute
189
+ end
190
+
191
+ # TODO: type endpoint description here
192
+ # @param [InstallmentPlanSearchRequest] body Required parameter: TODO: type
193
+ # description here
194
+ # @return [InstallmentPlanSearchDetailsResponse] Response from the API call.
195
+ def installment_plan_search(body)
196
+ @api_call
197
+ .request(new_request_builder(HttpMethodEnum::POST,
198
+ '/api/v1/installmentplans/search',
199
+ Server::DEFAULT)
200
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
201
+ .body_param(new_parameter(body))
202
+ .header_param(new_parameter('application/json', key: 'accept'))
203
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
204
+ .auth(And.new('OAuth2', 'ApiKey')))
205
+ .response(new_response_handler
206
+ .deserializer(APIHelper.method(:custom_type_deserializer))
207
+ .deserialize_into(InstallmentPlanSearchDetailsResponse.method(:from_hash))
208
+ .local_error('default',
209
+ 'Error',
210
+ ApiErrorResponseException))
211
+ .execute
212
+ end
213
+
214
+ # TODO: type endpoint description here
215
+ # @param [String] installment_plan_number Required parameter: TODO: type
216
+ # description here
217
+ # @param [RefundRequest] body Required parameter: TODO: type description
218
+ # here
219
+ # @return [RefundResponse] Response from the API call.
220
+ def installment_plan_refund(installment_plan_number,
221
+ body)
222
+ @api_call
223
+ .request(new_request_builder(HttpMethodEnum::POST,
224
+ '/api/v1/installmentplans/{installmentPlanNumber}/refund',
225
+ Server::DEFAULT)
226
+ .template_param(new_parameter(installment_plan_number, key: 'installmentPlanNumber')
227
+ .should_encode(true))
228
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
229
+ .body_param(new_parameter(body))
230
+ .header_param(new_parameter('application/json', key: 'accept'))
231
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
232
+ .auth(And.new('OAuth2', 'ApiKey')))
233
+ .response(new_response_handler
234
+ .deserializer(APIHelper.method(:custom_type_deserializer))
235
+ .deserialize_into(RefundResponse.method(:from_hash))
236
+ .local_error('default',
237
+ 'Error',
238
+ ApiErrorResponseException))
239
+ .execute
240
+ end
241
+ end
242
+ end
@@ -0,0 +1,42 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
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_o_auth2(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,51 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # ApiErrorResponse class.
8
+ class ApiErrorResponseException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [String]
14
+ attr_accessor :trace_id
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [ApiErrorModel]
18
+ attr_accessor :error
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
+ @trace_id = hash.key?('TraceId') ? hash['TraceId'] : SKIP
36
+ @error = ApiErrorModel.from_hash(hash['Error']) if hash['Error']
37
+ end
38
+
39
+ # Provides a human-readable string representation of the object.
40
+ def to_s
41
+ class_name = self.class.name.split('::').last
42
+ "<#{class_name} trace_id: #{@trace_id}, error: #{@error}>"
43
+ end
44
+
45
+ # Provides a debugging-friendly string with detailed object information.
46
+ def inspect
47
+ class_name = self.class.name.split('::').last
48
+ "<#{class_name} trace_id: #{@trace_id.inspect}, error: #{@error.inspect}>"
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
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,64 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
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,52 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # Utility class for custom header authorization.
8
+ class ApiKey < CoreLibrary::HeaderAuth
9
+ # Display error message on occurrence of authentication failure.
10
+ # @returns [String] The oAuth error message.
11
+ def error_message
12
+ 'ApiKey: x_splitit_api_key is undefined.'
13
+ end
14
+
15
+ # Initialization constructor.
16
+ def initialize(api_key_credentials)
17
+ auth_params = {}
18
+ auth_params['X-Splitit-Api-Key'] = api_key_credentials.x_splitit_api_key unless
19
+ api_key_credentials.nil? || api_key_credentials.x_splitit_api_key.nil?
20
+
21
+ super auth_params
22
+ end
23
+ end
24
+
25
+ # Data class for ApiKeyCredentials.
26
+ # Data class for ApiKeyCredentials.
27
+ class ApiKeyCredentials
28
+ attr_reader :x_splitit_api_key
29
+
30
+ def initialize(x_splitit_api_key:)
31
+ raise ArgumentError, 'x_splitit_api_key cannot be nil' if x_splitit_api_key.nil?
32
+
33
+ @x_splitit_api_key = x_splitit_api_key
34
+ end
35
+
36
+ def self.from_env
37
+ x_splitit_api_key = ENV['API_KEY_X_SPLITIT_API_KEY']
38
+ all_nil = [
39
+ x_splitit_api_key
40
+ ].all?(&:nil?)
41
+ return nil if all_nil
42
+
43
+ new(x_splitit_api_key: x_splitit_api_key)
44
+ end
45
+
46
+ def clone_with(x_splitit_api_key: nil)
47
+ x_splitit_api_key ||= self.x_splitit_api_key
48
+
49
+ ApiKeyCredentials.new(x_splitit_api_key: x_splitit_api_key)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,156 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
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
+ 'OAuth2: OAuthToken is undefined or expired.'
14
+ end
15
+
16
+ # Initialization constructor.
17
+ def initialize(o_auth2_credentials, config)
18
+ @_o_auth_client_id = o_auth2_credentials.o_auth_client_id unless
19
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_client_id.nil?
20
+ @_o_auth_client_secret = o_auth2_credentials.o_auth_client_secret unless
21
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_client_secret.nil?
22
+ @_o_auth_token = o_auth2_credentials.o_auth_token unless
23
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_token.nil?
24
+ @_o_auth_scopes = o_auth2_credentials.o_auth_scopes unless
25
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_scopes.nil?
26
+ @_o_auth_clock_skew = o_auth2_credentials.o_auth_clock_skew unless
27
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_clock_skew.nil?
28
+ @_o_auth_token_provider = o_auth2_credentials.o_auth_token_provider unless
29
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_token_provider.nil?
30
+ @_o_auth_on_token_update = o_auth2_credentials.o_auth_on_token_update unless
31
+ o_auth2_credentials.nil? || o_auth2_credentials.o_auth_on_token_update.nil?
32
+ @_o_auth_api = OAuthAuthorizationController.new(config)
33
+ super({})
34
+ end
35
+
36
+ # Validates the oAuth token.
37
+ # @return [Boolean] true if the token is present and not expired.
38
+ def valid
39
+ @_o_auth_token = get_token_from_provider
40
+ @_o_auth_token.is_a?(OAuthToken) && !token_expired?(@_o_auth_token)
41
+ end
42
+
43
+ # Builds the basic auth header for endpoints in the OAuth Authorization Controller.
44
+ # @return [String] The value of the Authentication header.
45
+ def build_basic_auth_header
46
+ "Basic #{AuthHelper.get_base64_encoded_value(@_o_auth_client_id, @_o_auth_client_secret)}"
47
+ end
48
+
49
+ # Fetches the token.
50
+ # @param [Hash] additional_params Any additional form parameters.
51
+ # @return [OAuthToken] The oAuth token instance.
52
+ def fetch_token(additional_params: nil)
53
+ token = @_o_auth_api.request_token_o_auth2(
54
+ build_basic_auth_header,
55
+ scope: !@_o_auth_scopes.nil? ? Array(@_o_auth_scopes).compact.join(' ') : @_o_auth_scopes,
56
+ _field_parameters: additional_params
57
+ )
58
+ if token.respond_to?('expires_in') && !token.expires_in.nil?
59
+ token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
60
+ end
61
+ token
62
+ end
63
+
64
+ # Checks if OAuth token has expired.
65
+ # @param [OAuthToken] token The oAuth token instance.
66
+ # @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
67
+ def token_expired?(token)
68
+ token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry, @_o_auth_clock_skew)
69
+ end
70
+
71
+ def apply(http_request)
72
+ auth_params = { 'Authorization' => "Bearer #{@_o_auth_token.access_token}" }
73
+ AuthHelper.apply(auth_params, http_request.method(:add_header))
74
+ end
75
+
76
+ private
77
+
78
+ # This provides the OAuth Token from either the user configured callbacks or from default provider.
79
+ # @return [OAuthToken] The fetched oauth token.
80
+ def get_token_from_provider
81
+ return @_o_auth_token if @_o_auth_token && !token_expired?(@_o_auth_token)
82
+
83
+ if @_o_auth_token_provider
84
+ o_auth_token = @_o_auth_token_provider.call(@_o_auth_token, self)
85
+ @_o_auth_on_token_update&.call(o_auth_token)
86
+ return o_auth_token
87
+ end
88
+ begin
89
+ o_auth_token = fetch_token
90
+ @_o_auth_on_token_update&.call(o_auth_token)
91
+ o_auth_token
92
+ rescue ApiException
93
+ @_o_auth_token
94
+ end
95
+ end
96
+ end
97
+
98
+ # Data class for OAuth2Credentials.
99
+ class OAuth2Credentials
100
+ attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_token,
101
+ :o_auth_scopes, :o_auth_token_provider, :o_auth_on_token_update,
102
+ :o_auth_clock_skew
103
+
104
+ def initialize(o_auth_client_id:, o_auth_client_secret:, o_auth_token: nil,
105
+ o_auth_scopes: nil, o_auth_token_provider: nil,
106
+ o_auth_on_token_update: nil, o_auth_clock_skew: 0)
107
+ raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
108
+ raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
109
+
110
+ @o_auth_client_id = o_auth_client_id
111
+ @o_auth_client_secret = o_auth_client_secret
112
+ @o_auth_token = o_auth_token
113
+ @o_auth_scopes = o_auth_scopes
114
+ @o_auth_token_provider = o_auth_token_provider
115
+ @o_auth_on_token_update = o_auth_on_token_update
116
+ @o_auth_clock_skew = o_auth_clock_skew
117
+ end
118
+
119
+ def self.from_env
120
+ o_auth_client_id = ENV['O_AUTH2_O_AUTH_CLIENT_ID']
121
+ o_auth_client_secret = ENV['O_AUTH2_O_AUTH_CLIENT_SECRET']
122
+ o_auth_scopes = ENV['O_AUTH2_O_AUTH_SCOPES']
123
+ o_auth_clock_skew = ENV['O_AUTH2_O_AUTH_CLOCK_SKEW']
124
+ all_nil = [
125
+ o_auth_client_id,
126
+ o_auth_client_secret
127
+ ].all?(&:nil?)
128
+ return nil if all_nil
129
+
130
+ new(o_auth_client_id: o_auth_client_id,
131
+ o_auth_client_secret: o_auth_client_secret,
132
+ o_auth_scopes: o_auth_scopes, o_auth_clock_skew: o_auth_clock_skew)
133
+ end
134
+
135
+ def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
136
+ o_auth_token: nil, o_auth_scopes: nil,
137
+ o_auth_token_provider: nil, o_auth_on_token_update: nil,
138
+ o_auth_clock_skew: nil)
139
+ o_auth_client_id ||= self.o_auth_client_id
140
+ o_auth_client_secret ||= self.o_auth_client_secret
141
+ o_auth_token ||= self.o_auth_token
142
+ o_auth_scopes ||= self.o_auth_scopes
143
+ o_auth_token_provider ||= self.o_auth_token_provider
144
+ o_auth_on_token_update ||= self.o_auth_on_token_update
145
+ o_auth_clock_skew ||= self.o_auth_clock_skew
146
+
147
+ OAuth2Credentials.new(o_auth_client_id: o_auth_client_id,
148
+ o_auth_client_secret: o_auth_client_secret,
149
+ o_auth_token: o_auth_token,
150
+ o_auth_scopes: o_auth_scopes,
151
+ o_auth_token_provider: o_auth_token_provider,
152
+ o_auth_on_token_update: o_auth_on_token_update,
153
+ o_auth_clock_skew: o_auth_clock_skew)
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,10 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # HttpCallBack allows defining callables for pre and post API calls.
8
+ class HttpCallBack < CoreLibrary::HttpCallback
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum < CoreLibrary::HttpMethod
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # Represents a single Http Request.
8
+ class HttpRequest < CoreLibrary::HttpRequest
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
9
+ end
10
+ end