Skip to content

Commit 12fb38d

Browse files
authored
Merge pull request #37 from maxmind/horgh/new-outputs-and-event-type
Add support for /device/local_time and /credit_card/is_virtual outputs, and new /event/type value
2 parents 9ebef61 + 341e676 commit 12fb38d

10 files changed

Lines changed: 80 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ CHANGELOG
1212
* `DALENYS`
1313
* `ONEY`
1414
* `POSCONNECT`
15+
* Added new type to the `Event.Type` enum: `PAYOUT_CHANGE`
16+
* Added support for new Device output:
17+
* `/device/local_time`
18+
* Added support for new CreditCard output:
19+
* `/credit_card/is_virtual`
1520

1621
1.8.0 (2018-01-19)
1722
------------------

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@
4242
<dependency>
4343
<groupId>com.fasterxml.jackson.core</groupId>
4444
<artifactId>jackson-core</artifactId>
45-
<version>2.9.3</version>
45+
<version>2.9.5</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>com.fasterxml.jackson.core</groupId>
4949
<artifactId>jackson-databind</artifactId>
50-
<version>2.9.3</version>
50+
<version>2.9.5</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>com.fasterxml.jackson.core</groupId>
5454
<artifactId>jackson-annotations</artifactId>
55-
<version>2.9.3</version>
55+
<version>2.9.5</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>com.maxmind.geoip2</groupId>
@@ -62,7 +62,7 @@
6262
<dependency>
6363
<groupId>org.apache.httpcomponents</groupId>
6464
<artifactId>httpclient</artifactId>
65-
<version>4.5.4</version>
65+
<version>4.5.5</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>commons-validator</groupId>
@@ -78,7 +78,7 @@
7878
<dependency>
7979
<groupId>com.github.tomakehurst</groupId>
8080
<artifactId>wiremock</artifactId>
81-
<version>2.14.0</version>
81+
<version>2.16.0</version>
8282
<scope>test</scope>
8383
</dependency>
8484
<dependency>
@@ -96,7 +96,7 @@
9696
<dependency>
9797
<groupId>com.fasterxml.jackson.jr</groupId>
9898
<artifactId>jackson-jr-objects</artifactId>
99-
<version>2.9.3</version>
99+
<version>2.9.5</version>
100100
<scope>test</scope>
101101
</dependency>
102102
<dependency>

