checkout_sdk 1.2.2 → 1.3.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 +4 -4
- data/lib/checkout_sdk/accounts/account_holder.rb +10 -2
- data/lib/checkout_sdk/accounts/account_holder_corporate.rb +15 -0
- data/lib/checkout_sdk/accounts/account_holder_individual.rb +18 -0
- data/lib/checkout_sdk/accounts/accounts.rb +23 -0
- data/lib/checkout_sdk/accounts/additional_document.rb +11 -0
- data/lib/checkout_sdk/accounts/additional_info.rb +17 -0
- data/lib/checkout_sdk/accounts/articles_of_association_type.rb +10 -0
- data/lib/checkout_sdk/accounts/bank_verification.rb +14 -0
- data/lib/checkout_sdk/accounts/bank_verification_type.rb +9 -0
- data/lib/checkout_sdk/accounts/company.rb +7 -1
- data/lib/checkout_sdk/accounts/contact_details.rb +4 -1
- data/lib/checkout_sdk/accounts/date_of_incorporation.rb +14 -0
- data/lib/checkout_sdk/accounts/financial_verification.rb +14 -0
- data/lib/checkout_sdk/accounts/financial_verification_type.rb +9 -0
- data/lib/checkout_sdk/accounts/invitee.rb +11 -0
- data/lib/checkout_sdk/accounts/onboard_entity.rb +13 -4
- data/lib/checkout_sdk/accounts/onboard_sub_entity_documents.rb +31 -4
- data/lib/checkout_sdk/accounts/processing_details.rb +26 -0
- data/lib/checkout_sdk/accounts/proof_of_legality.rb +14 -0
- data/lib/checkout_sdk/accounts/proof_of_legality_type.rb +9 -0
- data/lib/checkout_sdk/accounts/proof_of_principal_address.rb +14 -0
- data/lib/checkout_sdk/accounts/proof_of_principal_address_type.rb +9 -0
- data/lib/checkout_sdk/accounts/shareholder_structure.rb +14 -0
- data/lib/checkout_sdk/accounts/shareholder_structure_type.rb +9 -0
- data/lib/checkout_sdk/api_client.rb +59 -50
- data/lib/checkout_sdk/client.rb +2 -3
- data/lib/checkout_sdk/common/account_change_indicator_type.rb +12 -0
- data/lib/checkout_sdk/common/account_holder.rb +12 -9
- data/lib/checkout_sdk/common/account_password_change_indicator_type.rb +13 -0
- data/lib/checkout_sdk/common/account_type_card_product_type.rb +11 -0
- data/lib/checkout_sdk/common/cardholder_account_age_indicator_type.rb +13 -0
- data/lib/checkout_sdk/common/common.rb +6 -0
- data/lib/checkout_sdk/common/customer_retry.rb +11 -0
- data/lib/checkout_sdk/common/destination.rb +38 -0
- data/lib/checkout_sdk/common/payment_source_type.rb +8 -0
- data/lib/checkout_sdk/common/product.rb +4 -1
- data/lib/checkout_sdk/error.rb +24 -8
- data/lib/checkout_sdk/payments/applepay.rb +14 -0
- data/lib/checkout_sdk/payments/{sessions/card.rb → card.rb} +4 -1
- data/lib/checkout_sdk/payments/exemption.rb +2 -0
- data/lib/checkout_sdk/payments/googlepay.rb +14 -0
- data/lib/checkout_sdk/payments/hosted/hosted_payment_instruction.rb +11 -0
- data/lib/checkout_sdk/payments/hosted/hosted_payments_session.rb +44 -23
- data/lib/checkout_sdk/payments/hosted/payment_purpose_type.rb +27 -0
- data/lib/checkout_sdk/payments/links/payment_link.rb +18 -0
- data/lib/checkout_sdk/payments/locale_type.rb +31 -0
- data/lib/checkout_sdk/payments/partial_authorization.rb +11 -0
- data/lib/checkout_sdk/payments/payment_method_configuration.rb +17 -0
- data/lib/checkout_sdk/payments/payment_request.rb +3 -0
- data/lib/checkout_sdk/payments/payments.rb +13 -3
- data/lib/checkout_sdk/payments/product.rb +3 -0
- data/lib/checkout_sdk/payments/refund_order.rb +53 -0
- data/lib/checkout_sdk/payments/refund_request.rb +11 -2
- data/lib/checkout_sdk/payments/sender/government_sender.rb +3 -0
- data/lib/checkout_sdk/payments/sender/individual_sender.rb +3 -0
- data/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb +3 -0
- data/lib/checkout_sdk/payments/source/apm/ach_source.rb +27 -0
- data/lib/checkout_sdk/payments/source/apm/bizum_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/apm/octopus_source.rb +11 -0
- data/lib/checkout_sdk/payments/source/apm/plaid_source.rb +17 -0
- data/lib/checkout_sdk/payments/source/apm/sequra_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/card_source.rb +4 -1
- data/lib/checkout_sdk/payments/source/customer_source.rb +4 -1
- data/lib/checkout_sdk/payments/source/id_source.rb +4 -1
- data/lib/checkout_sdk/payments/source/network_token_source.rb +7 -1
- data/lib/checkout_sdk/payments/source/token_source.rb +4 -1
- data/lib/checkout_sdk/sessions/authentication_method.rb +3 -3
- data/lib/checkout_sdk/sessions/authentication_type.rb +3 -3
- data/lib/checkout_sdk/sessions/card_holder_account_info.rb +39 -3
- data/lib/checkout_sdk/sessions/channel/browser_session.rb +4 -1
- data/lib/checkout_sdk/sessions/channel/channel_data_type.rb +1 -0
- data/lib/checkout_sdk/sessions/channel/merchant_initiated_session.rb +15 -0
- data/lib/checkout_sdk/sessions/channel/request_type.rb +19 -0
- data/lib/checkout_sdk/sessions/channel/sdk_interface_type.rb +2 -2
- data/lib/checkout_sdk/sessions/initial_transaction.rb +23 -0
- data/lib/checkout_sdk/sessions/installment.rb +5 -0
- data/lib/checkout_sdk/sessions/merchant_risk_info.rb +20 -2
- data/lib/checkout_sdk/sessions/optimization.rb +19 -0
- data/lib/checkout_sdk/sessions/optimized_properties.rb +17 -0
- data/lib/checkout_sdk/sessions/pre_order_purchase_indicator_type.rb +10 -0
- data/lib/checkout_sdk/sessions/recurring.rb +5 -0
- data/lib/checkout_sdk/sessions/reorder_items_indicator_type.rb +10 -0
- data/lib/checkout_sdk/sessions/session_request.rb +25 -2
- data/lib/checkout_sdk/sessions/sessions.rb +9 -0
- data/lib/checkout_sdk/sessions/source/card_source.rb +2 -1
- data/lib/checkout_sdk/sessions/three_ds_method_completion_request.rb +3 -1
- data/lib/checkout_sdk/sessions/three_ds_req_auth_method.rb +16 -0
- data/lib/checkout_sdk/sessions/three_ds_requestor_authentication_info.rb +17 -0
- data/lib/checkout_sdk/sessions/transaction_type.rb +3 -3
- data/lib/checkout_sdk/version.rb +1 -1
- metadata +52 -7
- data/lib/checkout_sdk/payments/sessions/payment_method_configuration.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a49fd0dc6d8074742539d0651bdb5c94d255bdaa5ee5be1944c8d7ec2b0c6f
|
4
|
+
data.tar.gz: 914ac0e1f225f44336272904d87224442055d6d7f869e99c183301ebc07544c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e32feee8e37ce63ce23dbc396151f12c469d8361da8dad4a3272801ea272d648a3e46b5ff889662d088d4874316159ce30cbaa671f7b4c94d22f3d7352e66341
|
7
|
+
data.tar.gz: d4af9e3225ea291ac6570d4d6bcce2892c1816a9163f154d7659b09d03c8a1d68a4fe9f08f937ecb24d74d22268b82bd9706ba92a636ef57e9f1ab1495a1f4b7
|
@@ -21,8 +21,8 @@ module CheckoutSdk
|
|
21
21
|
# @!attribute email
|
22
22
|
# @return [String]
|
23
23
|
class AccountHolder
|
24
|
-
|
25
|
-
|
24
|
+
attr_reader :type
|
25
|
+
attr_accessor :tax_id,
|
26
26
|
:date_of_birth,
|
27
27
|
:country_of_birth,
|
28
28
|
:residential_status,
|
@@ -30,6 +30,14 @@ module CheckoutSdk
|
|
30
30
|
:phone,
|
31
31
|
:identification,
|
32
32
|
:email
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
# @abstract
|
37
|
+
# @param [String] type {MetadataSourceType}
|
38
|
+
def initialize(type)
|
39
|
+
@type = type
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute company_name
|
6
|
+
# @return [String]
|
7
|
+
class AccountHolderCorporate < AccountHolder
|
8
|
+
attr_accessor :company_name
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super AccountHolderType::CORPORATE
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute first_name
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute last_name
|
8
|
+
# @return [String]
|
9
|
+
class AccountHolderIndividual < AccountHolder
|
10
|
+
attr_accessor :first_name,
|
11
|
+
:last_name
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super AccountHolderType::INDIVIDUAL
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -8,6 +8,8 @@ require 'checkout_sdk/accounts/document'
|
|
8
8
|
require 'checkout_sdk/accounts/individual'
|
9
9
|
require 'checkout_sdk/accounts/business_type'
|
10
10
|
require 'checkout_sdk/accounts/account_holder'
|
11
|
+
require 'checkout_sdk/accounts/account_holder_corporate'
|
12
|
+
require 'checkout_sdk/accounts/account_holder_individual'
|
11
13
|
require 'checkout_sdk/accounts/entity_financial_details'
|
12
14
|
require 'checkout_sdk/accounts/file_request'
|
13
15
|
require 'checkout_sdk/accounts/date_of_birth'
|
@@ -36,3 +38,24 @@ require 'checkout_sdk/accounts/payment_instrument_request'
|
|
36
38
|
require 'checkout_sdk/accounts/payment_instruments_query'
|
37
39
|
require 'checkout_sdk/accounts/headers'
|
38
40
|
require 'checkout_sdk/accounts/update_payment_instrument_request'
|
41
|
+
require 'checkout_sdk/accounts/additional_document'
|
42
|
+
require 'checkout_sdk/accounts/additional_info'
|
43
|
+
require 'checkout_sdk/accounts/articles_of_association_type'
|
44
|
+
require 'checkout_sdk/accounts/bank_verification'
|
45
|
+
require 'checkout_sdk/accounts/bank_verification_type'
|
46
|
+
require 'checkout_sdk/accounts/company_verification'
|
47
|
+
require 'checkout_sdk/accounts/company_verification_type'
|
48
|
+
require 'checkout_sdk/accounts/date_of_incorporation'
|
49
|
+
require 'checkout_sdk/accounts/financial_verification'
|
50
|
+
require 'checkout_sdk/accounts/financial_verification_type'
|
51
|
+
require 'checkout_sdk/accounts/invitee'
|
52
|
+
require 'checkout_sdk/accounts/onboard_sub_entity_documents'
|
53
|
+
require 'checkout_sdk/accounts/processing_details'
|
54
|
+
require 'checkout_sdk/accounts/proof_of_legality'
|
55
|
+
require 'checkout_sdk/accounts/proof_of_legality_type'
|
56
|
+
require 'checkout_sdk/accounts/proof_of_principal_address'
|
57
|
+
require 'checkout_sdk/accounts/proof_of_principal_address_type'
|
58
|
+
require 'checkout_sdk/accounts/shareholder_structure'
|
59
|
+
require 'checkout_sdk/accounts/shareholder_structure_type'
|
60
|
+
require 'checkout_sdk/accounts/tax_verification'
|
61
|
+
require 'checkout_sdk/accounts/tax_verification_type'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute field1
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute field2
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute field3
|
10
|
+
# @return [String]
|
11
|
+
class AdditionalInfo
|
12
|
+
attr_accessor :field1,
|
13
|
+
:field2,
|
14
|
+
:field3
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -10,12 +10,16 @@ module CheckoutSdk
|
|
10
10
|
# @return [String]
|
11
11
|
# @!attribute trading_name
|
12
12
|
# @return [String]
|
13
|
+
# @!attribute date_of_incorporation
|
14
|
+
# @return [DateOfIncorporation]
|
15
|
+
# @!attribute regulatory_licence_number
|
16
|
+
# @return [String]
|
13
17
|
# @!attribute principal_address
|
14
18
|
# @return [CheckoutSdk::Common::Address]
|
15
19
|
# @!attribute registered_address
|
16
20
|
# @return [CheckoutSdk::Common::Address]
|
17
21
|
# @!attribute representatives
|
18
|
-
# @return [Array(
|
22
|
+
# @return [Array(EntityRepresentative)]
|
19
23
|
# @!attribute document
|
20
24
|
# @return [EntityDocument]
|
21
25
|
# @!attribute financial_details
|
@@ -25,6 +29,8 @@ module CheckoutSdk
|
|
25
29
|
:business_type,
|
26
30
|
:legal_name,
|
27
31
|
:trading_name,
|
32
|
+
:date_of_incorporation,
|
33
|
+
:regulatory_licence_number,
|
28
34
|
:principal_address,
|
29
35
|
:registered_address,
|
30
36
|
:representatives,
|
@@ -6,9 +6,12 @@ module CheckoutSdk
|
|
6
6
|
# @return [Phone]
|
7
7
|
# @!attribute email_addresses
|
8
8
|
# @return [EntityEmailAddresses]
|
9
|
+
# @!attribute invitee
|
10
|
+
# @return [Invitee]
|
9
11
|
class ContactDetails
|
10
12
|
attr_accessor :phone,
|
11
|
-
:email_addresses
|
13
|
+
:email_addresses,
|
14
|
+
:invitee
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute type
|
6
|
+
# @return [FinancialVerificationType]
|
7
|
+
# @!attribute front
|
8
|
+
# @return [String]
|
9
|
+
class FinancialVerification
|
10
|
+
attr_reader :type,
|
11
|
+
:front
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -4,23 +4,32 @@ module CheckoutSdk
|
|
4
4
|
module Accounts
|
5
5
|
# @!attribute reference
|
6
6
|
# @return [String]
|
7
|
-
# @!attribute
|
8
|
-
# @return [
|
7
|
+
# @!attribute is_draft
|
8
|
+
# @return [Boolean]
|
9
9
|
# @!attribute profile
|
10
10
|
# @return [Profile]
|
11
|
+
# @!attribute contact_details
|
12
|
+
# @return [ContactDetails]
|
11
13
|
# @!attribute company
|
12
14
|
# @return [Company]
|
15
|
+
# @!attribute processing_details
|
16
|
+
# @return [ProcessingDetails]
|
13
17
|
# @!attribute individual
|
14
18
|
# @return [Individual]
|
15
19
|
# @!attribute documents
|
16
20
|
# @return [OnboardSubEntityDocuments]
|
21
|
+
# @!attribute additional_info
|
22
|
+
# @return [AdditionalInfo]
|
17
23
|
class OnboardEntity
|
18
24
|
attr_accessor :reference,
|
19
|
-
:
|
25
|
+
:is_draft,
|
20
26
|
:profile,
|
27
|
+
:contact_details,
|
21
28
|
:company,
|
29
|
+
:processing_details,
|
22
30
|
:individual,
|
23
|
-
:documents
|
31
|
+
:documents,
|
32
|
+
:additional_info
|
24
33
|
end
|
25
34
|
end
|
26
35
|
end
|
@@ -2,16 +2,43 @@
|
|
2
2
|
|
3
3
|
module CheckoutSdk
|
4
4
|
module Accounts
|
5
|
-
# @!attribute
|
6
|
-
# @return [
|
5
|
+
# @!attribute identity_verification
|
6
|
+
# @return [EntityIdentificationDocument]
|
7
7
|
# @!attribute company_verification
|
8
8
|
# @return [CompanyVerification]
|
9
|
+
# @!attribute articles_of_association
|
10
|
+
# @return [ArticlesOfAssociationType]
|
11
|
+
# @!attribute bank_verification
|
12
|
+
# @return [BankVerification]
|
13
|
+
# @!attribute shareholder_structure
|
14
|
+
# @return [ShareholderStructure]
|
15
|
+
# @!attribute proof_of_legality
|
16
|
+
# @return [ProofOfLegality]
|
17
|
+
# @!attribute proof_of_principal_address
|
18
|
+
# @return [ProofOfPrincipalAddress]
|
19
|
+
# @!attribute additional_document1
|
20
|
+
# @return [AdditionalDocument]
|
21
|
+
# @!attribute additional_document2
|
22
|
+
# @return [AdditionalDocument]
|
23
|
+
# @!attribute additional_document3
|
24
|
+
# @return [AdditionalDocument]
|
9
25
|
# @!attribute tax_verification
|
10
26
|
# @return [TaxVerification]
|
27
|
+
# @!attribute financial_verification
|
28
|
+
# @return [FinancialVerification]
|
11
29
|
class OnboardSubEntityDocuments
|
12
|
-
attr_accessor :
|
30
|
+
attr_accessor :identity_verification,
|
13
31
|
:company_verification,
|
14
|
-
:
|
32
|
+
:articles_of_association,
|
33
|
+
:bank_verification,
|
34
|
+
:shareholder_structure,
|
35
|
+
:proof_of_legality,
|
36
|
+
:proof_of_principal_address,
|
37
|
+
:additional_document1,
|
38
|
+
:additional_document2,
|
39
|
+
:additional_document3,
|
40
|
+
:tax_verification,
|
41
|
+
:financial_verification
|
15
42
|
end
|
16
43
|
end
|
17
44
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute settlement_country
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute target_countries
|
8
|
+
# @return [Array(String)]
|
9
|
+
# @!attribute annual_processing_volume
|
10
|
+
# @return [Integer]
|
11
|
+
# @!attribute average_transaction_value
|
12
|
+
# @return [Integer]
|
13
|
+
# @!attribute highest_transaction_value
|
14
|
+
# @return [Integer]
|
15
|
+
# @!attribute currency
|
16
|
+
# @return [CheckoutSdk::Common::Currency]
|
17
|
+
class ProcessingDetails
|
18
|
+
attr_accessor :settlement_country,
|
19
|
+
:target_countries,
|
20
|
+
:annual_processing_volume,
|
21
|
+
:average_transaction_value,
|
22
|
+
:highest_transaction_value,
|
23
|
+
:currency
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute type
|
6
|
+
# @return [ProofOfPrincipalAddressType]
|
7
|
+
# @!attribute front
|
8
|
+
# @return [String]
|
9
|
+
class ProofOfPrincipalAddress
|
10
|
+
attr_reader :type,
|
11
|
+
:front
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Accounts
|
5
|
+
# @!attribute type
|
6
|
+
# @return [ShareholderStructureType]
|
7
|
+
# @!attribute front
|
8
|
+
# @return [String]
|
9
|
+
class ShareholderStructure
|
10
|
+
attr_accessor :type,
|
11
|
+
:front
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'csv'
|
4
|
+
|
3
5
|
module CheckoutSdk
|
4
6
|
class ApiClient
|
5
7
|
attr_accessor :client, :multipart_client, :log
|
6
8
|
|
7
|
-
# @param [CheckoutConfiguration] configuration
|
8
|
-
# @param [String] uri
|
9
9
|
def initialize(configuration, uri)
|
10
10
|
@client = configuration.http_client.clone
|
11
11
|
@client.url_prefix = uri
|
@@ -14,42 +14,27 @@ module CheckoutSdk
|
|
14
14
|
@log = configuration.logger
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
# @param [SdkAuthorization] authorization
|
19
|
-
# @param [Object] params
|
20
|
-
def invoke_get(path,
|
21
|
-
authorization,
|
22
|
-
params = nil)
|
17
|
+
def invoke_get(path, authorization, params = nil)
|
23
18
|
invoke(:get, path, authorization, params: params)
|
24
19
|
end
|
25
20
|
|
26
|
-
def invoke_post(path,
|
27
|
-
authorization,
|
28
|
-
request = nil,
|
29
|
-
idempotency_key = nil)
|
21
|
+
def invoke_post(path, authorization, request = nil, idempotency_key = nil)
|
30
22
|
invoke(:post, path, authorization, request, idempotency_key)
|
31
23
|
end
|
32
24
|
|
33
|
-
def invoke_put(path,
|
34
|
-
authorization,
|
35
|
-
request)
|
25
|
+
def invoke_put(path, authorization, request)
|
36
26
|
invoke(:put, path, authorization, request)
|
37
27
|
end
|
38
28
|
|
39
|
-
def invoke_patch(path,
|
40
|
-
authorization,
|
41
|
-
request = nil)
|
29
|
+
def invoke_patch(path, authorization, request = nil)
|
42
30
|
invoke(:patch, path, authorization, request)
|
43
31
|
end
|
44
32
|
|
45
|
-
def invoke_delete(path,
|
46
|
-
authorization)
|
33
|
+
def invoke_delete(path, authorization)
|
47
34
|
invoke(:delete, path, authorization)
|
48
35
|
end
|
49
36
|
|
50
|
-
def submit_file(path,
|
51
|
-
authorization,
|
52
|
-
request)
|
37
|
+
def submit_file(path, authorization, request)
|
53
38
|
upload(path, authorization, request)
|
54
39
|
end
|
55
40
|
|
@@ -58,7 +43,7 @@ module CheckoutSdk
|
|
58
43
|
def invoke(method, path, authorization, body = nil, idempotency_key = nil, params: nil)
|
59
44
|
path = append_params(path, params) unless params.nil?
|
60
45
|
|
61
|
-
headers =
|
46
|
+
headers = default_headers(authorization)
|
62
47
|
headers[:'Content-Type'] = 'application/json'
|
63
48
|
headers[:'Cko-Idempotency-Key'] = idempotency_key unless idempotency_key.nil?
|
64
49
|
|
@@ -71,26 +56,23 @@ module CheckoutSdk
|
|
71
56
|
raise CheckoutApiException, e.response
|
72
57
|
end
|
73
58
|
|
74
|
-
parse_response
|
59
|
+
parse_response(response)
|
75
60
|
end
|
76
61
|
|
77
|
-
def
|
78
|
-
{
|
79
|
-
|
80
|
-
Accept: 'application/json',
|
81
|
-
Authorization: authorization.authorization_header
|
82
|
-
}
|
62
|
+
def default_headers(authorization)
|
63
|
+
{ 'User-Agent': "checkout-sdk-ruby/#{VERSION}", Accept: 'application/json',
|
64
|
+
Authorization: authorization.authorization_header }
|
83
65
|
end
|
84
66
|
|
85
67
|
def append_params(path, input_params)
|
86
68
|
raise CheckoutArgumentException, 'Query parameters were not provided' if input_params.nil?
|
87
69
|
|
88
|
-
if input_params.is_a? String
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
70
|
+
params = if input_params.is_a? String
|
71
|
+
input_params
|
72
|
+
else
|
73
|
+
hash = CheckoutSdk::JsonSerializer.to_custom_hash(input_params)
|
74
|
+
URI.encode_www_form(hash)
|
75
|
+
end
|
94
76
|
|
95
77
|
"#{path}?#{params}"
|
96
78
|
end
|
@@ -103,16 +85,16 @@ module CheckoutSdk
|
|
103
85
|
MIME::Types.type_for(file_request.file).first,
|
104
86
|
File.basename(file_request.file)
|
105
87
|
),
|
106
|
-
:
|
88
|
+
purpose: file_request.purpose
|
107
89
|
}
|
108
90
|
end
|
109
91
|
|
110
92
|
def upload(path, authorization, file_request)
|
111
|
-
headers =
|
93
|
+
headers = default_headers(authorization)
|
112
94
|
|
113
95
|
file = File.open(file_request.file)
|
114
96
|
|
115
|
-
form = build_multipart_request
|
97
|
+
form = build_multipart_request(file_request, file)
|
116
98
|
|
117
99
|
begin
|
118
100
|
@log.info "post: /#{path}"
|
@@ -123,28 +105,55 @@ module CheckoutSdk
|
|
123
105
|
file.close
|
124
106
|
end
|
125
107
|
|
126
|
-
parse_response
|
108
|
+
parse_response(response)
|
127
109
|
end
|
128
110
|
|
129
111
|
def parse_response(response)
|
130
|
-
raise CheckoutApiException, response if response.status < 200 || response.status >=
|
112
|
+
raise CheckoutApiException, response if response.status < 200 || response.status >= 300
|
131
113
|
|
132
114
|
metadata = CheckoutUtils.map_to_http_metadata(response)
|
133
|
-
body =
|
134
|
-
|
135
|
-
|
136
|
-
|
115
|
+
body = parse_body(response)
|
116
|
+
|
117
|
+
if body.is_a?(Array)
|
118
|
+
body = OpenStruct.new(items: body)
|
119
|
+
elsif !body.is_a?(OpenStruct)
|
120
|
+
body = OpenStruct.new(contents: body)
|
121
|
+
end
|
122
|
+
|
123
|
+
body.http_metadata = metadata if body.is_a?(OpenStruct)
|
124
|
+
|
137
125
|
body
|
126
|
+
rescue JSON::ParserError => e
|
127
|
+
raise CheckoutApiException.new(response, "Error parsing JSON: #{e.message}")
|
128
|
+
rescue StandardError => e
|
129
|
+
@log&.error("Unexpected error occurred: #{e.message}")
|
130
|
+
raise
|
138
131
|
end
|
139
132
|
|
140
|
-
def
|
141
|
-
|
133
|
+
def parse_body(response)
|
134
|
+
content_type = response.headers['Content-Type']
|
135
|
+
return OpenStruct.new if response.body.nil? || response.body.empty?
|
142
136
|
|
143
|
-
if
|
144
|
-
JSON.parse(response.body
|
137
|
+
if content_type&.include?('application/json')
|
138
|
+
parsed_value = JSON.parse(response.body)
|
139
|
+
deep_convert_to_ostruct(parsed_value)
|
140
|
+
elsif content_type&.include?('text/csv')
|
141
|
+
csv_data = CSV.parse(response.body, headers: true)
|
142
|
+
OpenStruct.new(csv: csv_data)
|
145
143
|
else
|
146
144
|
OpenStruct.new(contents: response.body)
|
147
145
|
end
|
148
146
|
end
|
147
|
+
|
148
|
+
def deep_convert_to_ostruct(obj)
|
149
|
+
case obj
|
150
|
+
when Hash
|
151
|
+
OpenStruct.new(obj.transform_values { |value| deep_convert_to_ostruct(value) })
|
152
|
+
when Array
|
153
|
+
obj.map { |item| deep_convert_to_ostruct(item) }
|
154
|
+
else
|
155
|
+
obj
|
156
|
+
end
|
157
|
+
end
|
149
158
|
end
|
150
159
|
end
|