Skip to content

Commit 309077f

Browse files
committed
Merge pull request #6 from maxmind/greg/mf-factors
Add Factors. Add IP risk to Score.
2 parents aa1bfa8 + 7555336 commit 309077f

45 files changed

Lines changed: 954 additions & 541 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

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

4-
0.3.1 (2016-XX-XX)
4+
0.4.0 (2016-XX-XX)
55
------------------
66

7+
* Added support for the minFraud Factors.
8+
* Added IP address risk to the minFraud Score model.
9+
* Handle `PERMISSION_REQUIRED` errors by throwing a
10+
`PermissionRequiredException`.
11+
* Updated dependency.
712
* Added the following new values to the `Payment.Processor` enum:
8-
`CCNOW`, `DALPAY`, `EPAY` (repaces `EPAYEU`), `PAYPLUS`, `PINPAYMENTS`,
13+
`CCNOW`, `DALPAY`, `EPAY` (replaces `EPAYEU`), `PAYPLUS`, `PINPAYMENTS`,
914
`QUICKPAY`, and `VERAPAY
1015

1116
0.3.0 (2016-01-22)

README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# MaxMind minFraud Score and Insights Java API
1+
# MaxMind minFraud Score, Insights, and Factors Java API
22

33
## Beta Note ##
44

55
This is a beta release. The API may change before the first production
66
release.
77

8-
You may find information on the changes in minFraud Score and minFraud
9-
Insights in our [What's New
8+
You may find information on the changes in minFraud Score, Insights, and Factors
9+
in our [What's New
1010
documentation](https://dev.maxmind.com/minfraud/whats-new-in-minfraud-score-and-minfraud-insights/).
1111

1212
## Description ##
1313

14-
This package provides an API for the [MaxMind minFraud Score and Insights
15-
web services](http://dev.maxmind.com/minfraud-score-and-insights-api-documentation).
14+
This package provides an API for the [MaxMind minFraud Score, Insights, and
15+
Factors web services](http://dev.maxmind.com/minfraud-score-and-insights-api-documentation).
1616

1717
## Installation ##
1818

@@ -57,13 +57,19 @@ After creating the transaction object, send a Score request by calling the
5757
`score` method:
5858

5959
```java
60-
Score score = client.score(transaction);
60+
ScoreResponse score = client.score(transaction);
6161
```
6262

63-
or an Insights request by calling `insights` method:
63+
an Insights request by calling `insights` method:
6464

6565
```java
66-
Insights score = client.insights(transaction);
66+
InsightsResponse insights = client.insights(transaction);
67+
```
68+
69+
an Factors request by calling `factors` method:
70+
71+
```java
72+
FactorsResponse factors = client.factors(transaction);
6773
```
6874

6975
If the request succeeds, a model object will be returned for the endpoint.
@@ -81,20 +87,18 @@ Runtime exceptions:
8187

8288
Checked exceptions:
8389

84-
* `AuthenticationException` - This will be thrown by `score(transaction)` or
85-
`insights(transaction)` on `WebServiceClient` when the server is unable to
90+
* `AuthenticationException` - This will be thrown when the server is unable to
8691
authenticate the request, e.g., if the license key or user ID is invalid.
87-
* `InsufficientFundsException` - This will be thrown by `score(transaction)` or
88-
`insights(transaction)` on `WebServiceClient` when your account is out of funds.
89-
* `InvalidRequestException` - This will be thrown by `score(transaction)` or
90-
`insights(transaction)` on `WebServiceClient` when the server rejects the
92+
* `InsufficientFundsException` - This will be thrown when your account is out of
93+
funds.
94+
* `InvalidRequestException` - This will be thrown when the server rejects the
9195
request for another reason such as invalid JSON in the POST.
92-
* `MinFraudException` - This will be thrown by `score(transaction)` or
93-
`insights(transaction)` on `WebServiceClient` when the server returns an
96+
* `PermissionRequiredException` - This will be thrown when permission is
97+
required to use the service.
98+
* `MinFraudException` - This will be thrown when the server returns an
9499
unexpected response. This also serves as the base class for the above
95100
checked exceptions.
96-
* `HttpException` -This will be thrown by `score(transaction)` or
97-
`insights(transaction)` on `WebServiceClient` when an unexpected HTTP error
101+
* `HttpException` -This will be thrown when an unexpected HTTP error
98102
occurs such as an internal server error or other unexpected status code.
99103

100104
## Example
@@ -220,6 +224,6 @@ This API uses [Semantic Versioning](http://semver.org/).
220224

221225
## Copyright and License ##
222226

223-
This software is Copyright (c) 2016 by MaxMind, Inc.
227+
This software is Copyright (c) 2015-2016 by MaxMind, Inc.
224228

225229
This is free software, licensed under the Apache License, Version 2.0.

pom.xml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,36 @@
3939
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4040
</properties>
4141
<dependencies>
42+
<dependency>
43+
<groupId>com.fasterxml.jackson.core</groupId>
44+
<artifactId>jackson-core</artifactId>
45+
<version>2.7.3</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.fasterxml.jackson.core</groupId>
49+
<artifactId>jackson-databind</artifactId>
50+
<version>2.7.3</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.fasterxml.jackson.core</groupId>
54+
<artifactId>jackson-annotations</artifactId>
55+
<version>2.7.3</version>
56+
</dependency>
4257
<dependency>
4358
<groupId>com.maxmind.geoip2</groupId>
4459
<artifactId>geoip2</artifactId>
45-
<version>2.6.0</version>
60+
<version>2.7.0</version>
61+
<exclusions>
62+
<exclusion>
63+
<groupId>com.google.http-client</groupId>
64+
<artifactId>google-http-client</artifactId>
65+
</exclusion>
66+
</exclusions>
4667
</dependency>
4768
<dependency>
4869
<groupId>org.apache.httpcomponents</groupId>
4970
<artifactId>httpclient</artifactId>
50-
<version>4.5.1</version>
71+
<version>4.5.2</version>
5172
</dependency>
5273
<dependency>
5374
<groupId>commons-validator</groupId>
@@ -63,7 +84,7 @@
6384
<dependency>
6485
<groupId>com.github.tomakehurst</groupId>
6586
<artifactId>wiremock</artifactId>
66-
<version>2.0.8-beta</version>
87+
<version>2.0.10-beta</version>
6788
<scope>test</scope>
6889
</dependency>
6990
<dependency>
@@ -75,19 +96,19 @@
7596
<dependency>
7697
<groupId>org.slf4j</groupId>
7798
<artifactId>slf4j-simple</artifactId>
78-
<version>1.7.13</version>
99+
<version>1.7.21</version>
79100
<scope>test</scope>
80101
</dependency>
81102
<dependency>
82103
<groupId>com.fasterxml.jackson.jr</groupId>
83104
<artifactId>jackson-jr-objects</artifactId>
84-
<version>2.7.0</version>
105+
<version>2.7.4</version>
85106
<scope>test</scope>
86107
</dependency>
87108
<dependency>
88109
<groupId>pl.pragmatists</groupId>
89110
<artifactId>JUnitParams</artifactId>
90-
<version>1.0.4</version>
111+
<version>1.0.5</version>
91112
<scope>test</scope>
92113
</dependency>
93114
<dependency>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.maxmind.minfraud;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.databind.MapperFeature;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.databind.SerializationFeature;
7+
8+
import java.io.IOException;
9+
10+
public abstract class AbstractModel {
11+
12+
/**
13+
* @return JSON representation of this object.
14+
* @throws IOException if there is an error serializing the object to JSON.
15+
*/
16+
public final String toJson() throws IOException {
17+
ObjectMapper mapper = new ObjectMapper();
18+
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
19+
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
20+
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
21+
mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
22+
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
23+
24+
return mapper.writeValueAsString(this);
25+
}
26+
27+
@Override
28+
public String toString() {
29+
// This exception should never happen. If it does happen, we did
30+
// something wrong.
31+
try {
32+
return getClass().getName() + " [ " + toJson() + " ]";
33+
} catch (IOException e) {
34+
throw new RuntimeException(e);
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)