Skip to content

Commit 630fd87

Browse files
[PAY-5294] - Add support for $wager event type and new $transaction fields
2 parents c41008a + ba7af16 commit 630fd87

File tree

9 files changed

+385
-6
lines changed

9 files changed

+385
-6
lines changed

CHANGES.MD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
3.17.0 (2024-11-15)
2+
=================
3+
- Added support for `$wager` event type in Events API
4+
- Added support for `$minimum_deposit_amount`, `$maximum_deposit_amount`,
5+
`$minimum_withdrawal_amount`, `$maximum_withdrawal_amount`, `$current_balance`,
6+
and `$new_balance` fields to `$transaction` events
7+
18
3.16.0 (2024-09-26)
29
=================
310
- Added support for `$iata_carrier_code` to the `$booking` complex field

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Java 1.7 or later.
1313
<dependency>
1414
<groupId>com.siftscience</groupId>
1515
<artifactId>sift-java</artifactId>
16-
<version>3.16.0</version>
16+
<version>3.17.0</version>
1717
</dependency>
1818
```
1919
### Gradle
2020
```
2121
dependencies {
22-
compile 'com.siftscience:sift-java:3.16.0'
22+
compile 'com.siftscience:sift-java:3.17.0'
2323
}
2424
```
2525
### Other

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'signing'
55
apply plugin: 'java-library-distribution'
66

77
group = 'com.siftscience'
8-
version = '3.16.0'
8+
version = '3.17.0'
99

1010
repositories {
1111
mavenCentral()

src/main/java/com/siftscience/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
public class Constants {
44

55
public static final String API_VERSION = "v205";
6-
public static final String LIB_VERSION = "3.16.0";
6+
public static final String LIB_VERSION = "3.17.0";
77
public static final String USER_AGENT_HEADER = String.format("SiftScience/%s sift-java/%s", API_VERSION, LIB_VERSION);
88
}

src/main/java/com/siftscience/model/TransactionFieldSet.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public class TransactionFieldSet extends BaseAppBrowserSiteBrandFieldSet<Transac
3131
@Expose @SerializedName("$digital_orders") private List<DigitalOrder> digitalOrders;
3232
@Expose @SerializedName("$receiver_wallet_address") private String receiverWalletAddress;
3333
@Expose @SerializedName("$receiver_external_address") private Boolean receiverExternalAddress;
34+
@Expose @SerializedName("$minimum_deposit_amount") private Long minimumDepositAmount;
35+
@Expose @SerializedName("$maximum_deposit_amount") private Long maximumDepositAmount;
36+
@Expose @SerializedName("$minimum_withdrawal_amount") private Long minimumWithdrawalAmount;
37+
@Expose @SerializedName("$maximum_withdrawal_amount") private Long maximumWithdrawalAmount;
38+
@Expose @SerializedName("$current_balance") private Long currentBalance;
39+
@Expose @SerializedName("$new_balance") private Long newBalance;
3440

3541

3642
@Override
@@ -258,4 +264,58 @@ public TransactionFieldSet setReceiverExternalAddress(Boolean receiverExternalAd
258264
this.receiverExternalAddress = receiverExternalAddress;
259265
return this;
260266
}
267+
268+
public Long getMinimumDepositAmount() {
269+
return minimumDepositAmount;
270+
}
271+
272+
public TransactionFieldSet setMinimumDepositAmount(Long minimumDepositAmount) {
273+
this.minimumDepositAmount = minimumDepositAmount;
274+
return this;
275+
}
276+
277+
public Long getMaximumDepositAmount() {
278+
return maximumDepositAmount;
279+
}
280+
281+
public TransactionFieldSet setMaximumDepositAmount(Long maximumDepositAmount) {
282+
this.maximumDepositAmount = maximumDepositAmount;
283+
return this;
284+
}
285+
286+
public Long getMinimumWithdrawalAmount() {
287+
return minimumWithdrawalAmount;
288+
}
289+
290+
public TransactionFieldSet setMinimumWithdrawalAmount(Long minimumWithdrawalAmount) {
291+
this.minimumWithdrawalAmount = minimumWithdrawalAmount;
292+
return this;
293+
}
294+
295+
public Long getMaximumWithdrawalAmount() {
296+
return maximumWithdrawalAmount;
297+
}
298+
299+
public TransactionFieldSet setMaximumWithdrawalAmount(Long maximumWithdrawalAmount) {
300+
this.maximumWithdrawalAmount = maximumWithdrawalAmount;
301+
return this;
302+
}
303+
304+
public Long getCurrentBalance() {
305+
return currentBalance;
306+
}
307+
308+
public TransactionFieldSet setCurrentBalance(Long currentBalance) {
309+
this.currentBalance = currentBalance;
310+
return this;
311+
}
312+
313+
public Long getNewBalance() {
314+
return newBalance;
315+
}
316+
317+
public TransactionFieldSet setNewBalance(Long newBalance) {
318+
this.newBalance = newBalance;
319+
return this;
320+
}
261321
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package com.siftscience.model;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public class WagerFieldSet extends EventsApiRequestFieldSet<WagerFieldSet> {
7+
8+
@Expose @SerializedName("$wager_id") private String wagerId;
9+
@Expose @SerializedName("$wager_type") private String wagerType;
10+
@Expose @SerializedName("$wager_status") private String wagerStatus;
11+
@Expose @SerializedName("$amount") private Long amount;
12+
@Expose @SerializedName("$currency_code") private String currencyCode;
13+
@Expose @SerializedName("$wager_event_type") private String wagerEventType;
14+
@Expose @SerializedName("$wager_event_name") private String wagerEventName;
15+
@Expose @SerializedName("$wager_event_id") private String wagerEventId;
16+
@Expose @SerializedName("$minimum_wager_amount") private Long minimumWagerAmount;
17+
18+
@Override
19+
public String getEventType() {
20+
return "$wager";
21+
}
22+
23+
public static WagerFieldSet fromJson(String json) {
24+
return gson.fromJson(json, WagerFieldSet.class);
25+
}
26+
27+
public String getWagerId() {
28+
return wagerId;
29+
}
30+
31+
public WagerFieldSet setWagerId(String wagerId) {
32+
this.wagerId = wagerId;
33+
return this;
34+
}
35+
36+
public String getWagerType() {
37+
return wagerType;
38+
}
39+
40+
public WagerFieldSet setWagerType(String wagerType) {
41+
this.wagerType = wagerType;
42+
return this;
43+
}
44+
45+
public String getWagerStatus() {
46+
return wagerStatus;
47+
}
48+
49+
public WagerFieldSet setWagerStatus(String wagerStatus) {
50+
this.wagerStatus = wagerStatus;
51+
return this;
52+
}
53+
54+
public Long getAmount() {
55+
return amount;
56+
}
57+
58+
public WagerFieldSet setAmount(Long amount) {
59+
this.amount = amount;
60+
return this;
61+
}
62+
63+
public String getCurrencyCode() {
64+
return currencyCode;
65+
}
66+
67+
public WagerFieldSet setCurrencyCode(String currencyCode) {
68+
this.currencyCode = currencyCode;
69+
return this;
70+
}
71+
72+
public String getWagerEventType() {
73+
return wagerEventType;
74+
}
75+
76+
public WagerFieldSet setWagerEventType(String wagerEventType) {
77+
this.wagerEventType = wagerEventType;
78+
return this;
79+
}
80+
81+
public String getWagerEventName() {
82+
return wagerEventName;
83+
}
84+
85+
public WagerFieldSet setWagerEventName(String wagerEventName) {
86+
this.wagerEventName = wagerEventName;
87+
return this;
88+
}
89+
90+
public String getWagerEventId() {
91+
return wagerEventId;
92+
}
93+
94+
public WagerFieldSet setWagerEventId(String wagerEventId) {
95+
this.wagerEventId = wagerEventId;
96+
return this;
97+
}
98+
99+
public Long getMinimumWagerAmount() {
100+
return minimumWagerAmount;
101+
}
102+
103+
public WagerFieldSet setMinimumWagerAmount(Long minimumWagerAmount) {
104+
this.minimumWagerAmount = minimumWagerAmount;
105+
return this;
106+
}
107+
}

src/test/java/com/siftscience/SiftRequestTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void testUserAgentHeader() throws Exception {
3737

3838
// Verify the request.
3939
RecordedRequest recordedRequest = server.takeRequest();
40-
Assert.assertEquals("SiftScience/v205 sift-java/3.16.0", recordedRequest.getHeader("User-Agent"));
40+
Assert.assertEquals("SiftScience/v205 sift-java/3.17.0", recordedRequest.getHeader("User-Agent"));
4141
}
4242

4343
@Test

src/test/java/com/siftscience/TransactionEventTest.java

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.List;
77

88
import com.siftscience.model.DigitalOrder;
9-
import com.siftscience.model.PaymentMethod;
109
import com.siftscience.model.TransactionFieldSet;
1110
import okhttp3.OkHttpClient;
1211
import okhttp3.mockwebserver.MockResponse;
@@ -667,4 +666,132 @@ public void testTransactionEventWithCryptoFields() throws Exception {
667666

668667
server.shutdown();
669668
}
669+
670+
@Test
671+
public void testTransactionEventWithExtraDepositFields() throws Exception {
672+
String expectedRequestBody = "{\n" +
673+
" \"$type\" : \"$transaction\",\n" +
674+
" \"$api_key\" : \"YOUR_API_KEY\",\n" +
675+
" \"$user_id\" : \"billy_jones_301\",\n" +
676+
" \"$amount\" : 500000,\n" +
677+
" \"$currency_code\" : \"USD\",\n" +
678+
" \"$transaction_type\" : \"$deposit\",\n" +
679+
" \"$transaction_id\" : \"719637215\",\n" +
680+
" \"$minimum_deposit_amount\" : 5000,\n" +
681+
" \"$maximum_deposit_amount\" : 100000000,\n" +
682+
" \"$current_balance\" : 500000,\n" +
683+
" \"$new_balance\" : 1000000,\n" +
684+
"}";
685+
686+
// Start a new mock server and enqueue a mock response.
687+
MockWebServer server = new MockWebServer();
688+
MockResponse response = new MockResponse();
689+
response.setResponseCode(HTTP_OK);
690+
response.setBody("{\n" +
691+
" \"status\" : 0,\n" +
692+
" \"error_message\" : \"OK\",\n" +
693+
" \"time\" : 1327604222,\n" +
694+
" \"request\" : \"" + TestUtils.unescapeJson(expectedRequestBody) + "\"\n" +
695+
"}");
696+
server.enqueue(response);
697+
server.start();
698+
699+
// Create a new client and link it to the mock server.
700+
SiftClient client = new SiftClient("YOUR_API_KEY", "YOUR_ACCOUNT_ID",
701+
new OkHttpClient.Builder()
702+
.addInterceptor(OkHttpUtils.urlRewritingInterceptor(server))
703+
.build());
704+
705+
// Build and execute the request against the mock server.
706+
EventRequest request = client.buildRequest(new TransactionFieldSet()
707+
.setUserId("billy_jones_301")
708+
.setAmount(500000L)
709+
.setCurrencyCode("USD")
710+
.setTransactionType("$deposit")
711+
.setTransactionId("719637215")
712+
.setMinimumDepositAmount(5000L)
713+
.setMaximumDepositAmount(100000000L)
714+
.setCurrentBalance(500000L)
715+
.setNewBalance(1000000L));
716+
717+
EventResponse siftResponse = request.send();
718+
719+
// Verify the request.
720+
RecordedRequest request1 = server.takeRequest();
721+
Assert.assertEquals("POST", request1.getMethod());
722+
Assert.assertEquals("/v205/events", request1.getPath());
723+
JSONAssert.assertEquals(expectedRequestBody, request.getFieldSet().toJson(), true);
724+
725+
// Verify the response.
726+
Assert.assertEquals(HTTP_OK, siftResponse.getHttpStatusCode());
727+
Assert.assertEquals(0, (int) siftResponse.getBody().getStatus());
728+
JSONAssert.assertEquals(response.getBody().readUtf8(),
729+
siftResponse.getBody().toJson(), true);
730+
731+
server.shutdown();
732+
}
733+
734+
@Test
735+
public void testTransactionEventWithExtraWithdrawalFields() throws Exception {
736+
String expectedRequestBody = "{\n" +
737+
" \"$type\" : \"$transaction\",\n" +
738+
" \"$api_key\" : \"YOUR_API_KEY\",\n" +
739+
" \"$user_id\" : \"billy_jones_301\",\n" +
740+
" \"$amount\" : 500000,\n" +
741+
" \"$currency_code\" : \"USD\",\n" +
742+
" \"$transaction_type\" : \"$withdrawal\",\n" +
743+
" \"$transaction_id\" : \"719637215\",\n" +
744+
" \"$minimum_withdrawal_amount\" : 5000,\n" +
745+
" \"$maximum_withdrawal_amount\" : 100000000,\n" +
746+
" \"$current_balance\" : 1000000,\n" +
747+
" \"$new_balance\" : 500000,\n" +
748+
"}";
749+
750+
// Start a new mock server and enqueue a mock response.
751+
MockWebServer server = new MockWebServer();
752+
MockResponse response = new MockResponse();
753+
response.setResponseCode(HTTP_OK);
754+
response.setBody("{\n" +
755+
" \"status\" : 0,\n" +
756+
" \"error_message\" : \"OK\",\n" +
757+
" \"time\" : 1327604222,\n" +
758+
" \"request\" : \"" + TestUtils.unescapeJson(expectedRequestBody) + "\"\n" +
759+
"}");
760+
server.enqueue(response);
761+
server.start();
762+
763+
// Create a new client and link it to the mock server.
764+
SiftClient client = new SiftClient("YOUR_API_KEY", "YOUR_ACCOUNT_ID",
765+
new OkHttpClient.Builder()
766+
.addInterceptor(OkHttpUtils.urlRewritingInterceptor(server))
767+
.build());
768+
769+
// Build and execute the request against the mock server.
770+
EventRequest request = client.buildRequest(new TransactionFieldSet()
771+
.setUserId("billy_jones_301")
772+
.setAmount(500000L)
773+
.setCurrencyCode("USD")
774+
.setTransactionType("$withdrawal")
775+
.setTransactionId("719637215")
776+
.setMinimumWithdrawalAmount(5000L)
777+
.setMaximumWithdrawalAmount(100000000L)
778+
.setCurrentBalance(1000000L)
779+
.setNewBalance(500000L));
780+
781+
EventResponse siftResponse = request.send();
782+
783+
// Verify the request.
784+
RecordedRequest request1 = server.takeRequest();
785+
Assert.assertEquals("POST", request1.getMethod());
786+
Assert.assertEquals("/v205/events", request1.getPath());
787+
JSONAssert.assertEquals(expectedRequestBody, request.getFieldSet().toJson(), true);
788+
789+
// Verify the response.
790+
Assert.assertEquals(HTTP_OK, siftResponse.getHttpStatusCode());
791+
Assert.assertEquals(0, (int) siftResponse.getBody().getStatus());
792+
JSONAssert.assertEquals(response.getBody().readUtf8(),
793+
siftResponse.getBody().toJson(), true);
794+
795+
server.shutdown();
796+
}
670797
}

0 commit comments

Comments
 (0)