Skip to content

Commit 39f75ed

Browse files
committed
Add disposition output to response models
1 parent a4df463 commit 39f75ed

12 files changed

Lines changed: 128 additions & 14 deletions

File tree

CHANGELOG.md

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

4+
1.3.0 (2016-11-21)
5+
------------------
6+
7+
* The disposition was added to the minFraud response models. This is used to
8+
return the disposition of the transaction as set by the custom rules for the
9+
account.
10+
411
1.2.0 (2016-11-11)
512
------------------
613

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77

88
/**
99
* This class contains minFraud response data related to the device.
10+
* <p>
11+
* In order to receive device output from minFraud Insights or minFraud
12+
* Factors, you must be using the Device Tracking Add-on.
1013
*
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-
14+
* @see <a href="https://dev.maxmind.com/minfraud/device/">Device Tracking Add-on</a>
1615
*/
1716
public final class Device extends AbstractModel {
1817
private final Double confidence;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.maxmind.minfraud.response;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.maxmind.minfraud.AbstractModel;
5+
6+
/**
7+
* This class contains the disposition set by custom rules.
8+
*/
9+
public final class Disposition extends AbstractModel {
10+
private final String action;
11+
private final String reason;
12+
13+
public Disposition(
14+
@JsonProperty("action") String action,
15+
@JsonProperty("reason") String reason
16+
) {
17+
this.action = action;
18+
this.reason = reason;
19+
}
20+
21+
public Disposition() {
22+
this(null, null);
23+
}
24+
25+
/**
26+
* @return A {@code String} with the action to take on the transaction as
27+
* defined by your custom rules. The current set of values are
28+
* "accept", "manual_review", and "reject". If you do not have
29+
* custom rules set up, {@code null} will be returned.
30+
*/
31+
@JsonProperty("action")
32+
public String getAction() {
33+
return action;
34+
}
35+
36+
/**
37+
* @return A {@code String} with the reason for the action. The current
38+
* possible values are "custom_rule", "block_list", and "default".
39+
* If you do not have custom rules set up, {@code null} will be
40+
* returned.
41+
*/
42+
@JsonProperty("reason")
43+
public String getReason() {
44+
return reason;
45+
}
46+
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public FactorsResponse(
1717
@JsonProperty("billing_address") BillingAddress billingAddress,
1818
@JsonProperty("credit_card") CreditCard creditCard,
1919
@JsonProperty("device") Device device,
20+
@JsonProperty("disposition") Disposition disposition,
2021
@JsonProperty("email") Email email,
2122
@JsonProperty("funds_remaining") Double fundsRemaining,
2223
@JsonProperty("id") UUID id,
@@ -27,9 +28,9 @@ public FactorsResponse(
2728
@JsonProperty("subscores") Subscores subscores,
2829
@JsonProperty("warnings") List<Warning> warnings
2930
) {
30-
super(billingAddress, creditCard, device, email, fundsRemaining,
31-
id, ipAddress, queriesRemaining, riskScore, shippingAddress,
32-
warnings);
31+
super(billingAddress, creditCard, device, disposition, email,
32+
fundsRemaining, id, ipAddress, queriesRemaining, riskScore,
33+
shippingAddress, warnings);
3334
this.subscores = subscores;
3435
}
3536

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public InsightsResponse(
2020
@JsonProperty("billing_address") BillingAddress billingAddress,
2121
@JsonProperty("credit_card") CreditCard creditCard,
2222
@JsonProperty("device") Device device,
23+
@JsonProperty("disposition") Disposition disposition,
2324
@JsonProperty("email") Email email,
2425
@JsonProperty("funds_remaining") Double fundsRemaining,
2526
@JsonProperty("id") UUID id,
@@ -29,7 +30,7 @@ public InsightsResponse(
2930
@JsonProperty("shipping_address") ShippingAddress shippingAddress,
3031
@JsonProperty("warnings") List<Warning> warnings
3132
) {
32-
super(fundsRemaining, id, null, queriesRemaining, riskScore, warnings);
33+
super(disposition, fundsRemaining, id, null, queriesRemaining, riskScore, warnings);
3334
this.billingAddress = billingAddress == null ? new BillingAddress() : billingAddress;
3435
this.creditCard = creditCard == null ? new CreditCard() : creditCard;
3536
this.device = device == null ? new Device() : device;

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@
1212
* This class represents the minFraud Score response.
1313
*/
1414
public class ScoreResponse extends AbstractModel {
15-
protected final Double fundsRemaining;
16-
protected final UUID id;
17-
protected final Integer queriesRemaining;
18-
protected final Double riskScore;
19-
protected final List<Warning> warnings;
15+
private final Disposition disposition;
16+
private final Double fundsRemaining;
17+
private final UUID id;
18+
private final Integer queriesRemaining;
19+
private final Double riskScore;
20+
private final List<Warning> warnings;
2021
private final ScoreIpAddress ipAddress;
2122

2223
public ScoreResponse(
24+
@JsonProperty("disposition") Disposition disposition,
2325
@JsonProperty("funds_remaining") Double fundsRemaining,
2426
@JsonProperty("id") UUID id,
2527
@JsonProperty("ip_address") ScoreIpAddress ipAddress,
2628
@JsonProperty("queries_remaining") Integer queriesRemaining,
2729
@JsonProperty("risk_score") Double riskScore,
2830
@JsonProperty("warnings") List<Warning> warnings
2931
) {
32+
this.disposition = disposition == null ? new Disposition() : disposition;
3033
this.fundsRemaining = fundsRemaining;
3134
this.id = id;
3235
this.ipAddress = ipAddress == null ? new ScoreIpAddress() : ipAddress;
@@ -35,6 +38,15 @@ public ScoreResponse(
3538
this.warnings = Collections.unmodifiableList(warnings == null ? new ArrayList<Warning>() : warnings);
3639
}
3740

41+
/**
42+
* @return The disposition set by your custom rules.
43+
*/
44+
@JsonProperty("disposition")
45+
public final Disposition getDisposition() {
46+
return disposition;
47+
}
48+
49+
3850
/**
3951
* @return The approximate US dollar value of the funds remaining on your
4052
* MaxMind account.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.maxmind.minfraud.response;
2+
3+
import com.fasterxml.jackson.jr.ob.JSON;
4+
import org.junit.Test;
5+
6+
import java.util.UUID;
7+
8+
import static org.junit.Assert.assertEquals;
9+
10+
public class DispositionTest extends AbstractOutputTest {
11+
12+
@Test
13+
public void testDisposition() throws Exception {
14+
Disposition disposition = this.deserialize(
15+
Disposition.class,
16+
JSON.std
17+
.composeString()
18+
.startObject()
19+
.put("action", "accept")
20+
.put("reason", "default")
21+
.end()
22+
.finish()
23+
);
24+
25+
assertEquals("accept", disposition.getAction());
26+
assertEquals("default", disposition.getReason());
27+
}
28+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public void testInsights() throws Exception {
1818
JSON.std
1919
.composeString()
2020
.startObject()
21+
.startObjectField("disposition")
22+
.put("action", "accept")
23+
.end()
2124
.startObjectField("ip_address")
2225
.startObjectField("country")
2326
.put("iso_code", "US")
@@ -45,6 +48,7 @@ public void testInsights() throws Exception {
4548
.finish()
4649
);
4750

51+
assertEquals("disposition", "accept", insights.getDisposition().getAction());
4852
assertEquals("correct country ISO", "US", insights.getIpAddress().getCountry().getIsoCode());
4953
assertTrue("correct credit card prepaid", insights.getCreditCard().isPrepaid());
5054
assertTrue("correct shipping address is in IP country", insights.getShippingAddress().isInIpCountry());

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public void testScore() throws Exception {
2121
.put("id", id)
2222
.put("queries_remaining", 123)
2323
.put("risk_score", 0.01)
24+
.startObjectField("disposition")
25+
.put("action", "manual_review")
26+
.end()
2427
.startObjectField("ip_address")
2528
.put("risk", 0.02)
2629
.end()
@@ -37,6 +40,7 @@ public void testScore() throws Exception {
3740
assertEquals("correct funds remaining", Double.valueOf(1.20), score.getFundsRemaining());
3841
assertEquals("queries remaining", Integer.valueOf(123), score.getQueriesRemaining());
3942
assertEquals("risk score", Double.valueOf(0.01), score.getRiskScore());
43+
assertEquals("disposition", "manual_review", score.getDisposition().getAction());
4044
assertEquals("IP risk", Double.valueOf(0.02), score.getIpAddress().getRisk());
4145
assertEquals("warning code", "INVALID_INPUT", score.getWarnings().get(0).getCode());
4246
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
"id": "7835b099-d385-4e5b-969e-7df26181d73b",
116116
"last_seen": "2016-06-08T14:16:38Z"
117117
},
118+
"disposition": {
119+
"action": "reject",
120+
"reason": "custom_rule"
121+
},
118122
"email": {
119123
"is_free": true,
120124
"is_high_risk": true

0 commit comments

Comments
 (0)