src/main/java/com/maxmind/minfraud/request/Event.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public enum Type {
120120
ACCOUNT_LOGIN,
121121
EMAIL_CHANGE,
122122
PASSWORD_RESET,
123+
PAYOUT_CHANGE,
123124
PURCHASE,
124125
RECURRING_PURCHASE,
125126
REFERRAL,

src/main/java/com/maxmind/minfraud/response/CreditCard.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,43 @@ public final class CreditCard extends AbstractModel {
1212
private final String country;
1313
private final Boolean isIssuedInBillingAddressCountry;
1414
private final Boolean isPrepaid;
15+
private final Boolean isVirtual;
1516
private final String type;
1617

18+
// This method is for backwards compatibility. We should remove it when we
19+
// do a major release.
20+
public CreditCard(
21+
String brand,
22+
String country,
23+
Boolean isIssuedInBillingAddressCountry,
24+
Boolean isPrepaid,
25+
Issuer issuer,
26+
String type
27+
) {
28+
this(brand, country, isIssuedInBillingAddressCountry, isPrepaid, false,
29+
issuer, type);
30+
}
31+
1732
public CreditCard(
1833
@JsonProperty("brand") String brand,
1934
@JsonProperty("country") String country,
2035
@JsonProperty("is_issued_in_billing_address_country") Boolean isIssuedInBillingAddressCountry,
2136
@JsonProperty("is_prepaid") Boolean isPrepaid,
37+
@JsonProperty("is_virtual") Boolean isVirtual,
2238
@JsonProperty("issuer") Issuer issuer,
2339
@JsonProperty("type") String type
2440
) {
2541
this.brand = brand;
2642
this.country = country;
2743
this.isIssuedInBillingAddressCountry = isIssuedInBillingAddressCountry;
2844
this.isPrepaid = isPrepaid;
45+
this.isVirtual = isVirtual;
2946
this.issuer = issuer == null ? new Issuer() : issuer;
3047
this.type = type;
3148
}
3249

3350
public CreditCard() {
34-
this(null, null, null, null, null, null);
51+
this(null, null, null, null, null, null, null);
3552
}
3653

3754
/**
@@ -49,7 +66,7 @@ public String getBrand() {
4966
}
5067

5168
/**
52-
* @return The two letter <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">
69+
* @return The two letter <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">
5370
* ISO 3166-1 alpha-2</a> country code associated with the location
5471
* of the majority of customers using this credit card as determined
5572
* by their billing address. In cases where the location of customers
@@ -80,6 +97,15 @@ public Boolean isPrepaid() {
8097
return isPrepaid;
8198
}
8299

100+
/**
101+
* @return True if the card is a virtual card. False if not virtual. If the
102+
* IIN was not provided or is unknown, null will be returned.
103+
*/
104+
@JsonProperty("is_virtual")
105+
public Boolean isVirtual() {
106+
return isVirtual;
107+
}
108+
83109
/**
84110
* @return The credit card type.
85111
*/

src/main/java/com/maxmind/minfraud/response/Device.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,32 @@ public final class Device extends AbstractModel {
1717
private final Double confidence;
1818
private final UUID id;
1919
private final String lastSeen;
20+
private final String localTime;
21+
22+
// This method is for backwards compatibility. We should remove it when we
23+
// do a major release.
24+
public Device(
25+
Double confidence,
26+
UUID id,
27+
String lastSeen
28+
) {
29+
this(confidence, id, lastSeen, null);
30+
}
2031

2132
public Device(
2233
@JsonProperty("confidence") Double confidence,
2334
@JsonProperty("id") UUID id,
24-
@JsonProperty("last_seen") String lastSeen
35+
@JsonProperty("last_seen") String lastSeen,
36+
@JsonProperty("local_time") String localTime
2537
) {
2638
this.confidence = confidence;
2739
this.id = id;
2840
this.lastSeen = lastSeen;
41+
this.localTime = localTime;
2942
}
3043

3144
public Device() {
32-
this(null, null, null);
45+
this(null, null, null, null);
3346
}
3447

3548
/**
@@ -59,4 +72,13 @@ public UUID getId() {
5972
public String getLastSeen() {
6073
return lastSeen;
6174
}
75+
76+
/**
77+
* @return The date and time of the transaction at the UTC offset
78+
* associated with the device. This is an RFC 3339 date-time.
79+
*/
80+
@JsonProperty("local_time")
81+
public String getLocalTime() {
82+
return localTime;
83+
}
6284
}

src/test/java/com/maxmind/minfraud/WebServiceClientTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.jcabi.matchers.RegexMatchers.matchesPattern;
2323
import static com.maxmind.minfraud.request.RequestTestHelper.*;
2424
import static org.hamcrest.core.StringStartsWith.startsWith;
25+
import static org.junit.Assert.assertEquals;
2526
import static org.junit.Assert.assertFalse;
2627
import static org.junit.Assert.assertTrue;
2728

@@ -79,6 +80,10 @@ public void testFullInsightsTransaction() throws Exception {
7980
assertTrue(
8081
"response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return true",
8182
response.getIpAddress().getRepresentedCountry().isInEuropeanUnion());
83+
assertEquals(response.getDevice().getLocalTime(),
84+
"2018-04-05T15:34:40-07:00");
85+
86+
assertTrue(response.getCreditCard().isVirtual());
8287
}
8388
}
8489

src/test/java/com/maxmind/minfraud/request/EventTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ public void testTime() throws Exception {
3333
public void testType() throws Exception {
3434
Event event = new Builder().type(Type.ACCOUNT_CREATION).build();
3535
assertEquals(Type.ACCOUNT_CREATION, event.getType());
36+
37+
event = new Builder().type(Type.PAYOUT_CHANGE).build();
38+
assertEquals(Type.PAYOUT_CHANGE, event.getType());
3639
}
37-
}
40+
}

src/test/java/com/maxmind/minfraud/response/CreditCardTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public void testCreditCard() throws Exception {
2222
.put("country", "US")
2323
.put("is_issued_in_billing_address_country", true)
2424
.put("is_prepaid", true)
25+
.put("is_virtual", true)
2526
.put("type", "credit")
2627
.end()
2728
.finish()
@@ -32,6 +33,7 @@ public void testCreditCard() throws Exception {
3233
assertEquals("Visa", cc.getBrand());
3334
assertEquals("credit", cc.getType());
3435
assertTrue(cc.isPrepaid());
36+
assertTrue(cc.isVirtual());
3537
assertTrue(cc.isIssuedInBillingAddressCountry());
3638
}
3739

src/test/java/com/maxmind/minfraud/response/DeviceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ public void testDevice() throws Exception {
1919
.put("confidence", 99)
2020
.put("id", "C8D3BE1A-BE26-11E5-8C50-1B575C37265F")
2121
.put("last_seen", "2016-06-08T14:16:38Z")
22+
.put("local_time", "2018-04-05T15:21:00-07:00")
2223
.end()
2324
.finish()
2425
);
2526

2627
assertEquals(99.0, device.getConfidence(), 1e-15);
2728
assertEquals(UUID.fromString("C8D3BE1A-BE26-11E5-8C50-1B575C37265F"), device.getId());
2829
assertEquals("2016-06-08T14:16:38Z", device.getLastSeen());
30+
assertEquals("2018-04-05T15:21:00-07:00", device.getLocalTime());
2931
}
3032
}

src/test/resources/test-data/insights-response.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@
130130
"country": "US",
131131
"is_issued_in_billing_address_country": true,
132132
"is_prepaid": true,
133+
"is_virtual": true,
133134
"type": "credit"
134135
},
135136
"device": {
136137
"confidence": 99,
137138
"id": "7835b099-d385-4e5b-969e-7df26181d73b",
138-
"last_seen": "2016-06-08T14:16:38Z"
139+
"last_seen": "2016-06-08T14:16:38Z",
140+
"local_time": "2018-04-05T15:34:40-07:00"
139141
},
140142
"disposition": {
141143
"action": "reject",

0 commit comments

Comments
 (0)