Skip to content

Commit 3c1925a

Browse files
committed
Add /device/session_age, /device/session_id and /email/first_seen
1 parent 55c1065 commit 3c1925a

5 files changed

Lines changed: 84 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
* Added support for new Device inputs. These are:
5+
* `/device/session_age`
6+
* `/device/session_id`
7+
* Added support for new Email outputs. These are:
8+
* `/email/first_seen`
9+
410
1.4.0 (2017-02-22)
511
------------------
612

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ public final class Device extends AbstractModel {
1212
private final InetAddress ipAddress;
1313
private final String userAgent;
1414
private final String acceptLanguage;
15+
private final Float sessionAge;
16+
private final String sessionId;
1517

1618
private Device(Device.Builder builder) {
1719
ipAddress = builder.ipAddress;
1820
userAgent = builder.userAgent;
1921
acceptLanguage = builder.acceptLanguage;
22+
sessionAge = builder.sessionAge;
23+
sessionId = builder.sessionId;
2024
}
2125

2226
/**
@@ -27,6 +31,8 @@ public static final class Builder {
2731
InetAddress ipAddress;
2832
String userAgent;
2933
String acceptLanguage;
34+
Float sessionAge;
35+
String sessionId;
3036

3137
/**
3238
* The constructor for the {@code Device.Builder} class
@@ -62,6 +68,28 @@ public Device.Builder acceptLanguage(String acceptLanguage) {
6268
return this;
6369
}
6470

71+
/**
72+
* @param sessionAge A floating point number. The number of seconds
73+
* between the creation of the user's session and
74+
* the time of the transaction. Note that session_age
75+
* is not the duration of the current visit, but
76+
* the time since the start of the first visit.
77+
* @return The builder object.
78+
*/
79+
public Device.Builder sessionAge(Float sessionAge) { this.sessionAge =
80+
sessionAge; return this; }
81+
82+
/**
83+
* @param sessionId A string up to 255 characters in length. This is
84+
* an ID which uniquely identifies a visitor's
85+
* session on the site.
86+
* @return The builder object.
87+
*/
88+
public Device.Builder sessionId(String sessionId) {
89+
this.sessionId = sessionId;
90+
return this;
91+
}
92+
6593
/**
6694
* @return An instance of {@code Device} created from the
6795
* fields set on this builder.
@@ -87,6 +115,22 @@ public String getAcceptLanguage() {
87115
return acceptLanguage;
88116
}
89117

118+
/**
119+
* @return The session age.
120+
*/
121+
@JsonProperty("session_age")
122+
public Float getSessionAge() {
123+
return sessionAge;
124+
}
125+
126+
/**
127+
* @return The session id.
128+
*/
129+
@JsonProperty("session_id")
130+
public String getSessionId() {
131+
return sessionId;
132+
}
133+
90134
/**
91135
* @return The IP address used in the transaction.
92136
*/

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@
99
public final class Email extends AbstractModel {
1010
private final Boolean isFree;
1111
private final Boolean isHighRisk;
12+
private final String firstSeen;
1213

1314
public Email(
1415
@JsonProperty("is_free") Boolean isFree,
15-
@JsonProperty("is_high_risk") Boolean isHighRisk
16+
@JsonProperty("is_high_risk") Boolean isHighRisk,
17+
@JsonProperty("first_seen") String firstSeen
1618
) {
1719
this.isFree = isFree;
1820
this.isHighRisk = isHighRisk;
21+
this.firstSeen = firstSeen;
1922
}
2023

2124
public Email() {
22-
this(null, null);
25+
this(null, null, null);
2326
}
2427

2528
/**
@@ -37,4 +40,14 @@ public Boolean isFree() {
3740
public Boolean isHighRisk() {
3841
return isHighRisk;
3942
}
43+
44+
/**
45+
* @return A date string (e.g. 2017-04-24) to identify the date an email
46+
* address was first seen by MaxMind. This is expressed using the
47+
* ISO 8601 date format.
48+
*/
49+
@JsonProperty("first_seen")
50+
public String firstSeen() {
51+
return firstSeen;
52+
}
4053
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,19 @@ public void testAcceptLanguage() throws Exception {
3535
Device device = new Builder(ip).acceptLanguage(al).build();
3636
assertEquals(al, device.getAcceptLanguage());
3737
}
38-
}
38+
39+
40+
@Test
41+
public void testSessionAge() throws Exception {
42+
Float hour = (float) 3600;
43+
Device device = new Builder(ip).sessionAge(hour).build();
44+
assertEquals(hour, device.getSessionAge());
45+
}
46+
47+
@Test
48+
public void testSessionId() throws Exception {
49+
String id = "foobar";
50+
Device device = new Builder(ip).sessionId(id).build();
51+
assertEquals(id, device.getSessionId());
52+
}
53+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.jr.ob.JSON;
44
import org.junit.Test;
55

6+
import static org.junit.Assert.assertEquals;
67
import static org.junit.Assert.assertFalse;
78
import static org.junit.Assert.assertTrue;
89

@@ -17,11 +18,13 @@ public void testEmail() throws Exception {
1718
.startObject()
1819
.put("is_free", false)
1920
.put("is_high_risk", true)
21+
.put("first_seen", "2017-01-02")
2022
.end()
2123
.finish()
2224
);
2325

2426
assertFalse(email.isFree());
2527
assertTrue(email.isHighRisk());
28+
assertEquals(email.firstSeen(),"2017-01-02");
2629
}
2730
}

0 commit comments

Comments
 (0)