Skip to content

Commit c26456b

Browse files
authored
Replace Dispute service with the automatically generated Disputes ser… (#184)
* Replace Dispute service with the automatically generated Disputes service, update Readme, replace tests * adjust disputes tests
1 parent 4d0aefa commit c26456b

18 files changed

+208
-126
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ openapi-generator-cli:=java -jar build/openapi-generator-cli.jar
66
output:=build/out
77

88
services:=balancePlatform checkout legalEntityManagement management payout transfers
9-
singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue payment posTerminalManagement
9+
singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue payment posTerminalManagement disputes
1010

1111
binLookup: spec=BinLookupService-v54
1212
checkout: spec=CheckoutService-v70
@@ -21,6 +21,7 @@ legalEntityManagement: spec=LegalEntityService-v3
2121
balancePlatform: spec=BalancePlatformService-v2
2222
balanceControlService: spec=BalanceControlService-v1
2323
transfers: spec=TransferService-v3
24+
disputes: spec=DisputeService-v30
2425

2526
allServices: $(services) $(singleFileServices)
2627

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ This is the officially supported Ruby library for using Adyen's APIs.
77

88
This library supports the following:
99

10-
| API name | API version | Description | API object |
11-
|----------|:-----------:|-------------|------------|
12-
| [BIN lookup API](https://docs.adyen.com/api-explorer/BinLookup/54/overview) | v54 | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | [BinLookup](lib/adyen/services/binLookup.rb) |
13-
| [Checkout API](https://docs.adyen.com/api-explorer/Checkout/70/overview) | v70 | Our latest integration for accepting online payments. | [CheckoutAPI](lib/adyen/services/checkout.rb) |
14-
| [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/2/overview) | v2 | The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | [BalancePlatform](lib/adyen/services/balancePlatform.rb) |
15-
| [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | v1 | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | [DataProtection](lib/adyen/services/dataProtection.rb) |
16-
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](lib/adyen/services/legalEntityManagement.rb) |
17-
| [Management API](https://docs.adyen.com/api-explorer/Management/1/overview) | v1 | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | [Management](lib/adyen/services/management.rb) |
18-
| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | v68 | Our classic integration for online payments. | [Classic Integration API](lib/adyen/services/payment.rb) |
19-
| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](lib/adyen/services/payout.rb) |
20-
| [POS Terminal Management API](https://docs.adyen.com/api-explorer/postfmapi/1/overview) | v1 | Endpoints for managing your point-of-sale payment terminals. | [TerminalManagement](lib/adyen/services/posTerminalManagement.rb) |
21-
| [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
22-
| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | v46 | Manage both online and point-of-sale gift cards and other stored-value cards. | [StoredValue](lib/adyen/services/storedValue.rb) |
23-
| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | v3 | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | [Transfers](lib/adyen/services/transfers.rb) |
24-
| [Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/terminal-api-reference/) | - | Our point-of-sale integration. | [TerminalCloudAPI](lib/adyen/services/terminalCloudAPI.rb) |
10+
| API name | API version | Description | API object |
11+
|-------------------------------------------------------------------------------------------------------------------------------|:-----------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
12+
| [BIN lookup API](https://docs.adyen.com/api-explorer/BinLookup/54/overview) | v54 | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | [BinLookup](lib/adyen/services/binLookup.rb) |
13+
| [Checkout API](https://docs.adyen.com/api-explorer/Checkout/70/overview) | v70 | Our latest integration for accepting online payments. | [CheckoutAPI](lib/adyen/services/checkout.rb) |
14+
| [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/2/overview) | v2 | The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | [BalancePlatform](lib/adyen/services/balancePlatform.rb) |
15+
| [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | v1 | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | [DataProtection](lib/adyen/services/dataProtection.rb) |
16+
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](lib/adyen/services/legalEntityManagement.rb) |
17+
| [Management API](https://docs.adyen.com/api-explorer/Management/1/overview) | v1 | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | [Management](lib/adyen/services/management.rb) |
18+
| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | v68 | Our classic integration for online payments. | [Classic Integration API](lib/adyen/services/payment.rb) |
19+
| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](lib/adyen/services/payout.rb) |
20+
| [POS Terminal Management API](https://docs.adyen.com/api-explorer/postfmapi/1/overview) | v1 | Endpoints for managing your point-of-sale payment terminals. | [TerminalManagement](lib/adyen/services/posTerminalManagement.rb) |
21+
| [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
22+
| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | v46 | Manage both online and point-of-sale gift cards and other stored-value cards. | [StoredValue](lib/adyen/services/storedValue.rb) |
23+
| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | v3 | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | [Transfers](lib/adyen/services/transfers.rb) |
24+
| [Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/terminal-api-reference/) | - | Our point-of-sale integration. | [TerminalCloudAPI](lib/adyen/services/terminalCloudAPI.rb) |
25+
| [Disputes API](https://docs.adyen.com/api-explorer/Disputes/30/overview) | v30 | You can use the [Disputes API](https://docs.adyen.com/risk-management/disputes-api) to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes. | [Disputes](lib/adyen/services/disputes.rb) |
2526

2627
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
2728

lib/adyen-ruby-api-library.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require_relative 'adyen/services/posTerminalManagement'
1010
require_relative 'adyen/services/service'
1111
require_relative 'adyen/services/dataProtection'
12-
require_relative 'adyen/services/dispute'
12+
require_relative 'adyen/services/disputes'
1313
require_relative 'adyen/services/binLookup'
1414
require_relative 'adyen/hash_with_accessors'
1515
require_relative 'adyen/utils/hmac_validator'

lib/adyen/client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def service_url_base(service)
6868
when 'PosTerminalManagement'
6969
url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
7070
supports_live_url_prefix = false
71-
when 'DataProtectionService', 'DisputeService'
71+
when 'DataProtectionService', 'DisputesService'
7272
url = "https://ca-#{@env}.adyen.com/ca/services/#{service}"
7373
supports_live_url_prefix = false
7474
when 'LegalEntityManagement'
@@ -243,8 +243,8 @@ def data_protection
243243
@data_protection ||= Adyen::DataProtection.new(self)
244244
end
245245

246-
def dispute
247-
@dispute ||= Adyen::Dispute.new(self)
246+
def disputes
247+
@disputes ||= Adyen::Disputes.new(self)
248248
end
249249

250250
def bin_lookup

lib/adyen/services/dispute.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/adyen/services/disputes.rb

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
require_relative './service'
2+
module Adyen
3+
class Disputes < Service
4+
attr_accessor :service, :version
5+
6+
DEFAULT_VERSION = 30
7+
def initialize(client, version = DEFAULT_VERSION)
8+
super(client, version, 'Disputes')
9+
end
10+
11+
def accept_dispute(request, headers: {})
12+
endpoint = '/acceptDispute'.gsub(/{.+?}/, '%s')
13+
endpoint = endpoint.gsub(%r{^/}, '')
14+
endpoint = format(endpoint)
15+
16+
action = { method: 'post', url: endpoint }
17+
@client.call_adyen_api(@service, action, request, headers, @version)
18+
end
19+
20+
def defend_dispute(request, headers: {})
21+
endpoint = '/defendDispute'.gsub(/{.+?}/, '%s')
22+
endpoint = endpoint.gsub(%r{^/}, '')
23+
endpoint = format(endpoint)
24+
25+
action = { method: 'post', url: endpoint }
26+
@client.call_adyen_api(@service, action, request, headers, @version)
27+
end
28+
29+
def delete_dispute_defense_document(request, headers: {})
30+
endpoint = '/deleteDisputeDefenseDocument'.gsub(/{.+?}/, '%s')
31+
endpoint = endpoint.gsub(%r{^/}, '')
32+
endpoint = format(endpoint)
33+
34+
action = { method: 'post', url: endpoint }
35+
@client.call_adyen_api(@service, action, request, headers, @version)
36+
end
37+
38+
def download_dispute_defense_document(request, headers: {})
39+
endpoint = '/downloadDisputeDefenseDocument'.gsub(/{.+?}/, '%s')
40+
endpoint = endpoint.gsub(%r{^/}, '')
41+
endpoint = format(endpoint)
42+
43+
action = { method: 'post', url: endpoint }
44+
@client.call_adyen_api(@service, action, request, headers, @version)
45+
end
46+
47+
def retrieve_applicable_defense_reasons(request, headers: {})
48+
endpoint = '/retrieveApplicableDefenseReasons'.gsub(/{.+?}/, '%s')
49+
endpoint = endpoint.gsub(%r{^/}, '')
50+
endpoint = format(endpoint)
51+
52+
action = { method: 'post', url: endpoint }
53+
@client.call_adyen_api(@service, action, request, headers, @version)
54+
end
55+
56+
def supply_defense_document(request, headers: {})
57+
endpoint = '/supplyDefenseDocument'.gsub(/{.+?}/, '%s')
58+
endpoint = endpoint.gsub(%r{^/}, '')
59+
endpoint = format(endpoint)
60+
61+
action = { method: 'post', url: endpoint }
62+
@client.call_adyen_api(@service, action, request, headers, @version)
63+
end
64+
65+
end
66+
end

spec/dispute_spec.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

spec/disputes_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require 'spec_helper'
2+
3+
RSpec.describe Adyen::Disputes, service: 'disputes service' do
4+
before(:all) do
5+
@shared_values = {
6+
client: create_client(:api_key),
7+
service: 'Disputes'
8+
}
9+
end
10+
11+
# methods / values to test for
12+
# format is defined in spec_helper
13+
it 'makes a retrieve_applicable_defense_reasons call' do
14+
request_body = JSON.parse(json_from_file('mocks/requests/DisputesService/retrieve_applicable_defense_reasons.json'))
15+
16+
response_body = json_from_file('mocks/responses/DisputesService/retrieve_applicable_defense_reasons.json')
17+
18+
url = @shared_values[:client].service_url(@shared_values[:service], 'retrieveApplicableDefenseReasons',
19+
@shared_values[:client].disputes.version)
20+
WebMock.stub_request(:post, url)
21+
.with(
22+
body: request_body,
23+
headers: {
24+
'x-api-key' => @shared_values[:client].api_key
25+
}
26+
)
27+
.to_return(
28+
body: response_body
29+
)
30+
31+
result = @shared_values[:client].disputes.retrieve_applicable_defense_reasons(request_body)
32+
response_hash = result.response
33+
34+
expect(result.status)
35+
.to eq(200)
36+
expect(response_hash)
37+
.to eq(JSON.parse(response_body))
38+
expect(response_hash)
39+
.to be_a Adyen::HashWithAccessors
40+
expect(response_hash)
41+
.to be_a_kind_of Hash
42+
expect(response_hash['disputeServiceResult']['success'])
43+
.to eq(true)
44+
end
45+
end

spec/mocks/requests/DisputeService/defend_dispute.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

spec/mocks/requests/DisputeService/delete_dispute_defense_document.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)