adyen-ruby-api-library 6.3.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Makefile +72 -0
- data/README.md +20 -18
- data/lib/adyen/client.rb +66 -38
- data/lib/adyen/services/balanceControlService.rb +28 -0
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +63 -0
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +123 -0
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +51 -0
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +75 -0
- data/lib/adyen/services/balancePlatform/platform_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +63 -0
- data/lib/adyen/services/balancePlatform.rb +61 -0
- data/lib/adyen/services/binLookup.rb +40 -0
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +39 -0
- data/lib/adyen/services/checkout/modifications_api.rb +87 -0
- data/lib/adyen/services/checkout/orders_api.rb +51 -0
- data/lib/adyen/services/checkout/payment_links_api.rb +51 -0
- data/lib/adyen/services/checkout/payments_api.rb +87 -0
- data/lib/adyen/services/checkout/recurring_api.rb +39 -0
- data/lib/adyen/services/checkout/utility_api.rb +39 -0
- data/lib/adyen/services/checkout.rb +38 -211
- data/lib/adyen/services/dataProtection.rb +28 -0
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +75 -0
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement.rb +51 -0
- data/lib/adyen/services/management/account_company_level_api.rb +51 -0
- data/lib/adyen/services/management/account_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/account_store_level_api.rb +111 -0
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +63 -0
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/my_api_credential_api.rb +75 -0
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +87 -0
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +75 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +111 -0
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +63 -0
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/users_company_level_api.rb +63 -0
- data/lib/adyen/services/management/users_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/webhooks_company_level_api.rb +99 -0
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +99 -0
- data/lib/adyen/services/management.rb +151 -0
- data/lib/adyen/services/payment.rb +172 -0
- data/lib/adyen/services/payout/initialization_api.rb +51 -0
- data/lib/adyen/services/payout/instant_payouts_api.rb +27 -0
- data/lib/adyen/services/payout/reviewing_api.rb +39 -0
- data/lib/adyen/services/payout.rb +31 -0
- data/lib/adyen/services/posTerminalManagement.rb +76 -0
- data/lib/adyen/services/recurring.rb +81 -13
- data/lib/adyen/services/service.rb +2 -2
- data/lib/adyen/services/storedValue.rb +88 -0
- data/lib/adyen/services/transfers/transactions_api.rb +39 -0
- data/lib/adyen/services/transfers/transfers_api.rb +27 -0
- data/lib/adyen/services/transfers.rb +26 -0
- data/lib/adyen/version.rb +1 -1
- data/lib/adyen-ruby-api-library.rb +11 -5
- data/spec/account_spec.rb +1 -1
- data/spec/balance_control_spec.rb +44 -0
- data/spec/balance_platform_spec.rb +123 -0
- data/spec/bin_lookup_spec.rb +68 -10
- data/spec/checkout_spec.rb +39 -66
- data/spec/client_spec.rb +88 -9
- data/spec/fund_spec.rb +1 -1
- data/spec/hop_spec.rb +1 -1
- data/spec/lem_spec.rb +68 -0
- data/spec/management_spec.rb +68 -0
- data/spec/mocks/requests/BalanceControl/balance_transfer.json +10 -0
- data/spec/mocks/requests/BalancePlatform/create_account_holder.json +5 -0
- data/spec/mocks/requests/BalancePlatform/update_account_holder.json +10 -0
- data/spec/mocks/requests/LegalEntityManagement/create_business_line.json +15 -0
- data/spec/mocks/requests/Management/create_store.json +15 -0
- data/spec/mocks/requests/Recurring/create_permit.json +6 -0
- data/spec/mocks/requests/StoredValue/issue_giftcard.json +12 -0
- data/spec/mocks/requests/Transfers/get_transactions.json +82 -0
- data/spec/mocks/requests/Transfers/make_transfer.json +32 -0
- data/spec/mocks/responses/BalanceControl/balance_transfer.json +14 -0
- data/spec/mocks/responses/BalancePlatform/create_account_holder.json +41 -0
- data/spec/mocks/responses/BalancePlatform/get_balance_account.json +15 -0
- data/spec/mocks/responses/BalancePlatform/update_account_holder.json +16 -0
- data/spec/mocks/responses/LegalEntityManagement/create_business_line.json +17 -0
- data/spec/mocks/responses/Management/create_store.json +23 -0
- data/spec/mocks/responses/Management/get_companies.json +42 -0
- data/spec/mocks/responses/Recurring/create_permit.json +4 -0
- data/spec/mocks/responses/StoredValue/issue_giftcard.json +13 -0
- data/spec/mocks/responses/Transfers/get_transactions.json +82 -0
- data/spec/mocks/responses/Transfers/make_transfer.json +36 -0
- data/spec/notification_spec.rb +1 -1
- data/spec/payments_spec.rb +41 -23
- data/spec/payouts_spec.rb +43 -16
- data/spec/pos_terminal_management_spec.rb +46 -0
- data/spec/recurring_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/stored_value_spec.rb +43 -0
- data/spec/transfers_spec.rb +63 -0
- data/templates/api-single.mustache +29 -0
- data/templates/api-small.mustache +37 -0
- data/templates/api.mustache +36 -0
- data/templates/config.yaml +10 -0
- metadata +101 -11
- data/lib/adyen/services/bin_lookup.rb +0 -18
- data/lib/adyen/services/data_protection.rb +0 -17
- data/lib/adyen/services/payments.rb +0 -34
- data/lib/adyen/services/payouts.rb +0 -22
- data/lib/adyen/services/postfmapi.rb +0 -19
- data/spec/mocks/requests/Recurring/store_token.json +0 -15
- data/spec/mocks/responses/Recurring/store_token.json +0 -7
- data/spec/postfmapi_spec.rb +0 -16
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative './service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class StoredValue < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
DEFAULT_VERSION = 46
|
8
|
+
|
9
|
+
def initialize(client, version = DEFAULT_VERSION)
|
10
|
+
@service = "StoredValue"
|
11
|
+
@client = client
|
12
|
+
@version = version
|
13
|
+
end
|
14
|
+
|
15
|
+
def change_status(request, headers: {} )
|
16
|
+
"""
|
17
|
+
Changes the status of the payment method.
|
18
|
+
"""
|
19
|
+
endpoint = "/changeStatus".gsub(/{.+?}/, '%s')
|
20
|
+
endpoint = endpoint.gsub(/^\//, "")
|
21
|
+
endpoint = endpoint % []
|
22
|
+
|
23
|
+
action = { method: "post", url: endpoint}
|
24
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_balance(request, headers: {} )
|
28
|
+
"""
|
29
|
+
Checks the balance.
|
30
|
+
"""
|
31
|
+
endpoint = "/checkBalance".gsub(/{.+?}/, '%s')
|
32
|
+
endpoint = endpoint.gsub(/^\//, "")
|
33
|
+
endpoint = endpoint % []
|
34
|
+
|
35
|
+
action = { method: "post", url: endpoint}
|
36
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
37
|
+
end
|
38
|
+
|
39
|
+
def issue(request, headers: {} )
|
40
|
+
"""
|
41
|
+
Issues a new card.
|
42
|
+
"""
|
43
|
+
endpoint = "/issue".gsub(/{.+?}/, '%s')
|
44
|
+
endpoint = endpoint.gsub(/^\//, "")
|
45
|
+
endpoint = endpoint % []
|
46
|
+
|
47
|
+
action = { method: "post", url: endpoint}
|
48
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
49
|
+
end
|
50
|
+
|
51
|
+
def load(request, headers: {} )
|
52
|
+
"""
|
53
|
+
Loads the payment method.
|
54
|
+
"""
|
55
|
+
endpoint = "/load".gsub(/{.+?}/, '%s')
|
56
|
+
endpoint = endpoint.gsub(/^\//, "")
|
57
|
+
endpoint = endpoint % []
|
58
|
+
|
59
|
+
action = { method: "post", url: endpoint}
|
60
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def merge_balance(request, headers: {} )
|
64
|
+
"""
|
65
|
+
Merge the balance of two cards.
|
66
|
+
"""
|
67
|
+
endpoint = "/mergeBalance".gsub(/{.+?}/, '%s')
|
68
|
+
endpoint = endpoint.gsub(/^\//, "")
|
69
|
+
endpoint = endpoint % []
|
70
|
+
|
71
|
+
action = { method: "post", url: endpoint}
|
72
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
73
|
+
end
|
74
|
+
|
75
|
+
def void_transaction(request, headers: {} )
|
76
|
+
"""
|
77
|
+
Voids a transaction.
|
78
|
+
"""
|
79
|
+
endpoint = "/voidTransaction".gsub(/{.+?}/, '%s')
|
80
|
+
endpoint = endpoint.gsub(/^\//, "")
|
81
|
+
endpoint = endpoint % []
|
82
|
+
|
83
|
+
action = { method: "post", url: endpoint}
|
84
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class TransactionsApi < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
@service = "Transfers"
|
10
|
+
@client = client
|
11
|
+
@version = version
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_all_transactions(headers: {} , queryParams: {})
|
15
|
+
"""
|
16
|
+
Get all transactions
|
17
|
+
"""
|
18
|
+
endpoint = "/transactions".gsub(/{.+?}/, '%s')
|
19
|
+
endpoint = endpoint.gsub(/^\//, "")
|
20
|
+
endpoint = endpoint % []
|
21
|
+
endpoint = endpoint + create_query_string(queryParams)
|
22
|
+
action = { method: "get", url: endpoint}
|
23
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_transaction(id, headers: {} )
|
27
|
+
"""
|
28
|
+
Get a transaction
|
29
|
+
"""
|
30
|
+
endpoint = "/transactions/{id}".gsub(/{.+?}/, '%s')
|
31
|
+
endpoint = endpoint.gsub(/^\//, "")
|
32
|
+
endpoint = endpoint % [id]
|
33
|
+
|
34
|
+
action = { method: "get", url: endpoint}
|
35
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class TransfersApi < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
@service = "Transfers"
|
10
|
+
@client = client
|
11
|
+
@version = version
|
12
|
+
end
|
13
|
+
|
14
|
+
def transfer_funds(request, headers: {} )
|
15
|
+
"""
|
16
|
+
Transfer funds
|
17
|
+
"""
|
18
|
+
endpoint = "/transfers".gsub(/{.+?}/, '%s')
|
19
|
+
endpoint = endpoint.gsub(/^\//, "")
|
20
|
+
endpoint = endpoint % []
|
21
|
+
|
22
|
+
action = { method: "post", url: endpoint}
|
23
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'transfers/transactions_api'
|
2
|
+
require_relative 'transfers/transfers_api'
|
3
|
+
|
4
|
+
module Adyen
|
5
|
+
|
6
|
+
|
7
|
+
class Transfers
|
8
|
+
attr_accessor :service, :version
|
9
|
+
|
10
|
+
DEFAULT_VERSION = 3
|
11
|
+
def initialize(client, version = DEFAULT_VERSION)
|
12
|
+
@service = "Transfers"
|
13
|
+
@client = client
|
14
|
+
@version = version
|
15
|
+
end
|
16
|
+
|
17
|
+
def transactions_api
|
18
|
+
@transactions_api ||= Adyen::TransactionsApi.new(@client, @version)
|
19
|
+
end
|
20
|
+
|
21
|
+
def transfers_api
|
22
|
+
@transfers_api ||= Adyen::TransfersApi.new(@client, @version)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/adyen/version.rb
CHANGED
@@ -2,14 +2,20 @@ require_relative "adyen/version"
|
|
2
2
|
require_relative "adyen/client"
|
3
3
|
require_relative "adyen/errors"
|
4
4
|
require_relative "adyen/services/checkout"
|
5
|
-
require_relative "adyen/services/
|
6
|
-
require_relative "adyen/services/
|
5
|
+
require_relative "adyen/services/payment"
|
6
|
+
require_relative "adyen/services/payout"
|
7
7
|
require_relative "adyen/services/recurring"
|
8
8
|
require_relative "adyen/services/marketpay"
|
9
|
-
require_relative "adyen/services/
|
9
|
+
require_relative "adyen/services/posTerminalManagement"
|
10
10
|
require_relative "adyen/services/service"
|
11
|
-
require_relative "adyen/services/
|
11
|
+
require_relative "adyen/services/dataProtection"
|
12
12
|
require_relative "adyen/services/dispute"
|
13
|
-
require_relative "adyen/services/
|
13
|
+
require_relative "adyen/services/binLookup"
|
14
14
|
require_relative "adyen/hash_with_accessors"
|
15
15
|
require_relative "adyen/utils/hmac_validator"
|
16
|
+
require_relative "adyen/services/legalEntityManagement"
|
17
|
+
require_relative "adyen/services/balancePlatform"
|
18
|
+
require_relative "adyen/services/transfers"
|
19
|
+
require_relative "adyen/services/management"
|
20
|
+
require_relative "adyen/services/storedValue"
|
21
|
+
require_relative "adyen/services/balanceControlService"
|
data/spec/account_spec.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::BalancePlatform, service: "balancePlatform" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "BalancePlatform",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a balance transfer POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BalanceControl/balance_transfer.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/BalanceControl/balance_transfer.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "balanceTransfer", @shared_values[:client].balance_control_service.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].balance_control_service.balance_transfer(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::BalancePlatform, service: "balancePlatform" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "BalancePlatform",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a account_holder POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BalancePlatform/create_account_holder.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/BalancePlatform/create_account_holder.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "accountHolders", @shared_values[:client].balance_platform.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].balance_platform.account_holders_api.create_account_holder(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
|
45
|
+
it "makes a account_holder PATCH call" do
|
46
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BalancePlatform/update_account_holder.json"))
|
47
|
+
|
48
|
+
response_body = json_from_file("mocks/responses/BalancePlatform/update_account_holder.json")
|
49
|
+
|
50
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "accountHolders/AH3227C223222C5GKR23686TF", @shared_values[:client].balance_platform.version)
|
51
|
+
WebMock.stub_request(:patch, url).
|
52
|
+
with(
|
53
|
+
body: request_body,
|
54
|
+
headers: {
|
55
|
+
"x-api-key" => @shared_values[:client].api_key
|
56
|
+
}
|
57
|
+
).
|
58
|
+
to_return(
|
59
|
+
body: response_body
|
60
|
+
)
|
61
|
+
|
62
|
+
result = @shared_values[:client].balance_platform.account_holders_api.update_account_holder(request_body, id = "AH3227C223222C5GKR23686TF")
|
63
|
+
response_hash = result.response
|
64
|
+
|
65
|
+
expect(result.status).
|
66
|
+
to eq(200)
|
67
|
+
expect(response_hash).
|
68
|
+
to eq(JSON.parse(response_body))
|
69
|
+
expect(response_hash).
|
70
|
+
to be_a Adyen::HashWithAccessors
|
71
|
+
expect(response_hash).
|
72
|
+
to be_a_kind_of Hash
|
73
|
+
end
|
74
|
+
|
75
|
+
it "makes a balance_account GET call" do
|
76
|
+
|
77
|
+
response_body = json_from_file("mocks/responses/BalancePlatform/get_balance_account.json")
|
78
|
+
|
79
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "balanceAccounts/BA3227C223222B5BLP6JQC3FD", @shared_values[:client].balance_platform.version)
|
80
|
+
WebMock.stub_request(:get, url).
|
81
|
+
with(
|
82
|
+
headers: {
|
83
|
+
"x-api-key" => @shared_values[:client].api_key
|
84
|
+
}
|
85
|
+
).
|
86
|
+
to_return(
|
87
|
+
body: response_body
|
88
|
+
)
|
89
|
+
|
90
|
+
result = @shared_values[:client].balance_platform.balance_accounts_api.get_balance_account(id = "BA3227C223222B5BLP6JQC3FD")
|
91
|
+
response_hash = result.response
|
92
|
+
|
93
|
+
expect(result.status).
|
94
|
+
to eq(200)
|
95
|
+
expect(response_hash).
|
96
|
+
to eq(JSON.parse(response_body))
|
97
|
+
expect(response_hash).
|
98
|
+
to be_a Adyen::HashWithAccessors
|
99
|
+
expect(response_hash).
|
100
|
+
to be_a_kind_of Hash
|
101
|
+
end
|
102
|
+
|
103
|
+
it "makes a balance_account/sweeps DELETE call" do
|
104
|
+
|
105
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "balanceAccounts/balanceAccountID/sweeps/sweepID", @shared_values[:client].balance_platform.version)
|
106
|
+
WebMock.stub_request(:delete, url).
|
107
|
+
with(
|
108
|
+
headers: {
|
109
|
+
"x-api-key" => @shared_values[:client].api_key
|
110
|
+
}
|
111
|
+
).
|
112
|
+
to_return(
|
113
|
+
body: "{}"
|
114
|
+
)
|
115
|
+
|
116
|
+
result = @shared_values[:client].balance_platform.balance_accounts_api.delete_sweep("balanceAccountID", "sweepID")
|
117
|
+
response_hash = result.response
|
118
|
+
|
119
|
+
expect(result.status).
|
120
|
+
to eq(200)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
data/spec/bin_lookup_spec.rb
CHANGED
@@ -1,15 +1,73 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "json"
|
2
3
|
|
3
|
-
|
4
|
-
# client instance to be used in dynamically generated tests
|
5
|
-
client = create_client(:basic)
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
RSpec.describe Adyen::BinLookup, service: "BinLookup" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "BinLookup",
|
11
|
+
}
|
12
|
+
end
|
13
13
|
|
14
|
-
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a get_cost_estimate POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BinLookup/get_cost_estimate.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/BinLookup/get_cost_estimate.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "getCostEstimate", @shared_values[:client].bin_lookup.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].bin_lookup.get_cost_estimate(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
it "makes a get3ds_availability POST call" do
|
45
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BinLookup/get_3ds_availability.json"))
|
46
|
+
|
47
|
+
response_body = json_from_file("mocks/responses/BinLookup/get_3ds_availability.json")
|
48
|
+
|
49
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "get3dsAvailability", @shared_values[:client].bin_lookup.version)
|
50
|
+
WebMock.stub_request(:post, url).
|
51
|
+
with(
|
52
|
+
body: request_body,
|
53
|
+
headers: {
|
54
|
+
"x-api-key" => @shared_values[:client].api_key
|
55
|
+
}
|
56
|
+
).
|
57
|
+
to_return(
|
58
|
+
body: response_body
|
59
|
+
)
|
60
|
+
|
61
|
+
result = @shared_values[:client].bin_lookup.get3ds_availability(request_body)
|
62
|
+
response_hash = result.response
|
63
|
+
|
64
|
+
expect(result.status).
|
65
|
+
to eq(200)
|
66
|
+
expect(response_hash).
|
67
|
+
to eq(JSON.parse(response_body))
|
68
|
+
expect(response_hash).
|
69
|
+
to be_a Adyen::HashWithAccessors
|
70
|
+
expect(response_hash).
|
71
|
+
to be_a_kind_of Hash
|
72
|
+
end
|
15
73
|
end
|