Skip to content

Commit 53e081b

Browse files
committed
Add support for the /device/local_time output
1 parent 1b7ed09 commit 53e081b

5 files changed

Lines changed: 33 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ CHANGELOG
1313
* `ONEY`
1414
* `POSCONNECT`
1515
* Added new type to the `Event.Type` enum: `PAYOUT_CHANGE`
16+
* Added support for new Device output:
17+
* `/device/local_time`
1618

1719
1.8.0 (2018-01-19)
1820
------------------

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: 3 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,8 @@ 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");
8285
}
8386
}
8487

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135
"device": {
136136
"confidence": 99,
137137
"id": "7835b099-d385-4e5b-969e-7df26181d73b",
138-
"last_seen": "2016-06-08T14:16:38Z"
138+
"last_seen": "2016-06-08T14:16:38Z",
139+
"local_time": "2018-04-05T15:34:40-07:00"
139140
},
140141
"disposition": {
141142
"action": "reject",

0 commit comments

Comments
 (0)