Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
distribution: ['zulu']
os: [ubuntu-latest, windows-latest, macos-latest]
version: [ 11, 17, 21, 22 ]
version: [ 17, 21, 24 ]
steps:
- uses: actions/checkout@v5
with:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
CHANGELOG
=========

4.0.0
------------------

* BREAKING: Removed deprecated `TransactionReport.Builder(InetAddress, Tag)`
constructor. Use `Builder(Tag)` and `ipAddress(InetAddress)` instead.
* BREAKING: Removed deprecated `getUrl()` methods from `HttpException` and
`InvalidRequestException`. Use `getUri()` instead.
* BREAKING: Removed deprecated constructors from `FactorsResponse`,
`InsightsResponse`, and `Phone` classes.
* BREAKING: Removed deprecated `Subscores` class and
`FactorsResponse.getSubscores()` method. Use `getRiskScoreReasons()`
instead.
* BREAKING: Java 17 is now required (previously Java 11).

3.9.0
------------------

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To do this, add the dependency to your pom.xml:
<dependency>
<groupId>com.maxmind.minfraud</groupId>
<artifactId>minfraud</artifactId>
<version>3.8.0</version>
<version>4.0.0</version>
</dependency>
```

Expand All @@ -29,7 +29,7 @@ repositories {
mavenCentral()
}
dependencies {
compile 'com.maxmind.minfraud:minfraud:3.8.0'
compile 'com.maxmind.minfraud:minfraud:4.0.0'
}
```

Expand Down Expand Up @@ -281,7 +281,7 @@ to the client API, please see

## Requirements ##

This code requires Java 11+.
This code requires Java 17+.

## Contributing ##

Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.maxmind.minfraud</groupId>
<artifactId>minfraud</artifactId>
<version>3.8.0</version>
<version>4.0.0</version>
<name>MaxMind minFraud API</name>
<description>MaxMind minFraud Score, Insights, Factors and Report Transaction API</description>
<url>http://dev.maxmind.com/minfraud</url>
Expand Down Expand Up @@ -170,7 +170,7 @@
<version>3.11.3</version>
<configuration>
<show>public</show>
<source>11</source>
<source>17</source>
<doclint>-missing</doclint>
</configuration>
<executions>
Expand Down Expand Up @@ -206,9 +206,9 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<release>11</release>
<source>1.11</source>
<target>1.11</target>
<release>17</release>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/com/maxmind/minfraud/WebServiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -168,7 +167,7 @@ public WebServiceClient.Builder locales(List<String> val) {
if (locales == null) {
throw new IllegalArgumentException("locales must not be null");
}
locales = new ArrayList<>(val);
locales = List.copyOf(val);
return this;
}

Expand Down Expand Up @@ -436,17 +435,11 @@ private void handleErrorWithJsonBody(Map<String, String> content,
}

switch (code) {
case "ACCOUNT_ID_REQUIRED":
case "AUTHORIZATION_INVALID":
case "LICENSE_KEY_REQUIRED":
case "USER_ID_REQUIRED":
throw new AuthenticationException(error);
case "INSUFFICIENT_FUNDS":
throw new InsufficientFundsException(error);
case "PERMISSION_REQUIRED":
throw new PermissionRequiredException(error);
default:
throw new InvalidRequestException(error, code, status, uri, null);
case "ACCOUNT_ID_REQUIRED", "AUTHORIZATION_INVALID", "LICENSE_KEY_REQUIRED",
"USER_ID_REQUIRED" -> throw new AuthenticationException(error);
case "INSUFFICIENT_FUNDS" -> throw new InsufficientFundsException(error);
case "PERMISSION_REQUIRED" -> throw new PermissionRequiredException(error);
default -> throw new InvalidRequestException(error, code, status, uri, null);
}
}

Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/maxmind/minfraud/exception/HttpException.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.maxmind.minfraud.exception;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;

/**
* This class represents an HTTP transport error. This is not an error returned by the web service
Expand Down Expand Up @@ -51,16 +49,4 @@ public URI getUri() {
return this.uri;
}

/**
* @return the URL queried.
* @deprecated Use getUri() instead
*/
@Deprecated
public URL getUrl() {
try {
return this.uri.toURL();
} catch (MalformedURLException e) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This exception is thrown when your account does not have sufficient funds to complete the
* request.
*/
public class InsufficientFundsException extends MinFraudException {
public final class InsufficientFundsException extends MinFraudException {

/**
* @param message A message explaining the cause of the error.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.maxmind.minfraud.exception;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;

/**
* This class represents a non-specific error returned by MaxMind's minFraud web service. This
* occurs when the web service is up and responding to requests, but the request sent was invalid in
* some way.
*/
public class InvalidRequestException extends MinFraudException {
public final class InvalidRequestException extends MinFraudException {
private final String code;
private final int httpStatus;
private final URI uri;
Expand Down Expand Up @@ -63,16 +61,4 @@ public URI getUri() {
return this.uri;
}

/**
* @return the URL queried.
* @deprecated Use getUri() instead
*/
@Deprecated
public URL getUrl() {
try {
return this.uri.toURL();
} catch (MalformedURLException e) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* It also serves as the base class for {@code AuthenticationException},
* {@code InsufficientFundsException}, and {@code InvalidRequestException}.
*/
public class MinFraudException extends Exception {
public sealed class MinFraudException extends Exception
permits AuthenticationException, InsufficientFundsException, InvalidRequestException,
PermissionRequiredException {

/**
* @param message A message explaining the cause of the error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected AbstractLocation(AbstractLocation.Builder builder) {
* @param <T> the builder class
*/
@SuppressWarnings("unchecked")
abstract static class Builder<T extends AbstractLocation.Builder> {
abstract static class Builder<T extends AbstractLocation.Builder<T>> {
private static final Pattern COUNTRY_CODE_PATTERN = Pattern.compile("^[A-Z]{2}$");

String firstName;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/maxmind/minfraud/request/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ private String cleanAddress(String address) {
);
if (fastmailDomains.containsKey(possibleDomain)) {
domain = possibleDomain;
if (!localPart.equals("")) {
if (!localPart.isEmpty()) {
localPart = domainParts[0];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,6 @@ public Shipping getShipping() {
*/
@JsonProperty("shopping_cart")
public List<ShoppingCartItem> getShoppingCart() {
return new ArrayList<>(shoppingCart);
return List.copyOf(shoppingCart);
}
}
15 changes: 0 additions & 15 deletions src/main/java/com/maxmind/minfraud/request/TransactionReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ public static final class Builder {
String notes;
String transactionId;

/**
* The constructor for the {@code TransactionReport.Builder} class with IP address.
*
* @param ipAddress The IP address associated with the device used by the customer in the
* transaction.
* @param tag A string indicating the likelihood that a transaction may be
* fraudulent.
* @deprecated Use {@link #Builder(Tag)} instead and set the IP address using
* {@link #ipAddress(InetAddress)}.
*/
@Deprecated
public Builder(InetAddress ipAddress, Tag tag) {
this(tag);
this.ipAddress = ipAddress;
}

/**
* The constructor for the {@code TransactionReport.Builder} class.
Expand Down
68 changes: 0 additions & 68 deletions src/main/java/com/maxmind/minfraud/response/FactorsResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
public final class FactorsResponse extends InsightsResponse {

private final List<RiskScoreReason> riskScoreReasons;
private final Subscores subscores;


/**
Expand All @@ -32,7 +31,6 @@ public final class FactorsResponse extends InsightsResponse {
* significantly. Risk score reasons are usually only returned for medium to high risk
* transactions. If there were no significant changes to the risk score due to these
* reasons, then this list will be empty.
* @param subscores The {@code Subscores} model object.
* @param warnings A list containing warning objects.
*/
public FactorsResponse(
Expand All @@ -50,70 +48,14 @@ public FactorsResponse(
@JsonProperty("shipping_address") ShippingAddress shippingAddress,
@JsonProperty("shipping_phone") Phone shippingPhone,
@JsonProperty("risk_score_reasons") List<RiskScoreReason> riskScoreReasons,
@JsonProperty("subscores") Subscores subscores,
@JsonProperty("warnings") List<Warning> warnings
) {
super(billingAddress, billingPhone, creditCard, device, disposition, email,
fundsRemaining, id, ipAddress, queriesRemaining, riskScore,
shippingAddress, shippingPhone, warnings);
this.riskScoreReasons = riskScoreReasons;
this.subscores = subscores;
}

/**
* Constructor for backwards compatibility. This will be removed in the next major release.
*
* @deprecated use other constructor.
*/
@Deprecated
public FactorsResponse(
BillingAddress billingAddress,
CreditCard creditCard,
Device device,
Disposition disposition,
Email email,
Double fundsRemaining,
UUID id,
IpAddress ipAddress,
Integer queriesRemaining,
Double riskScore,
ShippingAddress shippingAddress,
Subscores subscores,
List<Warning> warnings
) {
this(billingAddress, null, creditCard, device, disposition, email, fundsRemaining, id,
ipAddress, queriesRemaining, riskScore, shippingAddress, null, null, subscores,
warnings);
}

/**
* Constructor for backwards compatibility. This will be removed in the next
* major release.
*
* @deprecated use other constructor.
*/
@Deprecated
public FactorsResponse(
BillingAddress billingAddress,
Phone billingPhone,
CreditCard creditCard,
Device device,
Disposition disposition,
Email email,
Double fundsRemaining,
UUID id,
IpAddress ipAddress,
Integer queriesRemaining,
Double riskScore,
ShippingAddress shippingAddress,
Phone shippingPhone,
Subscores subscores,
List<Warning> warnings
) {
this(billingAddress, billingPhone, creditCard, device, disposition, email, fundsRemaining,
id, ipAddress, queriesRemaining, riskScore, shippingAddress, shippingPhone, null,
subscores, warnings);
}

/**
* @return A list containing objects that describe risk score reasons
Expand All @@ -124,14 +66,4 @@ public List<RiskScoreReason> getRiskScoreReasons() {
return riskScoreReasons;
}

/**
* @return The {@code Subscores} model object containing the risk factor scores.
*
* @deprecated replaced by {@link getRiskScoreReasons}.
*/
@Deprecated
@JsonProperty("subscores")
public Subscores getSubscores() {
return subscores;
}
}
23 changes: 0 additions & 23 deletions src/main/java/com/maxmind/minfraud/response/InsightsResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,6 @@ public InsightsResponse(
this.shippingPhone = shippingPhone == null ? new Phone() : shippingPhone;
}

/**
* Constructor for backwards compatibility. This will be removed in the next major release.
*
* @deprecated use other constructor.
*/
@Deprecated
public InsightsResponse(
BillingAddress billingAddress,
CreditCard creditCard,
Device device,
Disposition disposition,
Email email,
Double fundsRemaining,
UUID id,
IpAddress ipAddress,
Integer queriesRemaining,
Double riskScore,
ShippingAddress shippingAddress,
List<Warning> warnings
) {
this(billingAddress, null, creditCard, device, disposition, email, fundsRemaining, id,
ipAddress, queriesRemaining, riskScore, shippingAddress, null, warnings);
}

/**
* @return The {@code IpAddress} model object.
Expand Down
Loading
Loading