Skip to content

Commit 5d5e622

Browse files
authored
Added required attributes for company level webhook setup (#82)
1 parent bc26f64 commit 5d5e622

File tree

4 files changed

+83
-12
lines changed

4 files changed

+83
-12
lines changed

force-app/main/default/classes/WebhookSetupRequest.cls

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public with sharing class WebhookSetupRequest {
2222
@NamespaceAccessible
2323
public String encryptionProtocol { get; set; }
2424

25+
@NamespaceAccessible
26+
public String filterMerchantAccountType { get; set; }
27+
28+
@NamespaceAccessible
29+
public List<String> filterMerchantAccounts { get; set; }
30+
2531
@NamespaceAccessible
2632
public Boolean equals(Object obj) {
2733
if (obj == null || !(obj instanceof WebhookSetupRequest)) return false;
@@ -33,7 +39,9 @@ public with sharing class WebhookSetupRequest {
3339
&& this.communicationFormat == other.communicationFormat
3440
&& this.type == other.type
3541
&& this.encryptionProtocol == other.encryptionProtocol
36-
&& this.additionalSettings.equals(other.additionalSettings);
42+
&& this.filterMerchantAccountType == other.filterMerchantAccountType
43+
&& (this.filterMerchantAccounts != null ? this.filterMerchantAccounts.equals(other.filterMerchantAccounts) : other.filterMerchantAccounts == null)
44+
&& (this.additionalSettings != null ? this.additionalSettings.equals(other.additionalSettings) : other.additionalSettings == null);
3745
}
3846

3947
@NamespaceAccessible
@@ -45,6 +53,8 @@ public with sharing class WebhookSetupRequest {
4553
communicationFormat,
4654
type,
4755
encryptionProtocol,
56+
filterMerchantAccountType,
57+
filterMerchantAccounts,
4858
additionalSettings
4959
};
5060
return ApiLibUtils.computeHashCode(requestFields);
@@ -60,6 +70,8 @@ public with sharing class WebhookSetupRequest {
6070
example.type = 'standard';
6171
example.encryptionProtocol = 'TLSv1.3';
6272
example.description = 'Webhook for payment notifications';
73+
example.filterMerchantAccountType = 'includeAccounts';
74+
example.filterMerchantAccounts = new List<String>{'TestMerchantAccount'};
6375
example.additionalSettings = new AdditionalSettings();
6476
example.additionalSettings.includeEventCodes = new List<String>{
6577
AdyenConstants.NOTIFICATION_REQUEST_TYPE_AUTHORISE,
@@ -76,12 +88,14 @@ public with sharing class WebhookSetupRequest {
7688
public Boolean equals(Object obj) {
7789
if (obj == null || !(obj instanceof AdditionalSettings)) return false;
7890
AdditionalSettings other = (AdditionalSettings) obj;
79-
return this.includeEventCodes == other.includeEventCodes;
91+
return (this.includeEventCodes != null
92+
? this.includeEventCodes.equals(other.includeEventCodes)
93+
: other.includeEventCodes == null);
8094
}
8195

8296
public Integer hashCode() {
8397
return ApiLibUtils.computeHashCode(new List<Object>{ includeEventCodes });
8498
}
8599
}
86100

87-
}
101+
}

force-app/main/default/classes/WebhookSetupRequestTest.cls

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ private class WebhookSetupRequestTest {
88
Assert.isNotNull(request.communicationFormat);
99
Assert.isNotNull(request.type);
1010
Assert.isNotNull(request.encryptionProtocol);
11+
Assert.isNotNull(request.filterMerchantAccountType);
12+
Assert.isNotNull(request.filterMerchantAccounts);
1113
}
1214

1315
@IsTest
@@ -37,6 +39,20 @@ private class WebhookSetupRequestTest {
3739
Assert.isFalse(result, 'Expected WebhookSetupRequest objects to be different');
3840
}
3941

42+
@IsTest
43+
static void testEqualsFalseWithFilterMerchantAccounts() {
44+
// Given
45+
WebhookSetupRequest req1 = WebhookSetupRequest.getExample();
46+
WebhookSetupRequest req2 = WebhookSetupRequest.getExample();
47+
req2.filterMerchantAccounts = new List<String>{'AnotherAccount'};
48+
49+
// When
50+
Boolean result = req1.equals(req2);
51+
52+
// Then
53+
Assert.isFalse(result, 'Expected WebhookSetupRequest objects to be different due to filterMerchantAccounts');
54+
}
55+
4056
@IsTest
4157
static void testHashCodeSame() {
4258
// Given
@@ -65,4 +81,19 @@ private class WebhookSetupRequestTest {
6581
// Then
6682
Assert.areNotEqual(hashCode1, hashCode2, 'Expected different objects to have different hash codes');
6783
}
68-
}
84+
85+
@IsTest
86+
static void testHashCodeDifferentWithFilterMerchantAccounts() {
87+
// Given
88+
WebhookSetupRequest req1 = WebhookSetupRequest.getExample();
89+
WebhookSetupRequest req2 = WebhookSetupRequest.getExample();
90+
req2.filterMerchantAccounts = new List<String>{'AnotherAccount'};
91+
92+
// When
93+
Integer hashCode1 = req1.hashCode();
94+
Integer hashCode2 = req2.hashCode();
95+
96+
// Then
97+
Assert.areNotEqual(hashCode1, hashCode2, 'Expected different objects to have different hash codes due to filterMerchantAccounts');
98+
}
99+
}

force-app/main/default/classes/WebhookSetupResponse.cls

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public with sharing class WebhookSetupResponse {
2828
@NamespaceAccessible
2929
public AdditionalSettings additionalSettings { get; set; }
3030

31+
@NamespaceAccessible
32+
public String filterMerchantAccountType { get; set; }
33+
34+
@NamespaceAccessible
35+
public List<String> filterMerchantAccounts { get; set; }
36+
3137
@NamespaceAccessible
3238
public Boolean equals(Object obj) {
3339
if (obj == null || !(obj instanceof WebhookSetupResponse)) return false;
@@ -41,7 +47,9 @@ public with sharing class WebhookSetupResponse {
4147
&& this.type == other.type
4248
&& this.encryptionProtocol == other.encryptionProtocol
4349
&& this.hasError == other.hasError
44-
&& this.additionalSettings.equals(other.additionalSettings);
50+
&& this.filterMerchantAccountType == other.filterMerchantAccountType
51+
&& (this.filterMerchantAccounts != null ? this.filterMerchantAccounts.equals(other.filterMerchantAccounts) : other.filterMerchantAccounts == null)
52+
&& (this.additionalSettings != null ? this.additionalSettings.equals(other.additionalSettings) : other.additionalSettings == null);
4553
}
4654

4755

@@ -56,8 +64,9 @@ public with sharing class WebhookSetupResponse {
5664
type,
5765
encryptionProtocol,
5866
hasError,
59-
additionalSettings != null ? additionalSettings.includeEventCodes : null,
60-
additionalSettings != null ? additionalSettings.excludeEventCodes : null
67+
additionalSettings,
68+
filterMerchantAccountType,
69+
filterMerchantAccounts
6170
};
6271
return ApiLibUtils.computeHashCode(responseFields);
6372
}
@@ -73,6 +82,8 @@ public with sharing class WebhookSetupResponse {
7382
example.type = 'standard';
7483
example.encryptionProtocol = 'TLSv1.3';
7584
example.hasError = false;
85+
example.filterMerchantAccountType = 'includeAccounts';
86+
example.filterMerchantAccounts = new List<String>{'TestMerchantAccount'};
7687

7788
example.additionalSettings = new AdditionalSettings();
7889
example.additionalSettings.includeEventCodes = new List<String>{
@@ -94,8 +105,10 @@ public with sharing class WebhookSetupResponse {
94105
public Boolean equals(Object obj) {
95106
if (obj == null || !(obj instanceof AdditionalSettings)) return false;
96107
AdditionalSettings other = (AdditionalSettings) obj;
97-
return this.includeEventCodes == other.includeEventCodes
98-
&& this.excludeEventCodes == other.excludeEventCodes;
108+
Boolean includeCodesEqual = (this.includeEventCodes != null ? this.includeEventCodes.equals(other.includeEventCodes) : other.includeEventCodes == null);
109+
Boolean excludeCodesEqual = (this.excludeEventCodes != null ? this.excludeEventCodes.equals(other.excludeEventCodes) : other.excludeEventCodes == null);
110+
111+
return includeCodesEqual && excludeCodesEqual;
99112
}
100113

101114
public Integer hashCode() {
@@ -104,4 +117,4 @@ public with sharing class WebhookSetupResponse {
104117

105118
}
106119

107-
}
120+
}

force-app/main/default/classes/WebhookSetupResponseTest.cls

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
@IsTest
22
private class WebhookSetupResponseTest {
33

4+
@IsTest
5+
static void getExampleTest() {
6+
// When
7+
WebhookSetupResponse response = WebhookSetupResponse.getExample();
8+
9+
// Then
10+
Assert.isNotNull(response);
11+
Assert.isNotNull(response.id);
12+
Assert.isNotNull(response.url);
13+
Assert.isNotNull(response.filterMerchantAccountType);
14+
Assert.isNotNull(response.filterMerchantAccounts);
15+
}
16+
417
@IsTest
518
static void testEqualsTrue() {
619
// Given
@@ -33,7 +46,7 @@ private class WebhookSetupResponseTest {
3346
// Given
3447
WebhookSetupResponse res1 = WebhookSetupResponse.getExample();
3548
WebhookSetupResponse res2 = WebhookSetupResponse.getExample();
36-
49+
3750
res1.additionalSettings = new WebhookSetupResponse.AdditionalSettings();
3851
res1.additionalSettings.includeEventCodes = new List<String>{
3952
AdyenConstants.NOTIFICATION_REQUEST_TYPE_AUTHORISE,
@@ -59,7 +72,7 @@ private class WebhookSetupResponseTest {
5972
// Then
6073
Assert.areEqual(hashCode1, hashCode2, 'Expected identical objects to have the same hash code');
6174
}
62-
75+
6376
@IsTest
6477
static void testHashCodeDifferent() {
6578
// Given

0 commit comments

Comments
 (0)