Skip to content

Commit 422e124

Browse files
committed
Add queries_remaining and funds_remaining support
Remove credits_remaining support.
1 parent 790bae1 commit 422e124

10 files changed

Lines changed: 53 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ CHANGELOG
44
0.5.0 (2016-XX-XX)
55
------------------
66

7+
* BREAKING CHANGE: `getCreditsRemaining()` has been removed from the web
8+
service models and has been replaced by `getQueriesRemaining()`.
9+
* Added `getQueriesRemaining()` and `getFundsRemaining()`. Note that
10+
`getFundsRemaining()` will not be returned by the web service until our new
11+
credit system is in place.
712
* This API now throws an `IllegalArgumentException` when `null` values are
813
passed to constructors or methods that require non-null values.
914

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ public final class FactorsResponse extends InsightsResponse {
1616
public FactorsResponse(
1717
@JsonProperty("billing_address") BillingAddress billingAddress,
1818
@JsonProperty("credit_card") CreditCard creditCard,
19-
@JsonProperty("credits_remaining") Integer creditsRemaining,
2019
@JsonProperty("device") Device device,
2120
@JsonProperty("email") Email email,
21+
@JsonProperty("funds_remaining") Double fundsRemaining,
2222
@JsonProperty("id") UUID id,
2323
@JsonProperty("ip_address") IpAddress ipAddress,
24+
@JsonProperty("queries_remaining") Integer queriesRemaining,
2425
@JsonProperty("risk_score") Double riskScore,
2526
@JsonProperty("shipping_address") ShippingAddress shippingAddress,
2627
@JsonProperty("subscores") Subscores subscores,
2728
@JsonProperty("warnings") List<Warning> warnings
2829
) {
29-
super(billingAddress, creditCard, creditsRemaining, device, email,
30-
id, ipAddress, riskScore, shippingAddress, warnings);
30+
super(billingAddress, creditCard, device, email, fundsRemaining,
31+
id, ipAddress, queriesRemaining, riskScore, shippingAddress,
32+
warnings);
3133
this.subscores = subscores;
3234
}
3335

@@ -38,5 +40,4 @@ public FactorsResponse(
3840
public Subscores getSubscores() {
3941
return subscores;
4042
}
41-
4243
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ public class InsightsResponse extends ScoreResponse {
1919
public InsightsResponse(
2020
@JsonProperty("billing_address") BillingAddress billingAddress,
2121
@JsonProperty("credit_card") CreditCard creditCard,
22-
@JsonProperty("credits_remaining") Integer creditsRemaining,
2322
@JsonProperty("device") Device device,
2423
@JsonProperty("email") Email email,
24+
@JsonProperty("funds_remaining") Double fundsRemaining,
2525
@JsonProperty("id") UUID id,
2626
@JsonProperty("ip_address") IpAddress ipAddress,
27+
@JsonProperty("queries_remaining") Integer queriesRemaining,
2728
@JsonProperty("risk_score") Double riskScore,
2829
@JsonProperty("shipping_address") ShippingAddress shippingAddress,
2930
@JsonProperty("warnings") List<Warning> warnings
3031
) {
31-
super(creditsRemaining, id, null, riskScore, warnings);
32+
super(fundsRemaining, id, null, queriesRemaining, riskScore, warnings);
3233
this.billingAddress = billingAddress == null ? new BillingAddress() : billingAddress;
3334
this.creditCard = creditCard == null ? new CreditCard() : creditCard;
3435
this.device = device == null ? new Device() : device;

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,36 @@
1212
* This class represents the minFraud Score response.
1313
*/
1414
public class ScoreResponse extends AbstractModel {
15-
protected final Integer creditsRemaining;
15+
protected final Double fundsRemaining;
1616
protected final UUID id;
17+
protected final Integer queriesRemaining;
1718
protected final Double riskScore;
1819
protected final List<Warning> warnings;
1920
private final ScoreIpAddress ipAddress;
2021

2122
public ScoreResponse(
22-
@JsonProperty("credits_remaining") Integer creditsRemaining,
23+
@JsonProperty("funds_remaining") Double fundsRemaining,
2324
@JsonProperty("id") UUID id,
2425
@JsonProperty("ip_address") ScoreIpAddress ipAddress,
26+
@JsonProperty("queries_remaining") Integer queriesRemaining,
2527
@JsonProperty("risk_score") Double riskScore,
2628
@JsonProperty("warnings") List<Warning> warnings
2729
) {
28-
this.creditsRemaining = creditsRemaining;
30+
this.fundsRemaining = fundsRemaining;
2931
this.id = id;
3032
this.ipAddress = ipAddress == null ? new ScoreIpAddress() : ipAddress;
33+
this.queriesRemaining = queriesRemaining;
3134
this.riskScore = riskScore;
3235
this.warnings = Collections.unmodifiableList(warnings == null ? new ArrayList<Warning>() : warnings);
3336
}
3437

3538
/**
36-
* @return The approximate number of service credits remaining on your
37-
* account.
39+
* @return The approximate US dollar value of the funds remaining on your
40+
* MaxMind account.
3841
*/
39-
@JsonProperty("credits_remaining")
40-
public final Integer getCreditsRemaining() {
41-
return creditsRemaining;
42+
@JsonProperty("funds_remaining")
43+
public final Double getFundsRemaining() {
44+
return fundsRemaining;
4245
}
4346

4447
/**
@@ -56,6 +59,15 @@ public IpAddressInterface getIpAddress() {
5659
return ipAddress;
5760
}
5861

62+
/**
63+
* @return The approximate number of queries remaining for this service
64+
* before your account runs out of funds.
65+
*/
66+
@JsonProperty("queries_remaining")
67+
public final Integer getQueriesRemaining() {
68+
return queriesRemaining;
69+
}
70+
5971
/**
6072
* @return This returns the risk score, from 0.01 to 99. A higher score
6173
* indicates a higher risk of fraud. For example, a score of 20 indicates a

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public void testFactors() throws Exception {
3636
.put("shipping_address_distance_to_ip_location", 0.16)
3737
.put("time_of_day", 0.17)
3838
.end()
39-
.put("credits_remaining", 123)
39+
.put("funds_remaining", 1.20)
40+
.put("queries_remaining", 123)
4041
.put("id", id)
4142
.put("risk_score", 0.01)
4243
.end()
@@ -60,8 +61,9 @@ public void testFactors() throws Exception {
6061
assertEquals("phone_number", Double.valueOf(0.15), factors.getSubscores().getPhoneNumber());
6162
assertEquals("shipping_address_distance_to_ip_location", Double.valueOf(0.16), factors.getSubscores().getShippingAddressDistanceToIpLocation());
6263
assertEquals("time_of_day", Double.valueOf(0.17), factors.getSubscores().getTimeOfDay());
64+
assertEquals("correct funnds remaining", Double.valueOf(1.20), factors.getFundsRemaining());
6365
assertEquals("correct ID", UUID.fromString(id), factors.getId());
64-
assertEquals("correct credits remaining", Integer.valueOf(123), factors.getCreditsRemaining());
66+
assertEquals("correct queries remaining", Integer.valueOf(123), factors.getQueriesRemaining());
6567
assertEquals("correct risk score", Double.valueOf(0.01), factors.getRiskScore());
6668
}
6769
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public void testInsights() throws Exception {
3232
.startObjectField("billing_address")
3333
.put("is_in_ip_country", true)
3434
.end()
35-
.put("credits_remaining", 123)
35+
.put("funds_remaining", 1.20)
36+
.put("queries_remaining", 123)
3637
.put("id", id)
3738
.put("risk_score", 0.01)
3839
.startArrayField("warnings")
@@ -48,8 +49,9 @@ public void testInsights() throws Exception {
4849
assertTrue("correct credit card prepaid", insights.getCreditCard().isPrepaid());
4950
assertTrue("correct shipping address is in IP country", insights.getShippingAddress().isInIpCountry());
5051
assertTrue("correct billing address is in IP country", insights.getBillingAddress().isInIpCountry());
52+
assertEquals("correct funds remaining", Double.valueOf(1.20), insights.getFundsRemaining());
5153
assertEquals("correct ID", UUID.fromString(id), insights.getId());
52-
assertEquals("correct credits remaining", Integer.valueOf(123), insights.getCreditsRemaining());
54+
assertEquals("correct queries remaining", Integer.valueOf(123), insights.getQueriesRemaining());
5355
assertEquals("correct risk score", Double.valueOf(0.01), insights.getRiskScore());
5456
assertEquals("correct warning code", "INVALID_INPUT", insights.getWarnings().get(0).getCode());
5557
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ public void testScore() throws Exception {
1717
JSON.std
1818
.composeString()
1919
.startObject()
20-
.put("credits_remaining", 123)
20+
.put("funds_remaining", 1.20)
2121
.put("id", id)
22+
.put("queries_remaining", 123)
2223
.put("risk_score", 0.01)
2324
.startObjectField("ip_address")
2425
.put("risk", 0.02)
@@ -33,9 +34,10 @@ public void testScore() throws Exception {
3334
);
3435

3536
assertEquals("correct ID", UUID.fromString(id), score.getId());
36-
assertEquals("credits remaining", Integer.valueOf(123), score.getCreditsRemaining());
37+
assertEquals("correct funds remaining", Double.valueOf(1.20), score.getFundsRemaining());
38+
assertEquals("queries remaining", Integer.valueOf(123), score.getQueriesRemaining());
3739
assertEquals("risk score", Double.valueOf(0.01), score.getRiskScore());
38-
assertEquals("IP ris", Double.valueOf(0.02), score.getIpAddress().getRisk());
40+
assertEquals("IP risk", Double.valueOf(0.02), score.getIpAddress().getRisk());
3941
assertEquals("warning code", "INVALID_INPUT", score.getWarnings().get(0).getCode());
4042
}
4143
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"id": "27d26476-e2bc-11e4-92b8-962e705b4af5",
33
"risk_score": 0.01,
4-
"credits_remaining": 1000,
4+
"funds_remaining": 10.00,
5+
"queries_remaining": 1000,
56
"ip_address": {
67
"risk": 0.01,
78
"city": {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"id": "27d26476-e2bc-11e4-92b8-962e705b4af5",
33
"risk_score": 0.01,
4-
"credits_remaining": 1000,
4+
"funds_remaining": 10.00,
5+
"queries_remaining": 1000,
56
"ip_address": {
67
"risk": 0.01,
78
"city": {
@@ -137,4 +138,4 @@
137138
"warning": "Encountered value at \/account\/username_md5 that does meet the required constraints"
138139
}
139140
]
140-
}
141+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"risk_score": 0.01,
33
"id": "27d26476-e2bc-11e4-92b8-962e705b4af5",
4-
"credits_remaining": 1000,
4+
"funds_remaining": 10.00,
5+
"queries_remaining": 1000,
56
"ip_address": {
67
"risk": 99
78
},

0 commit comments

Comments
 (0)