File tree Expand file tree Collapse file tree
main/java/com/maxmind/minfraud/response
test/java/com/maxmind/minfraud/response Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ CHANGELOG
66
77* Added support for the new email output ` /email/domain/first_seen ` This can
88 be accessed via ` response.getEmail().getDomain().getFirstSeen() ` .
9+ * Added ` Device.getLastSeenDateTime() ` , ` Device.getLocalDateTime() ` ,
10+ ` Email.getFirstSeenDate() ` , and ` GeoIp2Location.getLocalDateTime() ` methods
11+ that return ` java.time ` objects rather than strings.
912
10131.11.0 (2020-02-21)
1114-------------------
Original file line number Diff line number Diff line change 11package com .maxmind .minfraud .response ;
22
3+ import com .fasterxml .jackson .annotation .JsonIgnore ;
34import com .fasterxml .jackson .annotation .JsonProperty ;
45import com .maxmind .minfraud .AbstractModel ;
56
7+ import java .time .ZonedDateTime ;
68import java .util .UUID ;
79
810/**
@@ -73,6 +75,18 @@ public String getLastSeen() {
7375 return lastSeen ;
7476 }
7577
78+ /**
79+ * @return The date and time of the last sighting of the device as a
80+ * {@code ZonedDateTime}.
81+ */
82+ @ JsonIgnore
83+ public ZonedDateTime getLastSeenDateTime () {
84+ if (lastSeen == null ) {
85+ return null ;
86+ }
87+ return ZonedDateTime .parse (lastSeen );
88+ }
89+
7690 /**
7791 * @return The date and time of the transaction at the UTC offset
7892 * associated with the device. This is an RFC 3339 date-time.
@@ -81,4 +95,16 @@ public String getLastSeen() {
8195 public String getLocalTime () {
8296 return localTime ;
8397 }
98+
99+ /**
100+ * @return The date and time of the transaction at the UTC offset
101+ * associated with the device as a {@code ZonedDateTime}.
102+ */
103+ @ JsonIgnore
104+ public ZonedDateTime getLocalDateTime () {
105+ if (localTime == null ) {
106+ return null ;
107+ }
108+ return ZonedDateTime .parse (localTime );
109+ }
84110}
Original file line number Diff line number Diff line change 11package com .maxmind .minfraud .response ;
22
3+ import com .fasterxml .jackson .annotation .JsonIgnore ;
34import com .fasterxml .jackson .annotation .JsonProperty ;
45import com .maxmind .minfraud .AbstractModel ;
56
7+ import java .time .LocalDate ;
8+
69/**
710 * This class contains minFraud response data related to the email address.
811 */
@@ -102,4 +105,16 @@ public Boolean isHighRisk() {
102105 public String getFirstSeen () {
103106 return firstSeen ;
104107 }
108+
109+ /**
110+ * @return A date to identify the date an email address was first seen by
111+ * MaxMind.
112+ */
113+ @ JsonIgnore
114+ public LocalDate getFirstSeenDate () {
115+ if (firstSeen == null ) {
116+ return null ;
117+ }
118+ return LocalDate .parse (firstSeen );
119+ }
105120}
Original file line number Diff line number Diff line change 11package com .maxmind .minfraud .response ;
22
3+ import com .fasterxml .jackson .annotation .JsonIgnore ;
34import com .fasterxml .jackson .annotation .JsonProperty ;
45import com .maxmind .geoip2 .record .Location ;
56
7+ import java .time .ZonedDateTime ;
8+
69/**
710 * This class contains minFraud response data related to the GeoIP2 Insights
811 * location.
@@ -38,4 +41,16 @@ public GeoIp2Location() {
3841 public String getLocalTime () {
3942 return this .localTime ;
4043 }
44+
45+ /**
46+ * @return The date and time of the transaction in the time zone associated
47+ * with the IP address as a {@code ZonedDateTime}.
48+ */
49+ @ JsonIgnore
50+ public ZonedDateTime getLocalDateTime () {
51+ if (localTime == null ) {
52+ return null ;
53+ }
54+ return ZonedDateTime .parse (localTime );
55+ }
4156}
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ public void testDevice() throws Exception {
2727 assertEquals (99.0 , device .getConfidence (), 1e-15 );
2828 assertEquals (UUID .fromString ("C8D3BE1A-BE26-11E5-8C50-1B575C37265F" ), device .getId ());
2929 assertEquals ("2016-06-08T14:16:38Z" , device .getLastSeen ());
30+ assertEquals ("2016-06-08T14:16:38Z" , device .getLastSeenDateTime ().toString ());
3031 assertEquals ("2018-04-05T15:21:00-07:00" , device .getLocalTime ());
32+ assertEquals ("2018-04-05T15:21:00-07:00" , device .getLocalDateTime ().toString ());
33+
3134 }
3235}
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ public void testEmail() throws Exception {
3131 assertFalse (email .isDisposable ());
3232 assertFalse (email .isFree ());
3333 assertTrue (email .isHighRisk ());
34- assertEquals (email .getFirstSeen (), "2017-01-02" );
34+ assertEquals ("2017-01-02" , email .getFirstSeen ());
35+ assertEquals (LocalDate .parse ("2017-01-02" ), email .getFirstSeenDate ());
3536 }
3637
3738 @ Test
@@ -51,5 +52,6 @@ public void testEmailWithoutFirstSeen() throws Exception {
5152 assertFalse (email .isFree ());
5253 assertTrue (email .isHighRisk ());
5354 assertNull (email .getFirstSeen ());
55+ assertNull (email .getFirstSeenDate ());
5456 }
5557}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ public void testGetLocalTime() throws Exception {
2020 .finish ()
2121 );
2222
23- assertEquals (location .getLocalTime (), time );
23+ assertEquals (time , location .getLocalTime ());
24+ assertEquals (time , location .getLocalDateTime ().toString ());
2425 }
2526}
You can’t perform that action at this time.
0 commit comments