Skip to content

Commit 901ea47

Browse files
committed
Merge pull request #10 from maxmind/greg/more-device-outputs
More device outputs
2 parents f5e5e07 + 746a843 commit 901ea47

11 files changed

Lines changed: 63 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
* Added `getQueriesRemaining()` and `getFundsRemaining()`. Note that
1010
`getFundsRemaining()` will not be returned by the web service until our new
1111
credit system is in place.
12+
* Added `getLastSeen()` and `getConfidence()` to the `Device` response model.
1213
* This API now throws an `IllegalArgumentException` when `null` values are
1314
passed to constructors or methods that require non-null values.
1415

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
* Billing and Shipping.
99
*/
1010
public abstract class AbstractLocation extends AbstractModel {
11-
protected String firstName;
12-
protected String lastName;
13-
protected String company;
14-
protected String address;
15-
protected String address2;
16-
protected String city;
17-
protected String region;
18-
protected String country;
19-
protected String postal;
20-
protected String phoneNumber;
21-
protected String phoneCountryCode;
11+
private final String firstName;
12+
private final String lastName;
13+
private final String company;
14+
private final String address;
15+
private final String address2;
16+
private final String city;
17+
private final String region;
18+
private final String country;
19+
private final String postal;
20+
private final String phoneNumber;
21+
private final String phoneCountryCode;
2222

2323
protected AbstractLocation(AbstractLocation.Builder builder) {
2424
firstName = builder.firstName;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.maxmind.minfraud.AbstractModel;
55

6-
import java.text.ParseException;
76
import java.text.SimpleDateFormat;
87
import java.util.Date;
98

@@ -30,7 +29,6 @@ public static final class Builder {
3029
String shopId;
3130
Date time;
3231
Type type;
33-
SimpleDateFormat dateFormat;
3432

3533
/**
3634
* @param id Your internal ID for the transaction. We can use this to

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public final class Payment extends AbstractModel {
1111
private final Boolean wasAuthorized;
1212
private final String declineCode;
1313

14-
public Payment(Payment.Builder builder) {
14+
private Payment(Payment.Builder builder) {
1515
processor = builder.processor;
1616
wasAuthorized = builder.wasAuthorized;
1717
declineCode = builder.declineCode;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public final class Transaction extends AbstractModel {
2121
private final Shipping shipping;
2222
private final List<ShoppingCartItem> shoppingCart;
2323

24-
protected Transaction(Transaction.Builder builder) {
24+
private Transaction(Transaction.Builder builder) {
2525
account = builder.account;
2626
billing = builder.billing;
2727
creditCard = builder.creditCard;
@@ -48,7 +48,7 @@ public static class Builder {
4848
Order order;
4949
Payment payment;
5050
Shipping shipping;
51-
List<ShoppingCartItem> shoppingCart = new ArrayList<>();
51+
final List<ShoppingCartItem> shoppingCart = new ArrayList<>();
5252

5353
/**
5454
* The constructor for {@code Builder}

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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,57 @@
77

88
/**
99
* This class contains minFraud response data related to the device.
10+
*
11+
* In order to receive device output from minFraud Insights or minFraud
12+
* Factors, you must be using the Device Tracking Add-on.
13+
*
14+
* @see <a href="https://dev.maxmind.com/minfraud/device/">Device Tracking Add-on</a>
15+
1016
*/
1117
public final class Device extends AbstractModel {
18+
private final Double confidence;
1219
private final UUID id;
20+
private final String lastSeen;
1321

1422
public Device(
15-
@JsonProperty("id") UUID id
23+
@JsonProperty("confidence") Double confidence,
24+
@JsonProperty("id") UUID id,
25+
@JsonProperty("last_seen") String lastSeen
1626
) {
27+
this.confidence = confidence;
1728
this.id = id;
29+
this.lastSeen = lastSeen;
1830
}
1931

2032
public Device() {
21-
this(null);
33+
this(null, null, null);
34+
}
35+
36+
/**
37+
* @return a number representing the confidence that the device ID refers
38+
* to a unique device as opposed to a cluster of similar devices. A
39+
* confidence of 0.01 indicates very low confidence that the device is
40+
* unique, whereas 99 indicates very high confidence.
41+
*/
42+
public Double getConfidence() {
43+
return confidence;
2244
}
2345

2446
/**
25-
* @return The device id.
47+
* @return A UUID identifying the device associated with this IP address.
48+
* Note that many devices cannot be uniquely identified because they are too
49+
* common (for example, all iPhones of a given model and OS release).
2650
*/
2751
public UUID getId() {
2852
return id;
2953
}
54+
55+
/**
56+
* @return The date and time of the last sighting of the device. This is an
57+
* RFC 3339 date-time.
58+
*/
59+
@JsonProperty("last_seen")
60+
public String getLastSeen() {
61+
return lastSeen;
62+
}
3063
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
public class WebServiceClientTest {
2424

2525
@Rule
26-
public ExpectedException thrown = ExpectedException.none();
26+
public final ExpectedException thrown = ExpectedException.none();
2727

2828
@Rule
29-
public WireMockRule wireMockRule = new WireMockRule(0); // 0 picks random port
29+
public final WireMockRule wireMockRule = new WireMockRule(0); // 0 picks random port
3030

3131
@Test
3232
public void testFullScoreTransaction() throws Exception {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ public void testDevice() throws Exception {
1616
JSON.std
1717
.composeString()
1818
.startObject()
19+
.put("confidence", 99)
1920
.put("id", "C8D3BE1A-BE26-11E5-8C50-1B575C37265F")
21+
.put("last_seen", "2016-06-08T14:16:38Z")
2022
.end()
2123
.finish()
2224
);
2325

26+
assertEquals(99.0, device.getConfidence(), 1e-15);
2427
assertEquals(UUID.fromString("C8D3BE1A-BE26-11E5-8C50-1B575C37265F"), device.getId());
28+
assertEquals("2016-06-08T14:16:38Z", device.getLastSeen());
2529
}
2630
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ public class SubscoresTest extends AbstractOutputTest {
99

1010
@Test
1111
public void testSubscores() throws Exception {
12-
String phone = "132-342-2131";
13-
1412
Subscores subscores = this.deserialize(
1513
Subscores.class,
1614
JSON.std

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111
"type": "credit"
112112
},
113113
"device": {
114-
"id": "7835b099-d385-4e5b-969e-7df26181d73b"
114+
"confidence": 99,
115+
"id": "7835b099-d385-4e5b-969e-7df26181d73b",
116+
"last_seen": "2016-06-08T14:16:38Z"
115117
},
116118
"email": {
117119
"is_free": true,

0 commit comments

Comments
 (0)