Skip to content

Add /device/session_age, /device/session_id and /email/first_seen#25

Merged
oschwald merged 8 commits into
masterfrom
oalders/device-and-session-inputs
Jun 30, 2017
Merged

Add /device/session_age, /device/session_id and /email/first_seen#25
oschwald merged 8 commits into
masterfrom
oalders/device-and-session-inputs

Conversation

@oalders

@oalders oalders commented Jun 26, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@oalders
oalders force-pushed the oalders/device-and-session-inputs branch from 537520a to 3c1925a Compare June 26, 2017 22:49

@oschwald oschwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small comments.

* is not the duration of the current visit, but
* the time since the start of the first visit.
* @return The builder object.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use Double to store the session age. There probably isn't a need to repeat the type in the docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4f3c20e

* ISO 8601 date format.
*/
@JsonProperty("first_seen")
public String firstSeen() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be getFirstSeen() to follow the JavaBeans naming conventions used throughout. A Date might be a bit nicer, but it looks like we don't do that for /device/last_seen (probably for time zone reasons there) so maybe a string is best.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change this. Just wondering why the other methods in this class don't follow this same pattern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ef10959

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which ones? The rule is:

Getter
public T getP()
Boolean getter
public boolean isP()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now I understand the naming conventions. Thanks!


@Test
public void testSessionAge() throws Exception {
Float hour = (float) 3600;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than (float), you can just used 3600f (or 3600d for double).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4f3c20e


assertFalse(email.isFree());
assertTrue(email.isHighRisk());
assertEquals(email.firstSeen(),"2017-01-02");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add all the new fields to the JSON at https://github.com/maxmind/minfraud-api-java/tree/master/src/test/resources/test-data, which will test serialization and deserialization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ceb2df

@JsonProperty("is_free") Boolean isFree,
@JsonProperty("is_high_risk") Boolean isHighRisk
@JsonProperty("is_high_risk") Boolean isHighRisk,
@JsonProperty("first_seen") String firstSeen

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a breaking change. To prevent breakage, you should add another constructor with two arguments that calls this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that be something like this?

diff --git a/src/main/java/com/maxmind/minfraud/response/Email.java b/src/main/java/com/maxmind/minfraud/response/Email.java
index e281cd8..78d92c7 100644
--- a/src/main/java/com/maxmind/minfraud/response/Email.java
+++ b/src/main/java/com/maxmind/minfraud/response/Email.java
@@ -21,6 +21,13 @@ public final class Email extends AbstractModel {
         this.firstSeen = firstSeen;
     }

+    public Email(
+            @JsonProperty("is_free") Boolean isFree,
+            @JsonProperty("is_high_risk") Boolean isHighRisk
+    ) {
+        this(isFree,isHighRisk,null);
+    }
+
     public Email() {
         this(null, null, null);
     }

I'm getting

com.fasterxml.jackson.databind.JsonMappingException: Conflicting property-based creators: already had implicitly discovered creator [constructor for com.maxmind.minfraud.response.Email, annotations: [null]], encountered another: [constructor for com.maxmind.minfraud.response.Email, annotations: [null]]

@oschwald oschwald Jun 28, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the @JsonProperty for the old constructor. So something like:

    public Email(
            Boolean isFree,
            Boolean isHighRisk
    ) {
        this(isFree,isHighRisk,null);
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a change in 8ad2b57. It passes the tests, but the new test that I added passes even without the two argument constructor.

@oschwald oschwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One minor test change.

@@ -120,6 +120,7 @@
"reason": "custom_rule"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update full-request.json with the session_age and session_id?

@oschwald
oschwald merged commit 8359150 into master Jun 30, 2017
@oschwald
oschwald deleted the oalders/device-and-session-inputs branch June 30, 2017 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants