From e3dcb2bd838380fbe9117294a80b22dce5334b1e Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 12:30:13 -0700 Subject: [PATCH 1/8] Update to geoip2 5.0.0-SNAPSHOT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This introduces breaking changes due to changes in the geoip2 library: - IpAddress no longer extends InsightsResponse (now final in geoip2 5.0.0). Changed to use composition with delegation methods. All public methods remain the same, but code relying on IpAddress being an InsightsResponse will need to be updated. - GeoIp2Location no longer extends Location (now final in geoip2 5.0.0). Changed to store location data directly as fields. All public methods remain the same, but code relying on GeoIp2Location being a Location will need to be updated. - Removed getMaxMind() method from IpAddress as this data is not populated in minFraud responses. - Updated test data to remove deprecated is_satellite_provider field that was removed in geoip2 5.0.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CHANGELOG.md | 12 +++ pom.xml | 2 +- .../minfraud/response/GeoIp2Location.java | 76 +++++++++++++++++- .../maxmind/minfraud/response/IpAddress.java | 78 +++++++++++++++++-- .../resources/test-data/factors-response.json | 1 - .../test-data/insights-response.json | 1 - 6 files changed, 156 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bace614..0bb88504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,18 @@ CHANGELOG `FactorsResponse.getSubscores()` method. Use `getRiskScoreReasons()` instead. * BREAKING: Java 17 is now required (previously Java 11). +* BREAKING: Updated `geoip2` dependency to 5.0.0-SNAPSHOT. This introduces + several breaking changes due to changes in the geoip2 library: + * The `IpAddress` class no longer extends `InsightsResponse` from geoip2. + It now uses composition instead. All public methods remain the same, but + code relying on `IpAddress` being an `InsightsResponse` will need to be + updated. + * The `GeoIp2Location` class no longer extends `Location` from geoip2. It + now stores location data directly. All public methods remain the same, but + code relying on `GeoIp2Location` being a `Location` will need to be + updated. + * Removed the `getMaxMind()` method from the `IpAddress` class as this data + is not populated in minFraud responses. * Added `CREDIT_APPLICATION` and `FUND_TRANSFER` to the `Event.Type` enum. * Added the input `/event/party`. This is the party submitting the transaction. You may provide this using the `party` method on diff --git a/pom.xml b/pom.xml index 4fa11269..854e25a1 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ com.maxmind.geoip2 geoip2 - 4.4.0 + 5.0.0-SNAPSHOT org.junit.jupiter diff --git a/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java b/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java index f0b79789..7d6f6c94 100644 --- a/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java +++ b/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java @@ -8,7 +8,14 @@ /** * This class contains minFraud response data related to the GeoIP2 Insights location. */ -public final class GeoIp2Location extends Location { +public final class GeoIp2Location { + private final Integer accuracyRadius; + private final Integer averageIncome; + private final Double latitude; + private final Double longitude; + private final Integer metroCode; + private final Integer populationDensity; + private final String timeZone; private final String localTime; /** @@ -37,8 +44,13 @@ public GeoIp2Location( @JsonProperty("population_density") Integer populationDensity, @JsonProperty("time_zone") String timeZone ) { - super(accuracyRadius, averageIncome, latitude, longitude, metroCode, populationDensity, - timeZone); + this.accuracyRadius = accuracyRadius; + this.averageIncome = averageIncome; + this.latitude = latitude; + this.longitude = longitude; + this.metroCode = metroCode; + this.populationDensity = populationDensity; + this.timeZone = timeZone; this.localTime = localTime; } @@ -49,6 +61,64 @@ public GeoIp2Location() { this(null, null, null, null, null, null, null, null); } + /** + * @return The approximate accuracy radius in kilometers around the latitude and longitude + * for the geographical entity (country, subdivision, city or postal code) associated + * with the IP address. + */ + @JsonProperty("accuracy_radius") + public Integer getAccuracyRadius() { + return this.accuracyRadius; + } + + /** + * @return The average income in US dollars associated with the requested IP address. + */ + @JsonProperty("average_income") + public Integer getAverageIncome() { + return this.averageIncome; + } + + /** + * @return The approximate latitude of the location associated with the IP address. + */ + @JsonProperty("latitude") + public Double getLatitude() { + return this.latitude; + } + + /** + * @return The approximate longitude of the location associated with the IP address. + */ + @JsonProperty("longitude") + public Double getLongitude() { + return this.longitude; + } + + /** + * @return The metro code of the location if the location is in the US. + */ + @JsonProperty("metro_code") + public Integer getMetroCode() { + return this.metroCode; + } + + /** + * @return The estimated population per square kilometer associated with the IP address. + */ + @JsonProperty("population_density") + public Integer getPopulationDensity() { + return this.populationDensity; + } + + /** + * @return The time zone associated with location, as specified by the IANA Time Zone Database. + */ + @JsonProperty("time_zone") + public String getTimeZone() { + return this.timeZone; + } + /** * @return The date and time of the transaction in the time zone associated with the IP address. * The value is formatted according to RFC 3339. For instance, the local time in Boston diff --git a/src/main/java/com/maxmind/minfraud/response/IpAddress.java b/src/main/java/com/maxmind/minfraud/response/IpAddress.java index 93c4e83d..c789377a 100644 --- a/src/main/java/com/maxmind/minfraud/response/IpAddress.java +++ b/src/main/java/com/maxmind/minfraud/response/IpAddress.java @@ -5,7 +5,6 @@ import com.maxmind.geoip2.record.City; import com.maxmind.geoip2.record.Continent; import com.maxmind.geoip2.record.Country; -import com.maxmind.geoip2.record.MaxMind; import com.maxmind.geoip2.record.Postal; import com.maxmind.geoip2.record.RepresentedCountry; import com.maxmind.geoip2.record.Subdivision; @@ -16,7 +15,8 @@ /** * This class contains minFraud response data related to the IP location */ -public final class IpAddress extends InsightsResponse implements IpAddressInterface { +public final class IpAddress implements IpAddressInterface { + private final InsightsResponse insightsResponse; private final GeoIp2Location location; private final Double risk; private final List riskReasons; @@ -28,7 +28,6 @@ public final class IpAddress extends InsightsResponse implements IpAddressInterf * @param continent The continent information. * @param country The country information. * @param location The location information. - * @param maxmind MaxMind-specific information. * @param postal The postal information. * @param registeredCountry The information about the country where the IP was registered. * @param representedCountry The represented country, e.g., for military bases in other @@ -43,7 +42,6 @@ public IpAddress( @JsonProperty("continent") Continent continent, @JsonProperty("country") Country country, @JsonProperty("location") GeoIp2Location location, - @JsonProperty("maxmind") MaxMind maxmind, @JsonProperty("postal") Postal postal, @JsonProperty("registered_country") Country registeredCountry, @JsonProperty("represented_country") RepresentedCountry representedCountry, @@ -52,8 +50,9 @@ public IpAddress( @JsonProperty("subdivisions") List subdivisions, @JsonProperty("traits") Traits traits ) { - super(city, continent, country, location, maxmind, postal, registeredCountry, - representedCountry, subdivisions, traits); + // Store all the GeoIP2 data directly without using InsightsResponse for storage + this.insightsResponse = new InsightsResponse(city, continent, country, null, null, + postal, registeredCountry, representedCountry, subdivisions, traits); this.location = location == null ? new GeoIp2Location() : location; this.risk = risk; this.riskReasons = @@ -65,17 +64,80 @@ public IpAddress( */ public IpAddress() { this(null, null, null, null, null, null, - null, null, null, null, null, null); + null, null, null, null, null); } /** * @return Location record for the requested IP address. */ - @Override + @JsonProperty("location") public GeoIp2Location getLocation() { return location; } + /** + * @return City record for the requested IP address. + */ + @JsonProperty("city") + public City getCity() { + return insightsResponse.getCity(); + } + + /** + * @return Continent record for the requested IP address. + */ + @JsonProperty("continent") + public Continent getContinent() { + return insightsResponse.getContinent(); + } + + /** + * @return Country record for the requested IP address. + */ + @JsonProperty("country") + public Country getCountry() { + return insightsResponse.getCountry(); + } + + /** + * @return Postal record for the requested IP address. + */ + @JsonProperty("postal") + public Postal getPostal() { + return insightsResponse.getPostal(); + } + + /** + * @return Registered country record for the requested IP address. + */ + @JsonProperty("registered_country") + public Country getRegisteredCountry() { + return insightsResponse.getRegisteredCountry(); + } + + /** + * @return Represented country record for the requested IP address. + */ + @JsonProperty("represented_country") + public RepresentedCountry getRepresentedCountry() { + return insightsResponse.getRepresentedCountry(); + } + + /** + * @return List of subdivision records for the requested IP address. + */ + @JsonProperty("subdivisions") + public List getSubdivisions() { + return insightsResponse.getSubdivisions(); + } + + /** + * @return Traits record for the requested IP address. + */ + @JsonProperty("traits") + public Traits getTraits() { + return insightsResponse.getTraits(); + } /** * @return The risk associated with the IP address. The value ranges from 0.01 to 99. A higher diff --git a/src/test/resources/test-data/factors-response.json b/src/test/resources/test-data/factors-response.json index 7345b57a..41eec3f6 100644 --- a/src/test/resources/test-data/factors-response.json +++ b/src/test/resources/test-data/factors-response.json @@ -101,7 +101,6 @@ "is_anonymous_vpn": true, "is_hosting_provider": true, "is_public_proxy": true, - "is_satellite_provider": true, "is_tor_exit_node": true, "isp": "Andrews & Arnold Ltd", "mobile_country_code": "310", diff --git a/src/test/resources/test-data/insights-response.json b/src/test/resources/test-data/insights-response.json index 0302c7bc..14de174a 100644 --- a/src/test/resources/test-data/insights-response.json +++ b/src/test/resources/test-data/insights-response.json @@ -115,7 +115,6 @@ "is_anonymous_vpn": true, "is_hosting_provider": true, "is_public_proxy": true, - "is_satellite_provider": true, "is_tor_exit_node": true, "isp": "Andrews & Arnold Ltd", "mobile_country_code": "310", From d36ec60845cd89bff30b46bcab8f0328bb767523 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 13:32:43 -0700 Subject: [PATCH 2/8] Convert response classes to Java records MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change makes these classes more concise and provides better immutability guarantees. All `get*()` accessor methods in response classes are now deprecated and will be removed in 5.0.0. Use the automatically generated record accessor methods instead (e.g., use `riskScore()` instead of `getRiskScore()`). The response class hierarchy has been flattened. `InsightsResponse` no longer extends `ScoreResponse`, and `FactorsResponse` no longer extends `InsightsResponse`. Instead, `InsightsResponse` and `FactorsResponse` now include all fields from their former parent classes directly. All response classes now implement `JsonSerializable` instead of extending `AbstractModel`. The `toJson()` method remains available for serialization. Removed the `AbstractAddress` interface as it provided no value with records. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CHANGELOG.md | 12 + .../maxmind/minfraud/JsonSerializable.java | 18 ++ .../minfraud/response/AbstractAddress.java | 69 ---- .../minfraud/response/BillingAddress.java | 81 +++-- .../maxmind/minfraud/response/CreditCard.java | 149 +++++---- .../com/maxmind/minfraud/response/Device.java | 65 ++-- .../minfraud/response/Disposition.java | 56 ++-- .../com/maxmind/minfraud/response/Email.java | 91 +++--- .../minfraud/response/EmailDomain.java | 27 +- .../minfraud/response/FactorsResponse.java | 294 +++++++++++++++--- .../minfraud/response/GeoIp2Location.java | 123 ++++---- .../minfraud/response/InsightsResponse.java | 267 +++++++++++----- .../maxmind/minfraud/response/IpAddress.java | 147 +++++---- .../minfraud/response/IpAddressInterface.java | 11 +- .../minfraud/response/IpRiskReason.java | 67 ++-- .../com/maxmind/minfraud/response/Issuer.java | 77 ++--- .../com/maxmind/minfraud/response/Phone.java | 91 +++--- .../com/maxmind/minfraud/response/Reason.java | 99 ++++-- .../minfraud/response/RiskScoreReason.java | 42 +-- .../minfraud/response/ScoreIpAddress.java | 30 +- .../minfraud/response/ScoreResponse.java | 130 +++++--- .../minfraud/response/ShippingAddress.java | 115 ++++--- .../maxmind/minfraud/response/Warning.java | 77 +++-- .../response/AbstractAddressTest.java | 30 -- .../minfraud/response/BillingAddressTest.java | 26 +- .../minfraud/response/ScoreResponseTest.java | 2 +- .../response/ShippingAddressTest.java | 24 +- .../resources/test-data/factors-response.json | 16 + 28 files changed, 1383 insertions(+), 853 deletions(-) create mode 100644 src/main/java/com/maxmind/minfraud/JsonSerializable.java delete mode 100644 src/main/java/com/maxmind/minfraud/response/AbstractAddress.java delete mode 100644 src/test/java/com/maxmind/minfraud/response/AbstractAddressTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bb88504..98345192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,18 @@ CHANGELOG updated. * Removed the `getMaxMind()` method from the `IpAddress` class as this data is not populated in minFraud responses. +* BREAKING: Converted all response classes to Java records. This change makes + these classes more concise and provides better immutability guarantees. + * All `get*()` accessor methods in response classes are now deprecated and + will be removed in 5.0.0. Use the automatically generated record accessor + methods instead (e.g., use `riskScore()` instead of `getRiskScore()`). + * The response class hierarchy has been flattened. `InsightsResponse` no + longer extends `ScoreResponse`, and `FactorsResponse` no longer extends + `InsightsResponse`. Instead, `InsightsResponse` and `FactorsResponse` now + include all fields from their former parent classes directly. + * All response classes now implement `JsonSerializable` instead of extending + `AbstractModel`. The `toJson()` method remains available for serialization. + * Removed the `AbstractAddress` interface. * Added `CREDIT_APPLICATION` and `FUND_TRANSFER` to the `Event.Type` enum. * Added the input `/event/party`. This is the party submitting the transaction. You may provide this using the `party` method on diff --git a/src/main/java/com/maxmind/minfraud/JsonSerializable.java b/src/main/java/com/maxmind/minfraud/JsonSerializable.java new file mode 100644 index 00000000..cffd91a3 --- /dev/null +++ b/src/main/java/com/maxmind/minfraud/JsonSerializable.java @@ -0,0 +1,18 @@ +package com.maxmind.minfraud; + +import java.io.IOException; + +/** + * Interface for classes that can be serialized to JSON. + * Provides default implementation for toJson() method. + */ +public interface JsonSerializable { + + /** + * @return JSON representation of this object. + * @throws IOException if there is an error serializing the object to JSON. + */ + default String toJson() throws IOException { + return Mapper.get().writeValueAsString(this); + } +} diff --git a/src/main/java/com/maxmind/minfraud/response/AbstractAddress.java b/src/main/java/com/maxmind/minfraud/response/AbstractAddress.java deleted file mode 100644 index 59d3e21f..00000000 --- a/src/main/java/com/maxmind/minfraud/response/AbstractAddress.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.maxmind.minfraud.response; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; - -/** - * This class contains minFraud response data related to the shipping and billing address. - */ -public abstract class AbstractAddress extends AbstractModel { - private final Boolean isPostalInCity; - private final Double latitude; - private final Double longitude; - private final Integer distanceToIpLocation; - private final Boolean isInIpCountry; - - protected AbstractAddress(Integer distanceToIpLocation, Boolean isInIpCountry, - Boolean isPostalInCity, Double latitude, Double longitude) { - this.distanceToIpLocation = distanceToIpLocation; - this.isInIpCountry = isInIpCountry; - this.isPostalInCity = isPostalInCity; - this.latitude = latitude; - this.longitude = longitude; - } - - /** - * @return This returns true if the address is in the IP country. It is false when the address - * is not in the IP country. If the address could not be parsed or was not provided or the - * IP address could not be geolocated, then null will be returned. - */ - @JsonProperty("is_in_ip_country") - public final Boolean isInIpCountry() { - return isInIpCountry; - } - - /** - * @return The latitude associated with the address. This will be null if there is no value in - * the response. - */ - public final Double getLatitude() { - return latitude; - } - - /** - * @return The longitude associated with the address. This will be null if there is no value in - * the response. - */ - public final Double getLongitude() { - return longitude; - } - - /** - * @return The distance in kilometers from the address to the IP location in kilometers. This - * will be null if there is no value in the response. - */ - @JsonProperty("distance_to_ip_location") - public final Integer getDistanceToIpLocation() { - return distanceToIpLocation; - } - - /** - * @return This will return true if the postal code provided with the address is in the city for - * the address. It will return false when the postal code is not in the city. If the address - * was not provided or could not be parsed, null will be returned. - */ - @JsonProperty("is_postal_in_city") - public final Boolean isPostalInCity() { - return isPostalInCity; - } -} diff --git a/src/main/java/com/maxmind/minfraud/response/BillingAddress.java b/src/main/java/com/maxmind/minfraud/response/BillingAddress.java index d3502b15..8b838e87 100644 --- a/src/main/java/com/maxmind/minfraud/response/BillingAddress.java +++ b/src/main/java/com/maxmind/minfraud/response/BillingAddress.java @@ -1,36 +1,75 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains minFraud response data related to the billing address. + * + * @param distanceToIpLocation The distance in kilometers from the address to the IP location. + * This will be null if there is no value in the response. + * @param isInIpCountry This returns true if the address is in the IP country. It is false + * when the address is not in the IP country. If the address could not + * be parsed or was not provided or the IP address could not be + * geolocated, then null will be returned. + * @param isPostalInCity This will return true if the postal code provided with the address + * is in the city for the address. It will return false when the postal + * code is not in the city. If the address was not provided or could not + * be parsed, null will be returned. + * @param latitude The latitude associated with the address. This will be null if there + * is no value in the response. + * @param longitude The longitude associated with the address. This will be null if there + * is no value in the response. */ -public final class BillingAddress extends AbstractAddress { +public record BillingAddress( + @JsonProperty("distance_to_ip_location") + Integer distanceToIpLocation, + + @JsonProperty("is_in_ip_country") + Boolean isInIpCountry, + + @JsonProperty("is_postal_in_city") + Boolean isPostalInCity, + + @JsonProperty("latitude") + Double latitude, + + @JsonProperty("longitude") + Double longitude +) implements JsonSerializable { + /** - * Constructor for {@code BillingAddress}. - * - * @param distanceToIpLocation The distance in kilometers from the billing address to the IP - * location. - * @param isInIpCountry This is true if the billing address is in the IP country. - * @param isPostalInCity This is true if the billing postal code is in the city for the IP - * location. - * @param latitude The latitude associated with the IP address. - * @param longitude The longitude associated with the IP address. + * Constructs an instance of {@code BillingAddress} with no data. */ - public BillingAddress( - @JsonProperty("distance_to_ip_location") Integer distanceToIpLocation, - @JsonProperty("is_in_ip_country") Boolean isInIpCountry, - @JsonProperty("is_postal_in_city") Boolean isPostalInCity, - @JsonProperty("latitude") Double latitude, - @JsonProperty("longitude") Double longitude - ) { - super(distanceToIpLocation, isInIpCountry, isPostalInCity, latitude, longitude); + public BillingAddress() { + this(null, null, null, null, null); } /** - * Constructor for {@code BillingAddress}. + * @return The latitude associated with the address. + * @deprecated Use {@link #latitude()} instead. This method will be removed in 5.0.0. */ - public BillingAddress() { - this(null, null, null, null, null); + @Deprecated(since = "4.0.0", forRemoval = true) + public Double getLatitude() { + return latitude(); + } + + /** + * @return The longitude associated with the address. + * @deprecated Use {@link #longitude()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + public Double getLongitude() { + return longitude(); + } + + /** + * @return The distance in kilometers from the address to the IP location. + * @deprecated Use {@link #distanceToIpLocation()} instead. This method will be removed in + * 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + public Integer getDistanceToIpLocation() { + return distanceToIpLocation(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/CreditCard.java b/src/main/java/com/maxmind/minfraud/response/CreditCard.java index d711a626..248f42f3 100644 --- a/src/main/java/com/maxmind/minfraud/response/CreditCard.java +++ b/src/main/java/com/maxmind/minfraud/response/CreditCard.java @@ -1,54 +1,70 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains minFraud response data related to the credit card. + * + * @param brand The credit card brand. + * @param country The two letter + * ISO 3166-1 alpha-2 country code associated with the + * location of the majority of customers using this credit + * card as determined by their billing address. In cases + * where the location of customers is highly mixed, this + * defaults to the country of the bank issuing the card. + * @param isBusiness True if the card is a business card. False if not a + * business card. If the IIN was not provided or is unknown, + * null will be returned. + * @param isIssuedInBillingAddressCountry True if the country of the billing address matches the + * country of the majority of customers using that IIN. In + * cases where the location of customers is highly mixed, the + * match is to the country of the bank issuing the card. + * @param isPrepaid True if the card is a prepaid card. False if not prepaid. + * If the IIN was not provided or is unknown, null will be + * returned. + * @param isVirtual True if the card is a virtual card. False if not virtual. + * If the IIN was not provided or is unknown, null will be + * returned. + * @param issuer The {@code Issuer} model object. + * @param type The credit card type. */ -public final class CreditCard extends AbstractModel { - private final Issuer issuer; - private final String brand; - private final String country; - private final Boolean isBusiness; - private final Boolean isIssuedInBillingAddressCountry; - private final Boolean isPrepaid; - private final Boolean isVirtual; - private final String type; +public record CreditCard( + @JsonProperty("brand") + String brand, + + @JsonProperty("country") + String country, + + @JsonProperty("is_business") + Boolean isBusiness, + + @JsonProperty("is_issued_in_billing_address_country") + Boolean isIssuedInBillingAddressCountry, + + @JsonProperty("is_prepaid") + Boolean isPrepaid, + + @JsonProperty("is_virtual") + Boolean isVirtual, + + @JsonProperty("issuer") + Issuer issuer, + + @JsonProperty("type") + String type +) implements JsonSerializable { /** - * @param brand The credit card brand. - * @param country The country the card was issued in. - * @param isBusiness Whether it is a business card. - * @param isIssuedInBillingAddressCountry Whether the issuing country matches billing country. - * @param isPrepaid Whether the card was prepaid. - * @param isVirtual Whether it is a virtual card. - * @param issuer The issuer information. - * @param type The type. + * Compact canonical constructor that sets defaults for null values. */ - public CreditCard( - @JsonProperty("brand") String brand, - @JsonProperty("country") String country, - @JsonProperty("is_business") Boolean isBusiness, - @JsonProperty("is_issued_in_billing_address_country") - Boolean isIssuedInBillingAddressCountry, - @JsonProperty("is_prepaid") Boolean isPrepaid, - @JsonProperty("is_virtual") Boolean isVirtual, - @JsonProperty("issuer") Issuer issuer, - @JsonProperty("type") String type - ) { - this.brand = brand; - this.country = country; - this.isBusiness = isBusiness; - this.isIssuedInBillingAddressCountry = isIssuedInBillingAddressCountry; - this.isPrepaid = isPrepaid; - this.isVirtual = isVirtual; - this.issuer = issuer == null ? new Issuer() : issuer; - this.type = type; + public CreditCard { + issuer = issuer != null ? issuer : new Issuer(); } /** - * Constructor for {@code CreditCard}. + * Constructs an instance of {@code CreditCard} with no data. */ public CreditCard() { this(null, null, null, null, null, null, null, null); @@ -56,16 +72,22 @@ public CreditCard() { /** * @return The {@code Issuer} model object. + * @deprecated Use {@link #issuer()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("issuer") public Issuer getIssuer() { - return issuer; + return issuer(); } /** * @return The credit card brand. + * @deprecated Use {@link #brand()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("brand") public String getBrand() { - return brand; + return brand(); } /** @@ -73,52 +95,21 @@ public String getBrand() { * alpha-2 country code associated with the location of the majority of customers using * this credit card as determined by their billing address. In cases where the location of * customers is highly mixed, this defaults to the country of the bank issuing the card. + * @deprecated Use {@link #country()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("country") public String getCountry() { - return country; - } - - /** - * @return True if the card is a business card. False if not a business card. If the IIN was not - * provided or is unknown, null will be returned. - */ - @JsonProperty("is_business") - public Boolean isBusiness() { - return isBusiness; - } - - /** - * @return True if the country of the billing address matches the country of the majority of - * customers using that IIN. In cases where the location of customers is highly mixed, the - * match is to the country of the bank issuing the card. - */ - @JsonProperty("is_issued_in_billing_address_country") - public Boolean isIssuedInBillingAddressCountry() { - return isIssuedInBillingAddressCountry; - } - - /** - * @return True if the card is a prepaid card. False if not prepaid. If the IIN was not provided - * or is unknown, null will be returned. - */ - @JsonProperty("is_prepaid") - public Boolean isPrepaid() { - return isPrepaid; - } - - /** - * @return True if the card is a virtual card. False if not virtual. If the IIN was not provided - * or is unknown, null will be returned. - */ - @JsonProperty("is_virtual") - public Boolean isVirtual() { - return isVirtual; + return country(); } /** * @return The credit card type. + * @deprecated Use {@link #type()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("type") public String getType() { - return type; + return type(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/Device.java b/src/main/java/com/maxmind/minfraud/response/Device.java index 87bc17c7..4a78f3a0 100644 --- a/src/main/java/com/maxmind/minfraud/response/Device.java +++ b/src/main/java/com/maxmind/minfraud/response/Device.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; import java.time.ZonedDateTime; import java.util.UUID; @@ -12,34 +12,33 @@ * In order to receive device output from minFraud Insights or minFraud Factors, you must be using * the Device Tracking Add-on. * + * @param confidence A number representing the confidence that the device ID refers to a unique + * device as opposed to a cluster of similar devices. A confidence of 0.01 + * indicates very low confidence that the device is unique, whereas 99 indicates + * very high confidence. + * @param id A UUID identifying the device associated with this IP address. + * @param lastSeen The date and time of the last sighting of the device. This is an RFC 3339 + * date-time. + * @param localTime The date and time of the transaction at the UTC offset associated with the + * device. This is an RFC 3339 date-time. * @see Device Tracking Add-on */ -public final class Device extends AbstractModel { - private final Double confidence; - private final UUID id; - private final String lastSeen; - private final String localTime; +public record Device( + @JsonProperty("confidence") + Double confidence, - /** - * @param confidence The device confidence. - * @param id The device ID. - * @param lastSeen When the device was last seen. - * @param localTime The local time of the device. - */ - public Device( - @JsonProperty("confidence") Double confidence, - @JsonProperty("id") UUID id, - @JsonProperty("last_seen") String lastSeen, - @JsonProperty("local_time") String localTime - ) { - this.confidence = confidence; - this.id = id; - this.lastSeen = lastSeen; - this.localTime = localTime; - } + @JsonProperty("id") + UUID id, + + @JsonProperty("last_seen") + String lastSeen, + + @JsonProperty("local_time") + String localTime +) implements JsonSerializable { /** - * Constructor for {@code Device}. + * Constructs an instance of {@code Device} with no data. */ public Device() { this(null, null, null, null); @@ -49,24 +48,32 @@ public Device() { * @return a number representing the confidence that the device ID refers to a unique device as * opposed to a cluster of similar devices. A confidence of 0.01 indicates very low * confidence that the device is unique, whereas 99 indicates very high confidence. + * @deprecated Use {@link #confidence()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("confidence") public Double getConfidence() { - return confidence; + return confidence(); } /** * @return A UUID identifying the device associated with this IP address. + * @deprecated Use {@link #id()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("id") public UUID getId() { - return id; + return id(); } /** * @return The date and time of the last sighting of the device. This is an RFC 3339 date-time. + * @deprecated Use {@link #lastSeen()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("last_seen") public String getLastSeen() { - return lastSeen; + return lastSeen(); } /** @@ -83,10 +90,12 @@ public ZonedDateTime getLastSeenDateTime() { /** * @return The date and time of the transaction at the UTC offset associated with the device. * This is an RFC 3339 date-time. + * @deprecated Use {@link #localTime()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("local_time") public String getLocalTime() { - return localTime; + return localTime(); } /** diff --git a/src/main/java/com/maxmind/minfraud/response/Disposition.java b/src/main/java/com/maxmind/minfraud/response/Disposition.java index 60a87e43..ac178b1a 100644 --- a/src/main/java/com/maxmind/minfraud/response/Disposition.java +++ b/src/main/java/com/maxmind/minfraud/response/Disposition.java @@ -1,35 +1,35 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains the disposition set by custom rules. + * + * @param action A {@code String} with the action to take on the transaction as defined by your + * custom rules. The current set of values are "accept", "manual_review", "reject" + * and "test". If you do not have custom rules set up, {@code null} will be + * returned. + * @param reason A {@code String} with the reason for the action. The current possible values + * are "custom_rule" and "default". If you do not have custom rules set up, + * {@code null} will be returned. + * @param ruleLabel A {@code String} with the label of the custom rule that was triggered. If you + * do not have custom rules set up, the triggered custom rule does not have a + * label, or no custom rule was triggered, {@code null} will be returned. */ -public final class Disposition extends AbstractModel { - private final String action; - private final String reason; - private final String ruleLabel; +public record Disposition( + @JsonProperty("action") + String action, - /** - * Constructor for {@code Disposition}. - * - * @param action the disposition action - * @param reason reason - * @param ruleLabel rule label - */ - public Disposition( - @JsonProperty("action") String action, - @JsonProperty("reason") String reason, - @JsonProperty("rule_label") String ruleLabel - ) { - this.action = action; - this.reason = reason; - this.ruleLabel = ruleLabel; - } + @JsonProperty("reason") + String reason, + + @JsonProperty("rule_label") + String ruleLabel +) implements JsonSerializable { /** - * Constructor for {@code Disposition}. + * Constructs an instance of {@code Disposition} with no data. */ public Disposition() { this(null, null, null); @@ -39,29 +39,35 @@ public Disposition() { * @return A {@code String} with the action to take on the transaction as defined by your custom * rules. The current set of values are "accept", "manual_review", "reject" and "test". If * you do not have custom rules set up, {@code null} will be returned. + * @deprecated Use {@link #action()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("action") public String getAction() { - return action; + return action(); } /** * @return A {@code String} with the reason for the action. The current possible values are * "custom_rule" and "default". If you do not have custom rules set up, {@code null} will be * returned. + * @deprecated Use {@link #reason()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("reason") public String getReason() { - return reason; + return reason(); } /** * @return A {@code String} with the label of the custom rule that was triggered. If you do not * have custom rules set up, the triggered custom rule does not have a label, or no custom * rule was triggered, {@code null} will be returned. + * @deprecated Use {@link #ruleLabel()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("rule_label") public String getRuleLabel() { - return ruleLabel; + return ruleLabel(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/Email.java b/src/main/java/com/maxmind/minfraud/response/Email.java index a66712cc..784a2846 100644 --- a/src/main/java/com/maxmind/minfraud/response/Email.java +++ b/src/main/java/com/maxmind/minfraud/response/Email.java @@ -2,42 +2,45 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; import java.time.LocalDate; /** * This class contains minFraud response data related to the email address. + * + * @param domain The {@code EmailDomain} model object. + * @param isDisposable Whether it is a disposable email. + * @param isFree Whether it is a free email. + * @param isHighRisk Whether it is a high risk email. + * @param firstSeen A date string (e.g. 2017-04-24) to identify the date an email address was + * first seen by MaxMind. This is expressed using the ISO 8601 date format. */ -public final class Email extends AbstractModel { - private final Boolean isDisposable; - private final Boolean isFree; - private final Boolean isHighRisk; - private final String firstSeen; - private final EmailDomain domain; +public record Email( + @JsonProperty("domain") + EmailDomain domain, + + @JsonProperty("is_disposable") + Boolean isDisposable, + + @JsonProperty("is_free") + Boolean isFree, + + @JsonProperty("is_high_risk") + Boolean isHighRisk, + + @JsonProperty("first_seen") + String firstSeen +) implements JsonSerializable { /** - * @param domain The {@code EmailDomain} model object. - * @param isDisposable Whether it is a disposable email. - * @param isFree Whether it is a free email. - * @param isHighRisk Whether it is a high risk email. - * @param firstSeen When the email was first seen. + * Compact canonical constructor that sets defaults for null values. */ - public Email( - @JsonProperty("domain") EmailDomain domain, - @JsonProperty("is_disposable") Boolean isDisposable, - @JsonProperty("is_free") Boolean isFree, - @JsonProperty("is_high_risk") Boolean isHighRisk, - @JsonProperty("first_seen") String firstSeen - ) { - this.domain = domain == null ? new EmailDomain() : domain; - this.isDisposable = isDisposable; - this.isFree = isFree; - this.isHighRisk = isHighRisk; - this.firstSeen = firstSeen; + public Email { + domain = domain != null ? domain : new EmailDomain(); } /** - * Constructor for {@code Email}. + * Constructs an instance of {@code Email} with no data. */ public Email() { this(null, null, null, null, null); @@ -45,47 +48,23 @@ public Email() { /** * @return The {@code EmailDomain} model object. + * @deprecated Use {@link #domain()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("domain") public EmailDomain getDomain() { - return domain; - } - - /** - * @return Whether the email address is from a disposable email provider. If no email address - * was passed, this will be {@code null}. - */ - @JsonProperty("is_disposable") - public Boolean isDisposable() { - return isDisposable; - } - - /** - * /** - * - * @return Whether the email address is from a free email provider such as Gmail. If no email - * address was passed, this will be {@code null}. - */ - @JsonProperty("is_free") - public Boolean isFree() { - return isFree; - } - - /** - * @return Whether the email address is associated with fraud. If no email address was passed, - * this will be {@code null}. - */ - @JsonProperty("is_high_risk") - public Boolean isHighRisk() { - return isHighRisk; + return domain(); } /** * @return A date string (e.g. 2017-04-24) to identify the date an email address was first seen * by MaxMind. This is expressed using the ISO 8601 date format. + * @deprecated Use {@link #firstSeen()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("first_seen") public String getFirstSeen() { - return firstSeen; + return firstSeen(); } /** diff --git a/src/main/java/com/maxmind/minfraud/response/EmailDomain.java b/src/main/java/com/maxmind/minfraud/response/EmailDomain.java index e060ff53..dc4452ae 100644 --- a/src/main/java/com/maxmind/minfraud/response/EmailDomain.java +++ b/src/main/java/com/maxmind/minfraud/response/EmailDomain.java @@ -1,28 +1,21 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; import java.time.LocalDate; /** * This class contains minFraud response data related to the email domain. + * + * @param firstSeen A date to identify the date an email domain was first seen by MaxMind. */ -public final class EmailDomain extends AbstractModel { - private final LocalDate firstSeen; - - /** - * Constructor for {@code EmailDomain}. - * - * @param firstSeen A date to identify the date an email domain was first seen by MaxMind. - */ - public EmailDomain( - @JsonProperty("first_seen") LocalDate firstSeen - ) { - this.firstSeen = firstSeen; - } +public record EmailDomain( + @JsonProperty("first_seen") + LocalDate firstSeen +) implements JsonSerializable { /** - * Constructor for {@code EmailDomain}. + * Constructs an instance of {@code EmailDomain} with no data. */ public EmailDomain() { this(null); @@ -30,9 +23,11 @@ public EmailDomain() { /** * @return A date to identify the date an email domain was first seen by MaxMind. + * @deprecated Use {@link #firstSeen()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("first_seen") public LocalDate getFirstSeen() { - return firstSeen; + return firstSeen(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/FactorsResponse.java b/src/main/java/com/maxmind/minfraud/response/FactorsResponse.java index e847a74b..10f3bf93 100644 --- a/src/main/java/com/maxmind/minfraud/response/FactorsResponse.java +++ b/src/main/java/com/maxmind/minfraud/response/FactorsResponse.java @@ -1,69 +1,267 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; +import com.maxmind.minfraud.JsonSerializable; import java.util.List; import java.util.UUID; /** * This class provides a model for the minFraud Factors response. + * + * @param billingAddress The {@code BillingAddress} model object. + * @param billingPhone The {@code Phone} model object for the billing phone number. + * @param creditCard The {@code CreditCard} model object. + * @param device The {@code Device} model object. + * @param disposition The disposition set by your custom rules. + * @param email The {@code Email} model object. + * @param fundsRemaining The approximate US dollar value of the funds remaining on your MaxMind + * account. + * @param id This is a UUID that identifies the minFraud request. + * @param ipAddress The {@code IpAddress} model object. + * @param queriesRemaining The approximate number of queries remaining for this service before your + * account runs out of funds. + * @param riskScore This returns the risk score, from 0.01 to 99. A higher score indicates + * a higher risk of fraud. For example, a score of 20 indicates a 20% + * chance that a transaction is fraudulent. We never return a risk score of + * 0, since all transactions have the possibility of being fraudulent. + * Likewise, we never return a risk score of 100. + * @param riskScoreReasons A list containing {@code RiskScoreReason} model objects that describe + * risk score reasons for a given transaction that change the risk score + * 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 shippingAddress The {@code ShippingAddress} model object. + * @param shippingPhone The {@code Phone} model object for the shipping phone number. + * @param warnings An unmodifiable list containing warning objects that detail issues with + * the request such as invalid or unknown inputs. It is highly recommended + * that you check this list for issues when integrating the web service. */ -public final class FactorsResponse extends InsightsResponse { - - private final List riskScoreReasons; - - - /** - * Constructor for {@code FactorsResponse}. - * - * @param billingAddress The {@code BillingAddress} model object. - * @param creditCard The {@code CreditCard} model object. - * @param device The {@code Device} model object. - * @param disposition The {@code Disposition} model object. - * @param email The {@code Email} model object. - * @param fundsRemaining The approximate US dollar value of the funds. - * @param id This is a UUID that identifies the minFraud request. - * @param ipAddress The {@code IpAddress} model object. - * @param queriesRemaining The number of queries remaining. - * @param riskScore The risk score. - * @param shippingAddress The {@code ShippingAddress} model object. - * @param riskScoreReasons A list containing {@code RiskScoreReason} model objects that - * describe risk score reasons for a given transaction that change the risk score - * 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 warnings A list containing warning objects. - */ - public FactorsResponse( - @JsonProperty("billing_address") BillingAddress billingAddress, - @JsonProperty("billing_phone") Phone billingPhone, - @JsonProperty("credit_card") CreditCard creditCard, - @JsonProperty("device") Device device, - @JsonProperty("disposition") Disposition disposition, - @JsonProperty("email") Email email, - @JsonProperty("funds_remaining") Double fundsRemaining, - @JsonProperty("id") UUID id, - @JsonProperty("ip_address") IpAddress ipAddress, - @JsonProperty("queries_remaining") Integer queriesRemaining, - @JsonProperty("risk_score") Double riskScore, - @JsonProperty("shipping_address") ShippingAddress shippingAddress, - @JsonProperty("shipping_phone") Phone shippingPhone, - @JsonProperty("risk_score_reasons") List riskScoreReasons, - @JsonProperty("warnings") List warnings - ) { - super(billingAddress, billingPhone, creditCard, device, disposition, email, - fundsRemaining, id, ipAddress, queriesRemaining, riskScore, - shippingAddress, shippingPhone, warnings); - this.riskScoreReasons = riskScoreReasons; +public record FactorsResponse( + @JsonProperty("billing_address") + BillingAddress billingAddress, + + @JsonProperty("billing_phone") + Phone billingPhone, + + @JsonProperty("credit_card") + CreditCard creditCard, + + @JsonProperty("device") + Device device, + + @JsonProperty("disposition") + Disposition disposition, + + @JsonProperty("email") + Email email, + + @JsonProperty("funds_remaining") + Double fundsRemaining, + + @JsonProperty("id") + UUID id, + + @JsonProperty("ip_address") + IpAddress ipAddress, + + @JsonProperty("queries_remaining") + Integer queriesRemaining, + + @JsonProperty("risk_score") + Double riskScore, + + @JsonProperty("risk_score_reasons") + List riskScoreReasons, + + @JsonProperty("shipping_address") + ShippingAddress shippingAddress, + + @JsonProperty("shipping_phone") + Phone shippingPhone, + + @JsonProperty("warnings") + List warnings +) implements JsonSerializable { + + /** + * Compact canonical constructor that sets defaults for null values. + */ + public FactorsResponse { + billingAddress = billingAddress != null ? billingAddress : new BillingAddress(); + billingPhone = billingPhone != null ? billingPhone : new Phone(); + creditCard = creditCard != null ? creditCard : new CreditCard(); + device = device != null ? device : new Device(); + disposition = disposition != null ? disposition : new Disposition(); + email = email != null ? email : new Email(); + ipAddress = ipAddress != null ? ipAddress : new IpAddress(); + riskScoreReasons = riskScoreReasons != null ? List.copyOf(riskScoreReasons) : List.of(); + shippingAddress = shippingAddress != null ? shippingAddress : new ShippingAddress(); + shippingPhone = shippingPhone != null ? shippingPhone : new Phone(); + warnings = warnings != null ? List.copyOf(warnings) : List.of(); + } + + /** + * Constructs an instance of {@code FactorsResponse} with no data. + */ + public FactorsResponse() { + this(null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null); + } + + /** + * @return The {@code BillingAddress} model object. + * @deprecated Use {@link #billingAddress()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("billing_address") + public BillingAddress getBillingAddress() { + return billingAddress(); + } + + /** + * @return The {@code Phone} model object for the billing phone number. + * @deprecated Use {@link #billingPhone()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("billing_phone") + public Phone getBillingPhone() { + return billingPhone(); + } + + /** + * @return The {@code CreditCard} model object. + * @deprecated Use {@link #creditCard()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("credit_card") + public CreditCard getCreditCard() { + return creditCard(); + } + + /** + * @return The {@code Device} model object. + * @deprecated Use {@link #device()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("device") + public Device getDevice() { + return device(); } + /** + * @return The disposition set by your custom rules. + * @deprecated Use {@link #disposition()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("disposition") + public Disposition getDisposition() { + return disposition(); + } + + /** + * @return The {@code Email} model object. + * @deprecated Use {@link #email()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("email") + public Email getEmail() { + return email(); + } + + /** + * @return The approximate US dollar value of the funds remaining on your MaxMind account. + * @deprecated Use {@link #fundsRemaining()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("funds_remaining") + public Double getFundsRemaining() { + return fundsRemaining(); + } + + /** + * @return This is a UUID that identifies the minFraud request. + * @deprecated Use {@link #id()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("id") + public UUID getId() { + return id(); + } + + /** + * @return The {@code IpAddress} model object. + * @deprecated Use {@link #ipAddress()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("ip_address") + public IpAddress getIpAddress() { + return ipAddress(); + } + + /** + * @return The approximate number of queries remaining for this service before your account runs + * out of funds. + * @deprecated Use {@link #queriesRemaining()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("queries_remaining") + public Integer getQueriesRemaining() { + return queriesRemaining(); + } + + /** + * @return This returns the risk score, from 0.01 to 99. A higher score indicates a higher risk + * of fraud. For example, a score of 20 indicates a 20% chance that a transaction is + * fraudulent. We never return a risk score of 0, since all transactions have the + * possibility of being fraudulent. Likewise, we never return a risk score of 100. + * @deprecated Use {@link #riskScore()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("risk_score") + public Double getRiskScore() { + return riskScore(); + } /** * @return A list containing objects that describe risk score reasons * for a given transaction that change the risk score significantly. + * @deprecated Use {@link #riskScoreReasons()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("risk_score_reasons") public List getRiskScoreReasons() { - return riskScoreReasons; + return riskScoreReasons(); } + /** + * @return The {@code ShippingAddress} model object. + * @deprecated Use {@link #shippingAddress()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("shipping_address") + public ShippingAddress getShippingAddress() { + return shippingAddress(); + } + + /** + * @return The {@code Phone} model object for the shipping phone number. + * @deprecated Use {@link #shippingPhone()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("shipping_phone") + public Phone getShippingPhone() { + return shippingPhone(); + } + + /** + * @return An unmodifiable list containing warning objects that detail issues with the request + * such as invalid or unknown inputs. It is highly recommended that you check this list for + * issues when integrating the web service. + * @deprecated Use {@link #warnings()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("warnings") + public List getWarnings() { + return warnings(); + } } diff --git a/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java b/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java index 7d6f6c94..36043926 100644 --- a/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java +++ b/src/main/java/com/maxmind/minfraud/response/GeoIp2Location.java @@ -2,60 +2,59 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.geoip2.record.Location; +import com.maxmind.minfraud.JsonSerializable; import java.time.ZonedDateTime; /** * This class contains minFraud response data related to the GeoIP2 Insights location. + * + * @param accuracyRadius The approximate accuracy radius in kilometers around the latitude and + * longitude for the geographical entity (country, subdivision, city or + * postal code) associated with the IP address. + * @param averageIncome The average income in US dollars associated with the requested IP + * address. + * @param latitude The approximate latitude of the location associated with the IP + * address. + * @param localTime The date and time of the transaction in the time zone associated with + * the IP address. The value is formatted according to RFC 3339. For + * instance, the local time in Boston might be returned as + * "2015-04-27T19:17:24-04:00". + * @param longitude The approximate longitude of the location associated with the IP + * address. + * @param metroCode The metro code of the location if the location is in the US. + * @param populationDensity The estimated population per square kilometer associated with the IP + * address. + * @param timeZone The time zone associated with location, as specified by the IANA Time + * Zone Database. */ -public final class GeoIp2Location { - private final Integer accuracyRadius; - private final Integer averageIncome; - private final Double latitude; - private final Double longitude; - private final Integer metroCode; - private final Integer populationDensity; - private final String timeZone; - private final String localTime; +public record GeoIp2Location( + @JsonProperty("accuracy_radius") + Integer accuracyRadius, - /** - * Constructor for {@code EmailDomain}. - * - * @param accuracyRadius The approximate accuracy radius in kilometers. - * @param averageIncome The average income in US dollars associated with the IP address. - * @param latitude The approximate latitude of the location associated with the IP - * address. - * @param localTime The date and time of the transaction in the time zone associated - * with the IP address. - * @param longitude The approximate longitude of the location associated with the IP - * address. - * @param metroCode The metro code of the location if the location is in the US. - * @param populationDensity The estimated population per square kilometer associated with the IP - * address. - * @param timeZone The time zone associated with the location. - */ - public GeoIp2Location( - @JsonProperty("accuracy_radius") Integer accuracyRadius, - @JsonProperty("average_income") Integer averageIncome, - @JsonProperty("latitude") Double latitude, - @JsonProperty("local_time") String localTime, - @JsonProperty("longitude") Double longitude, - @JsonProperty("metro_code") Integer metroCode, - @JsonProperty("population_density") Integer populationDensity, - @JsonProperty("time_zone") String timeZone - ) { - this.accuracyRadius = accuracyRadius; - this.averageIncome = averageIncome; - this.latitude = latitude; - this.longitude = longitude; - this.metroCode = metroCode; - this.populationDensity = populationDensity; - this.timeZone = timeZone; - this.localTime = localTime; - } + @JsonProperty("average_income") + Integer averageIncome, + + @JsonProperty("latitude") + Double latitude, + + @JsonProperty("local_time") + String localTime, + + @JsonProperty("longitude") + Double longitude, + + @JsonProperty("metro_code") + Integer metroCode, + + @JsonProperty("population_density") + Integer populationDensity, + + @JsonProperty("time_zone") + String timeZone +) implements JsonSerializable { /** - * Constructor for {@code GeoIp2Location} + * Constructs an instance of {@code GeoIp2Location} with no data. */ public GeoIp2Location() { this(null, null, null, null, null, null, null, null); @@ -65,68 +64,84 @@ public GeoIp2Location() { * @return The approximate accuracy radius in kilometers around the latitude and longitude * for the geographical entity (country, subdivision, city or postal code) associated * with the IP address. + * @deprecated Use {@link #accuracyRadius()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("accuracy_radius") public Integer getAccuracyRadius() { - return this.accuracyRadius; + return accuracyRadius(); } /** * @return The average income in US dollars associated with the requested IP address. + * @deprecated Use {@link #averageIncome()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("average_income") public Integer getAverageIncome() { - return this.averageIncome; + return averageIncome(); } /** * @return The approximate latitude of the location associated with the IP address. + * @deprecated Use {@link #latitude()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("latitude") public Double getLatitude() { - return this.latitude; + return latitude(); } /** * @return The approximate longitude of the location associated with the IP address. + * @deprecated Use {@link #longitude()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("longitude") public Double getLongitude() { - return this.longitude; + return longitude(); } /** * @return The metro code of the location if the location is in the US. + * @deprecated Use {@link #metroCode()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("metro_code") public Integer getMetroCode() { - return this.metroCode; + return metroCode(); } /** * @return The estimated population per square kilometer associated with the IP address. + * @deprecated Use {@link #populationDensity()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("population_density") public Integer getPopulationDensity() { - return this.populationDensity; + return populationDensity(); } /** * @return The time zone associated with location, as specified by the IANA Time Zone Database. + * @deprecated Use {@link #timeZone()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("time_zone") public String getTimeZone() { - return this.timeZone; + return timeZone(); } /** * @return The date and time of the transaction in the time zone associated with the IP address. * The value is formatted according to RFC 3339. For instance, the local time in Boston * might be returned as "2015-04-27T19:17:24-04:00". + * @deprecated Use {@link #localTime()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("local_time") public String getLocalTime() { - return this.localTime; + return localTime(); } /** diff --git a/src/main/java/com/maxmind/minfraud/response/InsightsResponse.java b/src/main/java/com/maxmind/minfraud/response/InsightsResponse.java index 5c2cbfc1..8adde31b 100644 --- a/src/main/java/com/maxmind/minfraud/response/InsightsResponse.java +++ b/src/main/java/com/maxmind/minfraud/response/InsightsResponse.java @@ -1,127 +1,246 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; +import com.maxmind.minfraud.JsonSerializable; import java.util.List; import java.util.UUID; /** * This class provides a model for the minFraud Insights response. + * + * @param billingAddress The {@code BillingAddress} model object. + * @param billingPhone The {@code Phone} model object for the billing phone number. + * @param creditCard The {@code CreditCard} model object. + * @param device The {@code Device} model object. + * @param disposition The disposition set by your custom rules. + * @param email The {@code Email} model object. + * @param fundsRemaining The approximate US dollar value of the funds remaining on your MaxMind + * account. + * @param id This is a UUID that identifies the minFraud request. + * @param ipAddress The {@code IpAddress} model object. + * @param queriesRemaining The approximate number of queries remaining for this service before your + * account runs out of funds. + * @param riskScore This returns the risk score, from 0.01 to 99. A higher score indicates + * a higher risk of fraud. For example, a score of 20 indicates a 20% + * chance that a transaction is fraudulent. We never return a risk score of + * 0, since all transactions have the possibility of being fraudulent. + * Likewise, we never return a risk score of 100. + * @param shippingAddress The {@code ShippingAddress} model object. + * @param shippingPhone The {@code Phone} model object for the shipping phone number. + * @param warnings An unmodifiable list containing warning objects that detail issues with + * the request such as invalid or unknown inputs. It is highly recommended + * that you check this list for issues when integrating the web service. */ -public class InsightsResponse extends ScoreResponse { - private final IpAddress ipAddress; - private final CreditCard creditCard; - private final Device device; - private final Email email; - private final BillingAddress billingAddress; - private final Phone billingPhone; - private final ShippingAddress shippingAddress; - private final Phone shippingPhone; - - /** - * Constructor for {@code InsightsResponse}. - * - * @param billingAddress billing address - * @param billingPhone billing phone - * @param creditCard credit card - * @param device device - * @param disposition disposition - * @param email email - * @param fundsRemaining funds remaining - * @param id id - * @param ipAddress ip address - * @param queriesRemaining queries remaining - * @param riskScore risk score - * @param shippingAddress shipping address - * @param shippingPhone shipping phone - * @param warnings warnings - */ - public InsightsResponse( - @JsonProperty("billing_address") BillingAddress billingAddress, - @JsonProperty("billing_phone") Phone billingPhone, - @JsonProperty("credit_card") CreditCard creditCard, - @JsonProperty("device") Device device, - @JsonProperty("disposition") Disposition disposition, - @JsonProperty("email") Email email, - @JsonProperty("funds_remaining") Double fundsRemaining, - @JsonProperty("id") UUID id, - @JsonProperty("ip_address") IpAddress ipAddress, - @JsonProperty("queries_remaining") Integer queriesRemaining, - @JsonProperty("risk_score") Double riskScore, - @JsonProperty("shipping_address") ShippingAddress shippingAddress, - @JsonProperty("shipping_phone") Phone shippingPhone, - @JsonProperty("warnings") List warnings - ) { - super(disposition, fundsRemaining, id, null, queriesRemaining, riskScore, warnings); - this.billingAddress = billingAddress == null ? new BillingAddress() : billingAddress; - this.billingPhone = billingPhone == null ? new Phone() : billingPhone; - this.creditCard = creditCard == null ? new CreditCard() : creditCard; - this.device = device == null ? new Device() : device; - this.email = email == null ? new Email() : email; - this.ipAddress = ipAddress == null ? new IpAddress() : ipAddress; - this.shippingAddress = shippingAddress == null ? new ShippingAddress() : shippingAddress; - this.shippingPhone = shippingPhone == null ? new Phone() : shippingPhone; +public record InsightsResponse( + @JsonProperty("billing_address") + BillingAddress billingAddress, + + @JsonProperty("billing_phone") + Phone billingPhone, + + @JsonProperty("credit_card") + CreditCard creditCard, + + @JsonProperty("device") + Device device, + + @JsonProperty("disposition") + Disposition disposition, + + @JsonProperty("email") + Email email, + + @JsonProperty("funds_remaining") + Double fundsRemaining, + + @JsonProperty("id") + UUID id, + + @JsonProperty("ip_address") + IpAddress ipAddress, + + @JsonProperty("queries_remaining") + Integer queriesRemaining, + + @JsonProperty("risk_score") + Double riskScore, + + @JsonProperty("shipping_address") + ShippingAddress shippingAddress, + + @JsonProperty("shipping_phone") + Phone shippingPhone, + + @JsonProperty("warnings") + List warnings +) implements JsonSerializable { + + /** + * Compact canonical constructor that sets defaults for null values. + */ + public InsightsResponse { + billingAddress = billingAddress != null ? billingAddress : new BillingAddress(); + billingPhone = billingPhone != null ? billingPhone : new Phone(); + creditCard = creditCard != null ? creditCard : new CreditCard(); + device = device != null ? device : new Device(); + disposition = disposition != null ? disposition : new Disposition(); + email = email != null ? email : new Email(); + ipAddress = ipAddress != null ? ipAddress : new IpAddress(); + shippingAddress = shippingAddress != null ? shippingAddress : new ShippingAddress(); + shippingPhone = shippingPhone != null ? shippingPhone : new Phone(); + warnings = warnings != null ? List.copyOf(warnings) : List.of(); } + /** + * Constructs an instance of {@code InsightsResponse} with no data. + */ + public InsightsResponse() { + this(null, null, null, null, null, null, null, null, null, null, null, null, null, null); + } /** - * @return The {@code IpAddress} model object. + * @return The {@code BillingAddress} model object. + * @deprecated Use {@link #billingAddress()} instead. This method will be removed in 5.0.0. */ - @JsonProperty("ip_address") - public IpAddress getIpAddress() { - return ipAddress; + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("billing_address") + public BillingAddress getBillingAddress() { + return billingAddress(); + } + + /** + * @return The {@code Phone} model object for the billing phone number. + * @deprecated Use {@link #billingPhone()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("billing_phone") + public Phone getBillingPhone() { + return billingPhone(); } /** * @return The {@code CreditCard} model object. + * @deprecated Use {@link #creditCard()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("credit_card") public CreditCard getCreditCard() { - return creditCard; + return creditCard(); } /** * @return The {@code Device} model object. + * @deprecated Use {@link #device()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("device") public Device getDevice() { - return device; + return device(); + } + + /** + * @return The disposition set by your custom rules. + * @deprecated Use {@link #disposition()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("disposition") + public Disposition getDisposition() { + return disposition(); } /** * @return The {@code Email} model object. + * @deprecated Use {@link #email()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("email") public Email getEmail() { - return email; + return email(); + } + + /** + * @return The approximate US dollar value of the funds remaining on your MaxMind account. + * @deprecated Use {@link #fundsRemaining()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("funds_remaining") + public Double getFundsRemaining() { + return fundsRemaining(); + } + + /** + * @return This is a UUID that identifies the minFraud request. + * @deprecated Use {@link #id()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("id") + public UUID getId() { + return id(); + } + + /** + * @return The {@code IpAddress} model object. + * @deprecated Use {@link #ipAddress()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("ip_address") + public IpAddress getIpAddress() { + return ipAddress(); + } + + /** + * @return The approximate number of queries remaining for this service before your account runs + * out of funds. + * @deprecated Use {@link #queriesRemaining()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("queries_remaining") + public Integer getQueriesRemaining() { + return queriesRemaining(); + } + + /** + * @return This returns the risk score, from 0.01 to 99. A higher score indicates a higher risk + * of fraud. For example, a score of 20 indicates a 20% chance that a transaction is + * fraudulent. We never return a risk score of 0, since all transactions have the + * possibility of being fraudulent. Likewise, we never return a risk score of 100. + * @deprecated Use {@link #riskScore()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("risk_score") + public Double getRiskScore() { + return riskScore(); } /** * @return The {@code ShippingAddress} model object. + * @deprecated Use {@link #shippingAddress()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("shipping_address") public ShippingAddress getShippingAddress() { - return shippingAddress; + return shippingAddress(); } /** * @return The {@code Phone} model object for the shipping phone number. + * @deprecated Use {@link #shippingPhone()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("shipping_phone") public Phone getShippingPhone() { - return shippingPhone; - } - - /** - * @return The {@code BillingAddress} model object. - */ - @JsonProperty("billing_address") - public BillingAddress getBillingAddress() { - return billingAddress; + return shippingPhone(); } /** - * @return The {@code Phone} model object for the billing phone number. + * @return An unmodifiable list containing warning objects that detail issues with the request + * such as invalid or unknown inputs. It is highly recommended that you check this list for + * issues when integrating the web service. + * @deprecated Use {@link #warnings()} instead. This method will be removed in 5.0.0. */ - @JsonProperty("billing_phone") - public Phone getBillingPhone() { - return billingPhone; + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("warnings") + public List getWarnings() { + return warnings(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/IpAddress.java b/src/main/java/com/maxmind/minfraud/response/IpAddress.java index c789377a..1644fe50 100644 --- a/src/main/java/com/maxmind/minfraud/response/IpAddress.java +++ b/src/main/java/com/maxmind/minfraud/response/IpAddress.java @@ -1,7 +1,6 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.geoip2.model.InsightsResponse; import com.maxmind.geoip2.record.City; import com.maxmind.geoip2.record.Continent; import com.maxmind.geoip2.record.Country; @@ -9,58 +8,72 @@ import com.maxmind.geoip2.record.RepresentedCountry; import com.maxmind.geoip2.record.Subdivision; import com.maxmind.geoip2.record.Traits; -import java.util.Collections; +import com.maxmind.minfraud.JsonSerializable; import java.util.List; /** - * This class contains minFraud response data related to the IP location + * This class contains minFraud response data related to the IP location. + * + * @param city City record for the requested IP address. + * @param continent Continent record for the requested IP address. + * @param country Country record for the requested IP address. + * @param location Location record for the requested IP address. + * @param postal Postal record for the requested IP address. + * @param registeredCountry Registered country record for the requested IP address. + * @param representedCountry Represented country record for the requested IP address. + * @param risk The risk associated with the IP address. + * @param riskReasons An unmodifiable list containing risk reason objects that identify the + * reasons why the IP address received the associated risk. This will be + * an empty list if there are no reasons. + * @param subdivisions List of subdivision records for the requested IP address. + * @param traits Traits record for the requested IP address. */ -public final class IpAddress implements IpAddressInterface { - private final InsightsResponse insightsResponse; - private final GeoIp2Location location; - private final Double risk; - private final List riskReasons; +public record IpAddress( + @JsonProperty("city") + City city, + + @JsonProperty("continent") + Continent continent, + + @JsonProperty("country") + Country country, + + @JsonProperty("location") + GeoIp2Location location, + + @JsonProperty("postal") + Postal postal, + + @JsonProperty("registered_country") + Country registeredCountry, + + @JsonProperty("represented_country") + RepresentedCountry representedCountry, + + @JsonProperty("risk") + Double risk, + + @JsonProperty("risk_reasons") + List riskReasons, + + @JsonProperty("subdivisions") + List subdivisions, + + @JsonProperty("traits") + Traits traits +) implements IpAddressInterface, JsonSerializable { /** - * Constructor for {@code IpAddress} - * - * @param city The city information. - * @param continent The continent information. - * @param country The country information. - * @param location The location information. - * @param postal The postal information. - * @param registeredCountry The information about the country where the IP was registered. - * @param representedCountry The represented country, e.g., for military bases in other - * countries. - * @param risk The IP risk. - * @param riskReasons The reasons for the IP risk. - * @param subdivisions The list of subdivisions. - * @param traits Information about various other IP traits. + * Compact canonical constructor that sets defaults for null values. */ - public IpAddress( - @JsonProperty("city") City city, - @JsonProperty("continent") Continent continent, - @JsonProperty("country") Country country, - @JsonProperty("location") GeoIp2Location location, - @JsonProperty("postal") Postal postal, - @JsonProperty("registered_country") Country registeredCountry, - @JsonProperty("represented_country") RepresentedCountry representedCountry, - @JsonProperty("risk") Double risk, - @JsonProperty("risk_reasons") List riskReasons, - @JsonProperty("subdivisions") List subdivisions, - @JsonProperty("traits") Traits traits - ) { - // Store all the GeoIP2 data directly without using InsightsResponse for storage - this.insightsResponse = new InsightsResponse(city, continent, country, null, null, - postal, registeredCountry, representedCountry, subdivisions, traits); - this.location = location == null ? new GeoIp2Location() : location; - this.risk = risk; - this.riskReasons = - Collections.unmodifiableList(riskReasons == null ? List.of() : riskReasons); + public IpAddress { + location = location != null ? location : new GeoIp2Location(); + riskReasons = riskReasons != null ? List.copyOf(riskReasons) : List.of(); + subdivisions = subdivisions != null ? List.copyOf(subdivisions) : List.of(); } /** - * Constructor for {@code IpAddress}. + * Constructs an instance of {@code IpAddress} with no data. */ public IpAddress() { this(null, null, null, null, null, null, @@ -69,91 +82,113 @@ public IpAddress() { /** * @return Location record for the requested IP address. + * @deprecated Use {@link #location()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("location") public GeoIp2Location getLocation() { - return location; + return location(); } /** * @return City record for the requested IP address. + * @deprecated Use {@link #city()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("city") public City getCity() { - return insightsResponse.getCity(); + return city(); } /** * @return Continent record for the requested IP address. + * @deprecated Use {@link #continent()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("continent") public Continent getContinent() { - return insightsResponse.getContinent(); + return continent(); } /** * @return Country record for the requested IP address. + * @deprecated Use {@link #country()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("country") public Country getCountry() { - return insightsResponse.getCountry(); + return country(); } /** * @return Postal record for the requested IP address. + * @deprecated Use {@link #postal()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("postal") public Postal getPostal() { - return insightsResponse.getPostal(); + return postal(); } /** * @return Registered country record for the requested IP address. + * @deprecated Use {@link #registeredCountry()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("registered_country") public Country getRegisteredCountry() { - return insightsResponse.getRegisteredCountry(); + return registeredCountry(); } /** * @return Represented country record for the requested IP address. + * @deprecated Use {@link #representedCountry()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("represented_country") public RepresentedCountry getRepresentedCountry() { - return insightsResponse.getRepresentedCountry(); + return representedCountry(); } /** * @return List of subdivision records for the requested IP address. + * @deprecated Use {@link #subdivisions()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("subdivisions") public List getSubdivisions() { - return insightsResponse.getSubdivisions(); + return subdivisions(); } /** * @return Traits record for the requested IP address. + * @deprecated Use {@link #traits()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("traits") public Traits getTraits() { - return insightsResponse.getTraits(); + return traits(); } /** - * @return The risk associated with the IP address. The value ranges from 0.01 to 99. A higher - * score indicates a higher risk. + * @return The risk associated with the IP address. + * @deprecated Use {@link #risk()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("risk") public Double getRisk() { - return risk; + return risk(); } /** * @return An unmodifiable list containing risk reason objects that identify the reasons why the * IP address received the associated risk. This will be an empty list if there are no * reasons. + * @deprecated Use {@link #riskReasons()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("risk_reasons") public List getRiskReasons() { - return riskReasons; + return riskReasons(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/IpAddressInterface.java b/src/main/java/com/maxmind/minfraud/response/IpAddressInterface.java index 3afa99b0..c82f951b 100644 --- a/src/main/java/com/maxmind/minfraud/response/IpAddressInterface.java +++ b/src/main/java/com/maxmind/minfraud/response/IpAddressInterface.java @@ -7,5 +7,14 @@ public interface IpAddressInterface { /** * @return The risk associated with the IP address. */ - Double getRisk(); + Double risk(); + + /** + * @return The risk associated with the IP address. + * @deprecated Use {@link #risk()} instead. This method will be removed in 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + default Double getRisk() { + return risk(); + } } diff --git a/src/main/java/com/maxmind/minfraud/response/IpRiskReason.java b/src/main/java/com/maxmind/minfraud/response/IpRiskReason.java index 24686fa7..fd031ddd 100644 --- a/src/main/java/com/maxmind/minfraud/response/IpRiskReason.java +++ b/src/main/java/com/maxmind/minfraud/response/IpRiskReason.java @@ -1,28 +1,51 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class represents the reason for the IP risk. + * + * @param code This provides a machine-readable code identifying the reason. Although more codes + * may be added in the future, the current codes are: + *
+ *
ANONYMOUS_IP
+ *
The IP address belongs to an anonymous network. See the + * object at {@code .IPAddress.Traits} for more details.
+ * + *
BILLING_POSTAL_VELOCITY
+ *
Many different billing postal codes have been seen on + * this IP address.
+ * + *
EMAIL_VELOCITY
+ *
Many different email addresses have been seen on this + * IP address.
+ * + *
HIGH_RISK_DEVICE
+ *
A high risk device was seen on this IP address.
+ * + *
HIGH_RISK_EMAIL
+ *
A high risk email address was seen on this IP address in + * your past transactions.
+ * + *
ISSUER_ID_NUMBER_VELOCITY
+ *
Many different issuer ID numbers have been seen on this + * IP address.
+ * + *
MINFRAUD_NETWORK_ACTIVITY
+ *
Suspicious activity has been seen on this IP address + * across minFraud customers.
+ *
+ * @param reason This field provides a human-readable explanation of the reason. The description may + * change at any time and should not be matched against. */ -public final class IpRiskReason extends AbstractModel { - private final String code; - private final String reason; +public record IpRiskReason( + @JsonProperty("code") + String code, - /** - * Constructor for {@code IpRiskReason}. - * - * @param code The reason code. - * @param reason This field provides a human-readable explanation of the reason. - */ - public IpRiskReason( - @JsonProperty("code") String code, - @JsonProperty("reason") String reason - ) { - this.code = code; - this.reason = reason; - } + @JsonProperty("reason") + String reason +) implements JsonSerializable { /** * This provides a machine-readable code identifying the reason. Although more codes may be @@ -57,16 +80,22 @@ public IpRiskReason( * * * @return The reason code. + * @deprecated Use {@link #code()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("code") public String getCode() { - return this.code; + return code(); } /** * @return This field provides a human-readable explanation of the reason. The description may * change at any time and should not be matched against. + * @deprecated Use {@link #reason()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("reason") public String getReason() { - return this.reason; + return reason(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/Issuer.java b/src/main/java/com/maxmind/minfraud/response/Issuer.java index 709263c3..a0ee663b 100644 --- a/src/main/java/com/maxmind/minfraud/response/Issuer.java +++ b/src/main/java/com/maxmind/minfraud/response/Issuer.java @@ -1,39 +1,33 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains minFraud response data related to the credit card issuer. + * + * @param matchesProvidedName This is true if the name matches the name provided. + * @param matchesProvidedPhoneNumber This is true if the phone number matches the one provided. + * @param name The name of the bank which issued the credit card. + * @param phoneNumber The phone number of the bank which issued the credit card. In + * some cases the phone number we return may be out of date. */ -public final class Issuer extends AbstractModel { - private final String name; - private final Boolean matchesProvidedName; - private final String phoneNumber; - private final Boolean matchesProvidedPhoneNumber; +public record Issuer( + @JsonProperty("matches_provided_name") + Boolean matchesProvidedName, - /** - * Constructor for {@code Issuer}. - * - * @param matchesProvidedName This is true if the name matches the name provided. - * @param matchesProvidedPhoneNumber This is true if the phone number matches the one provided. - * @param name The name of the bank which issued the credit card. - * @param phoneNumber The phone number of the bank which issued the credit card. - */ - public Issuer( - @JsonProperty("matches_provided_name") Boolean matchesProvidedName, - @JsonProperty("matches_provided_phone_number") Boolean matchesProvidedPhoneNumber, - @JsonProperty("name") String name, - @JsonProperty("phone_number") String phoneNumber - ) { - this.matchesProvidedName = matchesProvidedName; - this.matchesProvidedPhoneNumber = matchesProvidedPhoneNumber; - this.name = name; - this.phoneNumber = phoneNumber; - } + @JsonProperty("matches_provided_phone_number") + Boolean matchesProvidedPhoneNumber, + + @JsonProperty("name") + String name, + + @JsonProperty("phone_number") + String phoneNumber +) implements JsonSerializable { /** - * Constructor for {@code Issuer}. + * Constructs an instance of {@code Issuer} with no data. */ public Issuer() { this(null, null, null, null); @@ -41,39 +35,22 @@ public Issuer() { /** * @return The name of the bank which issued the credit card. + * @deprecated Use {@link #name()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("name") public String getName() { - return name; - } - - /** - * @return This returns true if the name matches the name provided in the request for the card - * issuer. It returns false if the name does not match. It returns null if either no name or - * issuer ID number (IIN) was provided in the request or if MaxMind does not have a name - * associated with the IIN. - */ - @JsonProperty("matches_provided_name") - public Boolean matchesProvidedName() { - return matchesProvidedName; + return name(); } /** * @return The phone number of the bank which issued the credit card. In some cases the phone * number we return may be out of date. + * @deprecated Use {@link #phoneNumber()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("phone_number") public String getPhoneNumber() { - return phoneNumber; - } - - /** - * @return This returns true if the phone number matches the number provided in the request for - * the card issuer. It returns false if the number does not match. It returns null if either - * no phone number or issuer ID number (IIN) was provided in the request or if MaxMind does - * not have a phone number associated with the IIN. - */ - @JsonProperty("matches_provided_phone_number") - public Boolean matchesProvidedPhoneNumber() { - return matchesProvidedPhoneNumber; + return phoneNumber(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/Phone.java b/src/main/java/com/maxmind/minfraud/response/Phone.java index 41dcad14..391f68eb 100644 --- a/src/main/java/com/maxmind/minfraud/response/Phone.java +++ b/src/main/java/com/maxmind/minfraud/response/Phone.java @@ -1,92 +1,77 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains minFraud response data related to the phone number. + * + * @param country The two-character ISO 3166-1 country code for the country associated + * with the phone number. + * @param isVoip Whether the number is VoIP. + * @param matchesPostal Whether the phone number matches the postal code. + * @param networkOperator The name of the original network operator associated with the phone + * number. This field does not reflect phone numbers that have been ported + * from the original operator to another, nor does it identify mobile + * virtual network operators. + * @param numberType One of the following values: {@code fixed} or {@code mobile}. + * Additional values may be added in the future. */ -public final class Phone extends AbstractModel { - private final String country; - private final Boolean isVoip; - private final Boolean matchesPostal; - private final String networkOperator; - private final String numberType; +public record Phone( + @JsonProperty("country") + String country, - /** - * @param country The ISO 3166-2 country code for the phone number. - * @param isVoip Whether the number is VoIP. - * @param matchesPostal Whether the phone number matches the postal code. - * @param networkOperator The network operator associated with the phone number. - * @param numberType The type of the phone number. - */ - public Phone( - @JsonProperty("country") String country, - @JsonProperty("is_voip") Boolean isVoip, - @JsonProperty("matches_postal") Boolean matchesPostal, - @JsonProperty("network_operator") String networkOperator, - @JsonProperty("number_type") String numberType - ) { - this.country = country; - this.isVoip = isVoip; - this.matchesPostal = matchesPostal; - this.networkOperator = networkOperator; - this.numberType = numberType; - } + @JsonProperty("is_voip") + Boolean isVoip, + + @JsonProperty("matches_postal") + Boolean matchesPostal, + + @JsonProperty("network_operator") + String networkOperator, + + @JsonProperty("number_type") + String numberType +) implements JsonSerializable { /** - * Constructor for {@code Phone}. + * Constructs an instance of {@code Phone} with no data. */ public Phone() { this(null, null, null, null, null); } /** - * @return The two-character ISO 3166-1 country code for the country associated with the phone + * @return The two-character ISO 3166-1 country code for the country associated with the phone * number. + * @deprecated Use {@link #country()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("country") public String getCountry() { - return country; - } - - /** - * @return Whether the phone number is a Voice over Internet Protocol (VoIP) number allocated - * by a regulator. The value will be {@code null} if a valid phone number was not provided - * or if we do not have data for the phone number. - */ - @JsonProperty("is_voip") - public Boolean isVoip() { - return isVoip; - } - - /** - * @return This is {@code true} if the phone number's prefix is commonly associated with the - * postal code. It is {@code false} if the prefix is not associated with the postal code. - * It is non-{@code null} only when the phone number is in the US, the number prefix is - * in our database, and the postal code and country are provided in the request. - */ - @JsonProperty("matches_postal") - public Boolean matchesPostal() { - return matchesPostal; + return country(); } /** * @return The name of the original network operator associated with the phone number. This * field does not reflect phone numbers that have been ported from the original operator to * another, nor does it identify mobile virtual network operators. + * @deprecated Use {@link #networkOperator()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("network_operator") public String getNetworkOperator() { - return networkOperator; + return networkOperator(); } /** * @return One of the following values: {@code fixed} or {@code mobile}. Additional values may * be added in the future. + * @deprecated Use {@link #numberType()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("number_type") public String getNumberType() { - return numberType; + return numberType(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/Reason.java b/src/main/java/com/maxmind/minfraud/response/Reason.java index ffb1787a..9a1e7fb6 100644 --- a/src/main/java/com/maxmind/minfraud/response/Reason.java +++ b/src/main/java/com/maxmind/minfraud/response/Reason.java @@ -1,28 +1,85 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class represents a risk score reason for the multiplier. + * + * @param code This field provides a machine-readable code identifying the reason. + * Although more codes + * may be added in the future, the current codes are: + * + *
    + *
  • BROWSER_LANGUAGE - Riskiness of the browser user-agent + * and language associated with the request.
  • + *
  • BUSINESS_ACTIVITY - Riskiness of business activity associated with the + * request.
  • + *
  • COUNTRY - Riskiness of the country associated with the request.
  • + *
  • CUSTOMER_ID - Riskiness of a customer's activity.
  • + *
  • EMAIL_DOMAIN - Riskiness of email domain.
  • + *
  • EMAIL_DOMAIN_NEW - Riskiness of newly-sighted email domain.
  • + *
  • EMAIL_ADDRESS_NEW - Riskiness of newly-sighted email address.
  • + *
  • EMAIL_LOCAL_PART - Riskiness of the local part of the email address.
  • + *
  • EMAIL_VELOCITY - Velocity on email - many requests on same email + * over short period of time.
  • + *
  • ISSUER_ID_NUMBER_COUNTRY_MISMATCH - Riskiness of the country mismatch + * between IP, billing, shipping and IIN country.
  • + *
  • ISSUER_ID_NUMBER_ON_SHOP_ID - Risk of Issuer ID Number for the shop ID.
  • + *
  • ISSUER_ID_NUMBER_LAST_DIGITS_ACTIVITY - Riskiness of many recent + * requests and previous high-risk requests on the IIN and last digits of the + * credit card.
  • + *
  • ISSUER_ID_NUMBER_SHOP_ID_VELOCITY - Risk of recent Issuer ID Number activity + * for the shop ID.
  • + *
  • INTRACOUNTRY_DISTANCE - Risk of distance between IP, billing, + * and shipping location.
  • + *
  • ANONYMOUS_IP - Risk due to IP being an Anonymous IP.
  • + *
  • IP_BILLING_POSTAL_VELOCITY - Velocity of distinct billing postal code + * on IP address.
  • + *
  • IP_EMAIL_VELOCITY - Velocity of distinct email address on IP address.
  • + *
  • IP_HIGH_RISK_DEVICE - High-risk device sighted on IP address.
  • + *
  • IP_ISSUER_ID_NUMBER_VELOCITY - Velocity of distinct IIN on IP address.
  • + *
  • IP_ACTIVITY - Riskiness of IP based on minFraud network activity.
  • + *
  • LANGUAGE - Riskiness of browser language.
  • + *
  • MAX_RECENT_EMAIL - Riskiness of email address based on + * past minFraud risk scores on email.
  • + *
  • MAX_RECENT_PHONE - Riskiness of phone number based on + * past minFraud risk scores on phone.
  • + *
  • MAX_RECENT_SHIP - Riskiness of email address based on + * past minFraud risk scores on ship address.
  • + *
  • MULTIPLE_CUSTOMER_ID_ON_EMAIL - Riskiness of email address + * having many customer IDs.
  • + *
  • ORDER_AMOUNT - Riskiness of the order amount.
  • + *
  • ORG_DISTANCE_RISK - Risk of ISP and distance between billing address + * and IP location.
  • + *
  • PHONE - Riskiness of the phone number or related numbers.
  • + *
  • CART - Riskiness of shopping cart contents.
  • + *
  • TIME_OF_DAY - Risk due to local time of day.
  • + *
  • TRANSACTION_REPORT_EMAIL - Risk due to transaction reports on the email + * address.
  • + *
  • TRANSACTION_REPORT_IP - Risk due to transaction reports on the IP + * address.
  • + *
  • TRANSACTION_REPORT_PHONE - Risk due to transaction reports on the phone + * number.
  • + *
  • TRANSACTION_REPORT_SHIP - Risk due to transaction reports on the shipping + * address.
  • + *
  • EMAIL_ACTIVITY - Riskiness of the email address based on minFraud network + * activity.
  • + *
  • PHONE_ACTIVITY - Riskiness of the phone number based on minFraud network + * activity.
  • + *
  • SHIP_ACTIVITY - Riskiness of ship address based on minFraud network + * activity.
  • + *
+ * @param reason The human-readable explanation of the reason. The description may change at any + * time and should not be matched against. */ -public final class Reason extends AbstractModel { - private final String code; - private final String reason; +public record Reason( + @JsonProperty("code") + String code, - /** - * Constructor for {@code Reason}. - * - * @param code The code. - * @param reason The reason. - */ - public Reason( - @JsonProperty("code") String code, - @JsonProperty("reason") String reason - ) { - this.code = code; - this.reason = reason; - } + @JsonProperty("reason") + String reason +) implements JsonSerializable { /** * This field provides a machine-readable code identifying the reason. @@ -82,18 +139,22 @@ public Reason( * * * @return The code. + * @deprecated Use {@link #code()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("code") public String getCode() { - return this.code; + return code(); } /** * @return The human-readable explanation of the reason. The description may change at any time * and should not be matched against. + * @deprecated Use {@link #reason()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("reason") public String getReason() { - return this.reason; + return reason(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/RiskScoreReason.java b/src/main/java/com/maxmind/minfraud/response/RiskScoreReason.java index 2e25c2ce..0fd7ae78 100644 --- a/src/main/java/com/maxmind/minfraud/response/RiskScoreReason.java +++ b/src/main/java/com/maxmind/minfraud/response/RiskScoreReason.java @@ -1,30 +1,32 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; -import java.util.Collections; +import com.maxmind.minfraud.JsonSerializable; import java.util.List; /** * This class represents a risk score multiplier and reasons for that multiplier. + * + * @param multiplier The factor by which the risk score is increased (if the value is greater than + * 1) or decreased (if the value is less than 1) for given risk reason(s). + * Multipliers greater than 1.5 and less than 0.66 are considered significant and + * lead to risk reason(s) being present. + * @param reasons An unmodifiable list containing objects that describe one of the reasons for + * the multiplier. This will be an empty list if there are no reasons. */ -public final class RiskScoreReason extends AbstractModel { - private final Double multiplier; - private final List reasons; +public record RiskScoreReason( + @JsonProperty("multiplier") + Double multiplier, + + @JsonProperty("reasons") + List reasons +) implements JsonSerializable { /** - * Constructor for {@code RiskScoreReason}. - * - * @param multiplier The multiplier. - * @param reasons The reasons. + * Compact canonical constructor that ensures immutability. */ - public RiskScoreReason( - @JsonProperty("multiplier") Double multiplier, - @JsonProperty("reasons") List reasons - ) { - this.multiplier = multiplier; - this.reasons = - Collections.unmodifiableList(reasons == null ? List.of() : reasons); + public RiskScoreReason { + reasons = reasons != null ? List.copyOf(reasons) : List.of(); } /** @@ -32,18 +34,22 @@ public RiskScoreReason( * or decreased (if the value is less than 1) for given risk reason(s). * Multipliers greater than 1.5 and less than 0.66 are considered significant * and lead to risk reason(s) being present. + * @deprecated Use {@link #multiplier()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("multiplier") public Double getMultiplier() { - return multiplier; + return multiplier(); } /** * @return An unmodifiable list containing objects that describe one of the reasons for * the multiplier. This will be an empty list if there are no reasons. + * @deprecated Use {@link #reasons()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("reasons") public List getReasons() { - return reasons; + return reasons(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/ScoreIpAddress.java b/src/main/java/com/maxmind/minfraud/response/ScoreIpAddress.java index 847a5455..51e4942e 100644 --- a/src/main/java/com/maxmind/minfraud/response/ScoreIpAddress.java +++ b/src/main/java/com/maxmind/minfraud/response/ScoreIpAddress.java @@ -1,36 +1,32 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains the IP address risk. + * + * @param risk The risk associated with the IP address. */ -public final class ScoreIpAddress implements IpAddressInterface { - private final Double risk; +public record ScoreIpAddress( + @JsonProperty("risk") + Double risk +) implements IpAddressInterface, JsonSerializable { /** - * Constructor for {@code ScoreResponse}. - * - * @param risk The risk associated with the IP address. - */ - public ScoreIpAddress( - @JsonProperty("risk") Double risk - ) { - this.risk = risk; - } - - /** - * Constructor for {@code ScoreResponse}. + * Constructs an instance of {@code ScoreIpAddress} with no data. */ public ScoreIpAddress() { this(null); } /** - * @return The risk associated with the IP address. The value ranges from 0.01 to 99. A higher - * score indicates a higher risk. + * @return The risk associated with the IP address. + * @deprecated Use {@link #risk()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("risk") public Double getRisk() { - return risk; + return risk(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/ScoreResponse.java b/src/main/java/com/maxmind/minfraud/response/ScoreResponse.java index 22e4fa4c..11e2f23a 100644 --- a/src/main/java/com/maxmind/minfraud/response/ScoreResponse.java +++ b/src/main/java/com/maxmind/minfraud/response/ScoreResponse.java @@ -1,92 +1,117 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; -import java.util.Collections; +import com.maxmind.minfraud.JsonSerializable; import java.util.List; import java.util.UUID; /** * This class represents the minFraud Score response. + * + * @param disposition The disposition set by your custom rules. + * @param fundsRemaining The approximate US dollar value of the funds remaining on your MaxMind + * account. + * @param id This is a UUID that identifies the minFraud request. + * @param ipAddress The {@code IpAddress} model object. + * @param queriesRemaining The approximate number of queries remaining for this service before your + * account runs out of funds. + * @param riskScore This returns the risk score, from 0.01 to 99. A higher score indicates + * a higher risk of fraud. For example, a score of 20 indicates a 20% + * chance that a transaction is fraudulent. We never return a risk score of + * 0, since all transactions have the possibility of being fraudulent. + * Likewise, we never return a risk score of 100. + * @param warnings An unmodifiable list containing warning objects that detail issues with + * the request such as invalid or unknown inputs. It is highly recommended + * that you check this list for issues when integrating the web service. */ -public class ScoreResponse extends AbstractModel { - private final Disposition disposition; - private final Double fundsRemaining; - private final UUID id; - private final Integer queriesRemaining; - private final Double riskScore; - private final List warnings; - private final ScoreIpAddress ipAddress; +public record ScoreResponse( + @JsonProperty("disposition") + Disposition disposition, + + @JsonProperty("funds_remaining") + Double fundsRemaining, + + @JsonProperty("id") + UUID id, + + @JsonProperty("ip_address") + ScoreIpAddress ipAddress, + + @JsonProperty("queries_remaining") + Integer queriesRemaining, + + @JsonProperty("risk_score") + Double riskScore, + + @JsonProperty("warnings") + List warnings +) implements JsonSerializable { + + /** + * Compact canonical constructor that sets defaults for null values. + */ + public ScoreResponse { + disposition = disposition != null ? disposition : new Disposition(); + ipAddress = ipAddress != null ? ipAddress : new ScoreIpAddress(); + warnings = warnings != null ? List.copyOf(warnings) : List.of(); + } /** - * Constructor for {@code ScoreResponse}. - * - * @param disposition The disposition set by your custom rules. - * @param fundsRemaining The approximate US dollar value of the funds. - * @param id This is a UUID that identifies the minFraud request. - * @param ipAddress The {@code IpAddress} model object. - * @param queriesRemaining The number of queries remaining. - * @param riskScore The risk score. - * @param warnings A list containing warning objects. + * Constructs an instance of {@code ScoreResponse} with no data. */ - public ScoreResponse( - @JsonProperty("disposition") Disposition disposition, - @JsonProperty("funds_remaining") Double fundsRemaining, - @JsonProperty("id") UUID id, - @JsonProperty("ip_address") ScoreIpAddress ipAddress, - @JsonProperty("queries_remaining") Integer queriesRemaining, - @JsonProperty("risk_score") Double riskScore, - @JsonProperty("warnings") List warnings - ) { - this.disposition = disposition == null ? new Disposition() : disposition; - this.fundsRemaining = fundsRemaining; - this.id = id; - this.ipAddress = ipAddress == null ? new ScoreIpAddress() : ipAddress; - this.queriesRemaining = queriesRemaining; - this.riskScore = riskScore; - this.warnings = - Collections.unmodifiableList(warnings == null ? List.of() : warnings); + public ScoreResponse() { + this(null, null, null, null, null, null, null); } /** * @return The disposition set by your custom rules. + * @deprecated Use {@link #disposition()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("disposition") - public final Disposition getDisposition() { - return disposition; + public Disposition getDisposition() { + return disposition(); } - /** * @return The approximate US dollar value of the funds remaining on your MaxMind account. + * @deprecated Use {@link #fundsRemaining()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("funds_remaining") - public final Double getFundsRemaining() { - return fundsRemaining; + public Double getFundsRemaining() { + return fundsRemaining(); } /** * @return This is a UUID that identifies the minFraud request. + * @deprecated Use {@link #id()} instead. This method will be removed in 5.0.0. */ - public final UUID getId() { - return id; + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("id") + public UUID getId() { + return id(); } /** * @return The {@code IpAddress} model object. + * @deprecated Use {@link #ipAddress()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("ip_address") public IpAddressInterface getIpAddress() { - return ipAddress; + return ipAddress(); } /** * @return The approximate number of queries remaining for this service before your account runs * out of funds. + * @deprecated Use {@link #queriesRemaining()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("queries_remaining") - public final Integer getQueriesRemaining() { - return queriesRemaining; + public Integer getQueriesRemaining() { + return queriesRemaining(); } /** @@ -94,18 +119,23 @@ public final Integer getQueriesRemaining() { * of fraud. For example, a score of 20 indicates a 20% chance that a transaction is * fraudulent. We never return a risk score of 0, since all transactions have the * possibility of being fraudulent. Likewise, we never return a risk score of 100. + * @deprecated Use {@link #riskScore()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("risk_score") - public final Double getRiskScore() { - return riskScore; + public Double getRiskScore() { + return riskScore(); } /** * @return An unmodifiable list containing warning objects that detail issues with the request * such as invalid or unknown inputs. It is highly recommended that you check this list for * issues when integrating the web service. + * @deprecated Use {@link #warnings()} instead. This method will be removed in 5.0.0. */ - public final List getWarnings() { - return warnings; + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("warnings") + public List getWarnings() { + return warnings(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/ShippingAddress.java b/src/main/java/com/maxmind/minfraud/response/ShippingAddress.java index 7f3d9bfc..6f4bbcac 100644 --- a/src/main/java/com/maxmind/minfraud/response/ShippingAddress.java +++ b/src/main/java/com/maxmind/minfraud/response/ShippingAddress.java @@ -1,66 +1,99 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; +import com.maxmind.minfraud.JsonSerializable; /** * This class contains minFraud response data related to the shipping address. + * + * @param distanceToBillingAddress The distance in kilometers from the shipping address to billing + * address. + * @param distanceToIpLocation The distance in kilometers from the address to the IP location. + * This will be null if there is no value in the response. + * @param isHighRisk This returns true if the shipping address is an address + * associated with fraudulent transactions. It returns false when + * the address is not associated with increased risk. If the address + * could not be parsed or was not provided, null is returned. + * @param isInIpCountry This returns true if the address is in the IP country. It is + * false when the address is not in the IP country. If the address + * could not be parsed or was not provided or the IP address could + * not be geolocated, then null will be returned. + * @param isPostalInCity This will return true if the postal code provided with the + * address is in the city for the address. It will return false when + * the postal code is not in the city. If the address was not + * provided or could not be parsed, null will be returned. + * @param latitude The latitude associated with the address. This will be null if + * there is no value in the response. + * @param longitude The longitude associated with the address. This will be null if + * there is no value in the response. */ -public final class ShippingAddress extends AbstractAddress { - private final Boolean isHighRisk; - private final Integer distanceToBillingAddress; +public record ShippingAddress( + @JsonProperty("distance_to_billing_address") + Integer distanceToBillingAddress, + + @JsonProperty("distance_to_ip_location") + Integer distanceToIpLocation, + + @JsonProperty("is_high_risk") + Boolean isHighRisk, + + @JsonProperty("is_in_ip_country") + Boolean isInIpCountry, + + @JsonProperty("is_postal_in_city") + Boolean isPostalInCity, + + @JsonProperty("latitude") + Double latitude, + + @JsonProperty("longitude") + Double longitude +) implements JsonSerializable { /** - * Constructor for {@code ShippingAddress}. - * - * @param distanceToBillingAddress The distance in kilometers from the shipping address to the - * billing address. - * @param distanceToIpLocation The distance in kilometers from the shipping address to the - * IP location. - * @param isHighRisk This is true if the shipping address is associated with - * fraudulent transactions. - * @param isInIpCountry This is true if the shipping address is in the IP country. - * @param isPostalInCity This is true if the shipping postal code is in the city for - * the IP location. - * @param latitude The latitude associated with the IP address. - * @param longitude The longitude associated with the IP address. + * Constructs an instance of {@code ShippingAddress} with no data. */ - public ShippingAddress( - @JsonProperty("distance_to_billing_address") Integer distanceToBillingAddress, - @JsonProperty("distance_to_ip_location") Integer distanceToIpLocation, - @JsonProperty("is_high_risk") Boolean isHighRisk, - @JsonProperty("is_in_ip_country") Boolean isInIpCountry, - @JsonProperty("is_postal_in_city") Boolean isPostalInCity, - @JsonProperty("latitude") Double latitude, - @JsonProperty("longitude") Double longitude - ) { - super(distanceToIpLocation, isInIpCountry, isPostalInCity, latitude, longitude); - this.distanceToBillingAddress = distanceToBillingAddress; - this.isHighRisk = isHighRisk; + public ShippingAddress() { + this(null, null, null, null, null, null, null); } /** - * Constructor for {@code ShippingAddress}. + * @return The distance in kilometers from the shipping address to billing address. + * @deprecated Use {@link #distanceToBillingAddress()} instead. This method will be removed + * in 5.0.0. */ - public ShippingAddress() { - this(null, null, null, null, null, null, null); + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("distance_to_billing_address") + public Integer getDistanceToBillingAddress() { + return distanceToBillingAddress(); } /** - * @return This returns true if the shipping address is an address associated with fraudulent - * transactions. It returns false when the address is not associated with increased risk. If - * the address could not be parsed or was not provided, null is returned. + * @return The latitude associated with the address. + * @deprecated Use {@link #latitude()} instead. This method will be removed in 5.0.0. */ - @JsonProperty("is_high_risk") - public Boolean isHighRisk() { - return isHighRisk; + @Deprecated(since = "4.0.0", forRemoval = true) + public Double getLatitude() { + return latitude(); } /** - * @return The distance in kilometers from the shipping address to billing address. + * @return The longitude associated with the address. + * @deprecated Use {@link #longitude()} instead. This method will be removed in 5.0.0. */ - @JsonProperty("distance_to_billing_address") - public Integer getDistanceToBillingAddress() { - return distanceToBillingAddress; + @Deprecated(since = "4.0.0", forRemoval = true) + public Double getLongitude() { + return longitude(); + } + + /** + * @return The distance in kilometers from the address to the IP location. + * @deprecated Use {@link #distanceToIpLocation()} instead. This method will be removed in + * 5.0.0. + */ + @Deprecated(since = "4.0.0", forRemoval = true) + public Integer getDistanceToIpLocation() { + return distanceToIpLocation(); } } diff --git a/src/main/java/com/maxmind/minfraud/response/Warning.java b/src/main/java/com/maxmind/minfraud/response/Warning.java index 05d73404..4aaa0fb3 100644 --- a/src/main/java/com/maxmind/minfraud/response/Warning.java +++ b/src/main/java/com/maxmind/minfraud/response/Warning.java @@ -1,32 +1,53 @@ package com.maxmind.minfraud.response; import com.fasterxml.jackson.annotation.JsonProperty; -import com.maxmind.minfraud.AbstractModel; +import com.maxmind.minfraud.JsonSerializable; /** * This class represents a warning returned by the web service. + * + * @param code This provides a machine-readable code identifying the warning. Although more + * codes may be added in the future, the current codes are: + * + *
    + *
  • BILLING_CITY_NOT_FOUND – the billing city could not be found in + * our database.
  • + *
  • BILLING_COUNTRY_NOT_FOUND – the billing country could not be + * found in our database.
  • + *
  • BILLING_POSTAL_NOT_FOUND – the billing postal could not be found + * in our database.
  • + *
  • INPUT_INVALID – the value associated with the key does not meet + * the required constraints, e.g., "United States" in a field that + * requires a two-letter country code.
  • + *
  • INPUT_UNKNOWN – an unknown key was encountered in the request + * body.
  • + *
  • IP_ADDRESS_NOT_FOUND – the IP address could not be + * geolocated.
  • + *
  • SHIPPING_CITY_NOT_FOUND – the shipping city could not be found + * in our database.
  • + *
  • SHIPPING_COUNTRY_NOT_FOUND – the shipping country could not be + * found in our database.
  • + *
  • SHIPPING_POSTAL_NOT_FOUND – the shipping postal could not be + * found in our database.
  • + *
+ * @param warning This field provides a human-readable explanation of the warning. The + * description may change at any time and should not be matched against. + * @param inputPointer This is a JSON Pointer to the input that the warning is associated with. For + * instance, if the warning was about the billing city, the value would be + * "/billing/city". See + * RFC 6901 for the JSON + * Pointer spec. */ -public final class Warning extends AbstractModel { - private final String code; - private final String warning; - private final String inputPointer; +public record Warning( + @JsonProperty("code") + String code, - /** - * Constructor for {@code Warning}. - * - * @param code The warning code. - * @param warning The warning message. - * @param inputPointer The JSON Pointer to the input that the warning is associated with. - */ - public Warning( - @JsonProperty("code") String code, - @JsonProperty("warning") String warning, - @JsonProperty("input_pointer") String inputPointer - ) { - this.code = code; - this.warning = warning; - this.inputPointer = inputPointer; - } + @JsonProperty("warning") + String warning, + + @JsonProperty("input_pointer") + String inputPointer +) implements JsonSerializable { /** * This provides a machine-readable code identifying the warning. Although more codes may be @@ -55,17 +76,23 @@ public Warning( * * * @return The warning code. + * @deprecated Use {@link #code()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("code") public String getCode() { - return this.code; + return code(); } /** * @return This field provides a human-readable explanation of the warning. The description may * change at any time and should not be matched against. + * @deprecated Use {@link #warning()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) + @JsonProperty("warning") public String getWarning() { - return this.warning; + return warning(); } /** @@ -73,9 +100,11 @@ public String getWarning() { * instance, if the warning was about the billing city, the value would be "/billing/city". * See * RFC 6901 for the JSON Pointer spec. + * @deprecated Use {@link #inputPointer()} instead. This method will be removed in 5.0.0. */ + @Deprecated(since = "4.0.0", forRemoval = true) @JsonProperty("input_pointer") public String getInputPointer() { - return this.inputPointer; + return inputPointer(); } } diff --git a/src/test/java/com/maxmind/minfraud/response/AbstractAddressTest.java b/src/test/java/com/maxmind/minfraud/response/AbstractAddressTest.java deleted file mode 100644 index 8f870edc..00000000 --- a/src/test/java/com/maxmind/minfraud/response/AbstractAddressTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.maxmind.minfraud.response; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -abstract class AbstractAddressTest extends AbstractOutputTest { - private static final double DELTA = 1e-15; - - void testAddress(AbstractAddress address) { - assertTrue(address.isInIpCountry(), "correct isInIpCountry"); - assertTrue(address.isPostalInCity(), "correct isPostalInCity"); - assertEquals( - 100, - address.getDistanceToIpLocation().longValue(), - "correct getDistanceToIpLocation" - ); - assertEquals( - 32.1, - address.getLongitude(), - AbstractAddressTest.DELTA, - "correct longitude" - ); - assertEquals( - 43.1, - address.getLatitude(), - AbstractAddressTest.DELTA, - "correct latitude" - ); - } -} diff --git a/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java b/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java index ecc1307e..e4a68b4d 100644 --- a/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java +++ b/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java @@ -1,9 +1,13 @@ package com.maxmind.minfraud.response; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import com.fasterxml.jackson.jr.ob.JSON; import org.junit.jupiter.api.Test; -public class BillingAddressTest extends AbstractAddressTest { +public class BillingAddressTest extends AbstractOutputTest { + private static final double DELTA = 1e-15; @Test public void testBillingAddress() throws Exception { @@ -20,6 +24,24 @@ public void testBillingAddress() throws Exception { .finish() ); - this.testAddress(address); + assertTrue(address.isInIpCountry(), "correct isInIpCountry"); + assertTrue(address.isPostalInCity(), "correct isPostalInCity"); + assertEquals( + 100, + address.getDistanceToIpLocation().longValue(), + "correct getDistanceToIpLocation" + ); + assertEquals( + 32.1, + address.getLongitude(), + DELTA, + "correct longitude" + ); + assertEquals( + 43.1, + address.getLatitude(), + DELTA, + "correct latitude" + ); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java b/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java index 1b9d255a..a2aa379a 100644 --- a/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java +++ b/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java @@ -12,7 +12,7 @@ public class ScoreResponseTest extends AbstractOutputTest { public void testScore() throws Exception { String id = "b643d445-18b2-4b9d-bad4-c9c4366e402a"; ScoreResponse score = this.deserialize( - InsightsResponse.class, + ScoreResponse.class, JSON.std .composeString() .startObject() diff --git a/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java b/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java index a3892959..b8474ddc 100644 --- a/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java +++ b/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java @@ -2,11 +2,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.jr.ob.JSON; import org.junit.jupiter.api.Test; -public class ShippingAddressTest extends AbstractAddressTest { +public class ShippingAddressTest extends AbstractOutputTest { + private static final double DELTA = 1e-15; @Test public void testShippingAddress() throws Exception { @@ -26,7 +28,25 @@ public void testShippingAddress() throws Exception { .finish() ); - this.testAddress(address); + assertTrue(address.isInIpCountry(), "correct isInIpCountry"); + assertTrue(address.isPostalInCity(), "correct isPostalInCity"); + assertEquals( + 100, + address.getDistanceToIpLocation().longValue(), + "correct getDistanceToIpLocation" + ); + assertEquals( + 32.1, + address.getLongitude(), + DELTA, + "correct longitude" + ); + assertEquals( + 43.1, + address.getLatitude(), + DELTA, + "correct latitude" + ); assertFalse(address.isHighRisk(), "is high risk"); assertEquals( diff --git a/src/test/resources/test-data/factors-response.json b/src/test/resources/test-data/factors-response.json index 41eec3f6..c0fa536a 100644 --- a/src/test/resources/test-data/factors-response.json +++ b/src/test/resources/test-data/factors-response.json @@ -80,6 +80,22 @@ "zh-CN": "\u82f1\u56fd" } }, + "represented_country": { + "geoname_id": 6252001, + "is_in_european_union": false, + "iso_code": "US", + "names": { + "de": "Vereinigte Staaten", + "en": "United States", + "es": "Estados Unidos", + "fr": "\u00c9tats-Unis", + "ja": "\u30a2\u30e1\u30ea\u30ab\u5408\u8846\u56fd", + "pt-BR": "Estados Unidos", + "ru": "\u0421\u0428\u0410", + "zh-CN": "\u7f8e\u56fd" + }, + "type": "military" + }, "subdivisions": [ { "confidence": 42, From a422f355a095431479dc83eca940689c3418cd13 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 14:02:29 -0700 Subject: [PATCH 3/8] Use record-style method naming for request and exception classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated all request and exception classes to use record-style method naming by removing the "get" prefix from accessor methods. This provides consistency with the response classes that were recently converted to Java records. Request classes updated: - Account, Email, Device, CreditCard, Transaction, TransactionReport - Billing, Shipping, AbstractLocation, ShoppingCartItem - Payment, Order, Event, CustomInputs Exception classes updated: - HttpException (httpStatus, uri) - InvalidRequestException (code, httpStatus, uri) Unlike response classes, no deprecated helper methods were added as these methods are primarily used for serialization. All 210 tests pass successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CHANGELOG.md | 15 +- .../minfraud/exception/HttpException.java | 4 +- .../exception/InvalidRequestException.java | 6 +- .../minfraud/request/AbstractLocation.java | 22 +-- .../com/maxmind/minfraud/request/Account.java | 4 +- .../maxmind/minfraud/request/CreditCard.java | 20 +-- .../minfraud/request/CustomInputs.java | 2 +- .../com/maxmind/minfraud/request/Device.java | 10 +- .../com/maxmind/minfraud/request/Email.java | 4 +- .../com/maxmind/minfraud/request/Event.java | 12 +- .../com/maxmind/minfraud/request/Order.java | 12 +- .../com/maxmind/minfraud/request/Payment.java | 6 +- .../maxmind/minfraud/request/Shipping.java | 2 +- .../minfraud/request/ShoppingCartItem.java | 8 +- .../maxmind/minfraud/request/Transaction.java | 22 +-- .../minfraud/request/TransactionReport.java | 14 +- .../minfraud/exception/HttpExceptionTest.java | 4 +- .../InvalidRequestExceptionTest.java | 6 +- .../request/AbstractLocationTest.java | 22 +-- .../maxmind/minfraud/request/AccountTest.java | 4 +- .../minfraud/request/CreditCardTest.java | 24 +-- .../minfraud/request/CustomInputsTest.java | 2 +- .../maxmind/minfraud/request/DeviceTest.java | 14 +- .../maxmind/minfraud/request/EmailTest.java | 168 +++++++++--------- .../maxmind/minfraud/request/EventTest.java | 20 +-- .../maxmind/minfraud/request/OrderTest.java | 14 +- .../maxmind/minfraud/request/PaymentTest.java | 10 +- .../minfraud/request/ShippingTest.java | 2 +- .../minfraud/request/ShoppingCartTest.java | 10 +- .../request/TransactionReportTest.java | 22 +-- .../minfraud/request/TransactionTest.java | 26 +-- 31 files changed, 262 insertions(+), 249 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98345192..ae136643 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ CHANGELOG * 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. + `InvalidRequestException`. Use `uri()` instead. * BREAKING: Removed deprecated constructors from `FactorsResponse`, `InsightsResponse`, and `Phone` classes. * BREAKING: Removed deprecated `Subscores` class and @@ -38,6 +38,19 @@ CHANGELOG * All response classes now implement `JsonSerializable` instead of extending `AbstractModel`. The `toJson()` method remains available for serialization. * Removed the `AbstractAddress` interface. +* BREAKING: Updated all request classes to use record-style method naming. The + `get` prefix has been removed from all accessor methods (e.g., use `userId()` + instead of `getUserId()`). This applies to all request classes including + `Account`, `Billing`, `CreditCard`, `CustomInputs`, `Device`, `Email`, + `Event`, `Order`, `Payment`, `Shipping`, `ShoppingCartItem`, `Transaction`, + and `TransactionReport`. Unlike response classes, no deprecated helper methods + were added as these methods are primarily used for serialization. +* BREAKING: Updated exception classes to use record-style method naming. The + `get` prefix has been removed from all accessor methods. For `HttpException`, + use `httpStatus()` and `uri()` instead of `getHttpStatus()` and `getUri()`. + For `InvalidRequestException`, use `code()`, `httpStatus()`, and `uri()` + instead of `getCode()`, `getHttpStatus()`, and `getUri()`. No deprecated + helper methods were added. * Added `CREDIT_APPLICATION` and `FUND_TRANSFER` to the `Event.Type` enum. * Added the input `/event/party`. This is the party submitting the transaction. You may provide this using the `party` method on diff --git a/src/main/java/com/maxmind/minfraud/exception/HttpException.java b/src/main/java/com/maxmind/minfraud/exception/HttpException.java index bcab2d50..e4b644f7 100644 --- a/src/main/java/com/maxmind/minfraud/exception/HttpException.java +++ b/src/main/java/com/maxmind/minfraud/exception/HttpException.java @@ -38,14 +38,14 @@ public HttpException(String message, int httpStatus, URI uri, /** * @return the HTTP status of the query that caused the exception. */ - public int getHttpStatus() { + public int httpStatus() { return httpStatus; } /** * @return the URI queried. */ - public URI getUri() { + public URI uri() { return this.uri; } diff --git a/src/main/java/com/maxmind/minfraud/exception/InvalidRequestException.java b/src/main/java/com/maxmind/minfraud/exception/InvalidRequestException.java index a128a8f1..d1637e45 100644 --- a/src/main/java/com/maxmind/minfraud/exception/InvalidRequestException.java +++ b/src/main/java/com/maxmind/minfraud/exception/InvalidRequestException.java @@ -42,7 +42,7 @@ public InvalidRequestException(String message, String code, int httpStatus, /** * @return The error code returned by the MaxMind web service. */ - public final String getCode() { + public final String code() { return code; } @@ -50,14 +50,14 @@ public final String getCode() { * @return The integer HTTP status returned by the MaxMind web service. Will be 0 if it was not * set at throw time. */ - public final int getHttpStatus() { + public final int httpStatus() { return httpStatus; } /** * @return the URI queried. */ - public URI getUri() { + public URI uri() { return this.uri; } diff --git a/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java b/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java index 1fcf130a..b8452e34 100644 --- a/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java +++ b/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java @@ -168,7 +168,7 @@ public final T phoneNumber(String number) { * @return The first name associated with the address */ @JsonProperty("first_name") - public final String getFirstName() { + public final String firstName() { return firstName; } @@ -176,7 +176,7 @@ public final String getFirstName() { * @return The last name associated with the address */ @JsonProperty("last_name") - public final String getLastName() { + public final String lastName() { return lastName; } @@ -184,7 +184,7 @@ public final String getLastName() { * @return The company name associated with the address */ @JsonProperty("company") - public final String getCompany() { + public final String company() { return company; } @@ -193,7 +193,7 @@ public final String getCompany() { * @return The first line of the address */ @JsonProperty("address") - public final String getAddress() { + public final String address() { return address; } @@ -202,7 +202,7 @@ public final String getAddress() { * @return The second line of the address */ @JsonProperty("address_2") - public final String getAddress2() { + public final String address2() { return address2; } @@ -211,7 +211,7 @@ public final String getAddress2() { * @return The city associated with the address */ @JsonProperty("city") - public final String getCity() { + public final String city() { return city; } @@ -220,7 +220,7 @@ public final String getCity() { * @return The region code associated with the address */ @JsonProperty("region") - public final String getRegion() { + public final String region() { return region; } @@ -229,7 +229,7 @@ public final String getRegion() { * @return The country associated with the address */ @JsonProperty("country") - public final String getCountry() { + public final String country() { return country; } @@ -237,7 +237,7 @@ public final String getCountry() { * @return The postal code associated with the address */ @JsonProperty("postal") - public final String getPostal() { + public final String postal() { return postal; } @@ -245,7 +245,7 @@ public final String getPostal() { * @return The phone number associated with the address */ @JsonProperty("phone_number") - public final String getPhoneNumber() { + public final String phoneNumber() { return phoneNumber; } @@ -253,7 +253,7 @@ public final String getPhoneNumber() { * @return The phone number country code associated with the address */ @JsonProperty("phone_country_code") - public final String getPhoneCountryCode() { + public final String phoneCountryCode() { return phoneCountryCode; } } diff --git a/src/main/java/com/maxmind/minfraud/request/Account.java b/src/main/java/com/maxmind/minfraud/request/Account.java index 6894ffe9..3852c458 100644 --- a/src/main/java/com/maxmind/minfraud/request/Account.java +++ b/src/main/java/com/maxmind/minfraud/request/Account.java @@ -70,7 +70,7 @@ public Account build() { * @return The user ID. */ @JsonProperty("user_id") - public String getUserId() { + public String userId() { return userId; } @@ -78,7 +78,7 @@ public String getUserId() { * @return The MD5 of the username passed to the builder. */ @JsonProperty("username_md5") - public String getUsernameMd5() { + public String usernameMd5() { return usernameMd5; } } \ No newline at end of file diff --git a/src/main/java/com/maxmind/minfraud/request/CreditCard.java b/src/main/java/com/maxmind/minfraud/request/CreditCard.java index 9ec8dbb5..beb5836d 100644 --- a/src/main/java/com/maxmind/minfraud/request/CreditCard.java +++ b/src/main/java/com/maxmind/minfraud/request/CreditCard.java @@ -195,7 +195,7 @@ public CreditCard build() { * @return The issuer ID number. */ @JsonProperty("issuer_id_number") - public String getIssuerIdNumber() { + public String issuerIdNumber() { return issuerIdNumber; } @@ -203,7 +203,7 @@ public String getIssuerIdNumber() { * @return The last two or four digits of the credit card number. */ @JsonProperty("last_digits") - public String getLastDigits() { + public String lastDigits() { return lastDigits; } @@ -211,7 +211,7 @@ public String getLastDigits() { * @return The name of the issuing bank as provided by the end user. */ @JsonProperty("bank_name") - public String getBankName() { + public String bankName() { return bankName; } @@ -219,7 +219,7 @@ public String getBankName() { * @return The phone country code for the issuing bank as provided by the end user. */ @JsonProperty("bank_phone_country_code") - public String getBankPhoneCountryCode() { + public String bankPhoneCountryCode() { return bankPhoneCountryCode; } @@ -228,7 +228,7 @@ public String getBankPhoneCountryCode() { * end user. */ @JsonProperty("bank_phone_number") - public String getBankPhoneNumber() { + public String bankPhoneNumber() { return bankPhoneNumber; } @@ -237,7 +237,7 @@ public String getBankPhoneNumber() { * located. */ @JsonProperty("country") - public String getCountry() { + public String country() { return country; } @@ -246,7 +246,7 @@ public String getCountry() { * card processor. The minFraud service supports the standard AVS codes. */ @JsonProperty("avs_result") - public Character getAvsResult() { + public Character avsResult() { return avsResult; } @@ -254,7 +254,7 @@ public Character getAvsResult() { * @return The card verification value (CVV) code as provided by the payment processor. */ @JsonProperty("cvv_result") - public Character getCvvResult() { + public Character cvvResult() { return cvvResult; } @@ -262,7 +262,7 @@ public Character getCvvResult() { * @return A credit card token uniquely identifying the card. */ @JsonProperty("token") - public String getToken() { + public String token() { return token; } @@ -274,7 +274,7 @@ public String getToken() { * resulted in another outcome other than success or failure. */ @JsonProperty("was_3d_secure_successful") - public Boolean getWas3dSecureSuccessful() { + public Boolean was3dSecureSuccessful() { return was3dSecureSuccessful; } } diff --git a/src/main/java/com/maxmind/minfraud/request/CustomInputs.java b/src/main/java/com/maxmind/minfraud/request/CustomInputs.java index e93c5fdd..4d72ae19 100644 --- a/src/main/java/com/maxmind/minfraud/request/CustomInputs.java +++ b/src/main/java/com/maxmind/minfraud/request/CustomInputs.java @@ -103,7 +103,7 @@ private void validateKey(String key) { * @return an unmodifiable map containing the custom inputs. */ @JsonAnyGetter - public Map getInputs() { + public Map inputs() { return inputs; } } diff --git a/src/main/java/com/maxmind/minfraud/request/Device.java b/src/main/java/com/maxmind/minfraud/request/Device.java index 47d4192b..48a03e8f 100644 --- a/src/main/java/com/maxmind/minfraud/request/Device.java +++ b/src/main/java/com/maxmind/minfraud/request/Device.java @@ -112,7 +112,7 @@ public Device build() { * @return The "User-Agent" header. */ @JsonProperty("user_agent") - public String getUserAgent() { + public String userAgent() { return userAgent; } @@ -120,7 +120,7 @@ public String getUserAgent() { * @return The "Accept-Language" header. */ @JsonProperty("accept_language") - public String getAcceptLanguage() { + public String acceptLanguage() { return acceptLanguage; } @@ -128,7 +128,7 @@ public String getAcceptLanguage() { * @return The session age. */ @JsonProperty("session_age") - public Double getSessionAge() { + public Double sessionAge() { return sessionAge; } @@ -136,7 +136,7 @@ public Double getSessionAge() { * @return The session id. */ @JsonProperty("session_id") - public String getSessionId() { + public String sessionId() { return sessionId; } @@ -144,7 +144,7 @@ public String getSessionId() { * @return The IP address used in the transaction. */ @JsonProperty("ip_address") - public InetAddress getIpAddress() { + public InetAddress ipAddress() { return ipAddress; } } diff --git a/src/main/java/com/maxmind/minfraud/request/Email.java b/src/main/java/com/maxmind/minfraud/request/Email.java index fe2562b6..7ad23384 100644 --- a/src/main/java/com/maxmind/minfraud/request/Email.java +++ b/src/main/java/com/maxmind/minfraud/request/Email.java @@ -395,7 +395,7 @@ public Email build() { * {@link Builder#hashAddress()} as well, or null if you did not set an email address. */ @JsonProperty("address") - public String getAddress() { + public String address() { if (address == null) { return null; } @@ -566,7 +566,7 @@ private static boolean isValidDomainLabel(String label) { * @return The domain of the email address used in the transaction. */ @JsonProperty("domain") - public String getDomain() { + public String domain() { return domain; } } diff --git a/src/main/java/com/maxmind/minfraud/request/Event.java b/src/main/java/com/maxmind/minfraud/request/Event.java index 1ca0da1a..faa93e98 100644 --- a/src/main/java/com/maxmind/minfraud/request/Event.java +++ b/src/main/java/com/maxmind/minfraud/request/Event.java @@ -106,7 +106,7 @@ public Event build() { * @return The party submitting the transaction. */ @JsonProperty("party") - public Party getParty() { + public Party party() { return party; } @@ -114,7 +114,7 @@ public Party getParty() { * @return The transaction ID. */ @JsonProperty("transaction_id") - public String getTransactionId() { + public String transactionId() { return transactionId; } @@ -122,7 +122,7 @@ public String getTransactionId() { * @return The shop ID. */ @JsonProperty("shop_id") - public String getShopId() { + public String shopId() { return shopId; } @@ -130,7 +130,7 @@ public String getShopId() { * @return The date and time of the event. */ @JsonIgnore - public Date getTime() { + public Date time() { return Date.from(time.toInstant()); } @@ -138,7 +138,7 @@ public Date getTime() { * @return The date and time of the event. */ @JsonProperty("time") - public ZonedDateTime getDateTime() { + public ZonedDateTime dateTime() { return time; } @@ -146,7 +146,7 @@ public ZonedDateTime getDateTime() { * @return The type of the event. */ @JsonProperty("type") - public Type getType() { + public Type type() { return type; } diff --git a/src/main/java/com/maxmind/minfraud/request/Order.java b/src/main/java/com/maxmind/minfraud/request/Order.java index 69838b21..99c39c3c 100644 --- a/src/main/java/com/maxmind/minfraud/request/Order.java +++ b/src/main/java/com/maxmind/minfraud/request/Order.java @@ -144,7 +144,7 @@ public Order build() { * @return The total order amount. */ @JsonProperty("amount") - public BigDecimal getAmount() { + public BigDecimal amount() { return amount; } @@ -152,7 +152,7 @@ public BigDecimal getAmount() { * @return The currency code. */ @JsonProperty("currency") - public String getCurrency() { + public String currency() { return currency; } @@ -160,7 +160,7 @@ public String getCurrency() { * @return The discount codes. */ @JsonProperty("discount_code") - public String getDiscountCode() { + public String discountCode() { return discountCode; } @@ -168,7 +168,7 @@ public String getDiscountCode() { * @return The affiliate ID. */ @JsonProperty("affiliate_id") - public String getAffiliateId() { + public String affiliateId() { return affiliateId; } @@ -176,7 +176,7 @@ public String getAffiliateId() { * @return The sub-affiliate ID. */ @JsonProperty("subaffiliate_id") - public String getSubaffiliateId() { + public String subaffiliateId() { return subaffiliateId; } @@ -184,7 +184,7 @@ public String getSubaffiliateId() { * @return The referrer URI. */ @JsonProperty("referrer_uri") - public URI getReferrerUri() { + public URI referrerUri() { return referrerUri; } diff --git a/src/main/java/com/maxmind/minfraud/request/Payment.java b/src/main/java/com/maxmind/minfraud/request/Payment.java index 47ac7f26..a4949f66 100644 --- a/src/main/java/com/maxmind/minfraud/request/Payment.java +++ b/src/main/java/com/maxmind/minfraud/request/Payment.java @@ -80,7 +80,7 @@ public Payment build() { * @return The payment method. */ @JsonProperty("method") - public Method getMethod() { + public Method method() { return method; } @@ -88,7 +88,7 @@ public Method getMethod() { * @return The payment processor. */ @JsonProperty("processor") - public Processor getProcessor() { + public Processor processor() { return processor; } @@ -104,7 +104,7 @@ public Boolean wasAuthorized() { * @return The decline code. */ @JsonProperty("decline_code") - public String getDeclineCode() { + public String declineCode() { return declineCode; } diff --git a/src/main/java/com/maxmind/minfraud/request/Shipping.java b/src/main/java/com/maxmind/minfraud/request/Shipping.java index e2ce8a94..43ab51ad 100644 --- a/src/main/java/com/maxmind/minfraud/request/Shipping.java +++ b/src/main/java/com/maxmind/minfraud/request/Shipping.java @@ -42,7 +42,7 @@ public Shipping build() { * @return The shipping delivery speed for the order. */ @JsonProperty("delivery_speed") - public DeliverySpeed getDeliverySpeed() { + public DeliverySpeed deliverySpeed() { return deliverySpeed; } diff --git a/src/main/java/com/maxmind/minfraud/request/ShoppingCartItem.java b/src/main/java/com/maxmind/minfraud/request/ShoppingCartItem.java index 7af9e715..fec63ace 100644 --- a/src/main/java/com/maxmind/minfraud/request/ShoppingCartItem.java +++ b/src/main/java/com/maxmind/minfraud/request/ShoppingCartItem.java @@ -95,7 +95,7 @@ public ShoppingCartItem build() { * @return The category of the item. */ @JsonProperty("category") - public String getCategory() { + public String category() { return category; } @@ -103,7 +103,7 @@ public String getCategory() { * @return The ID of the item. */ @JsonProperty("item_id") - public String getItemId() { + public String itemId() { return itemId; } @@ -111,7 +111,7 @@ public String getItemId() { * @return The quantity of the item. */ @JsonProperty("quantity") - public Integer getQuantity() { + public Integer quantity() { return quantity; } @@ -119,7 +119,7 @@ public Integer getQuantity() { * @return The price of the item. */ @JsonProperty("price") - public BigDecimal getPrice() { + public BigDecimal price() { return price; } } diff --git a/src/main/java/com/maxmind/minfraud/request/Transaction.java b/src/main/java/com/maxmind/minfraud/request/Transaction.java index 47beeb6f..66e275a4 100644 --- a/src/main/java/com/maxmind/minfraud/request/Transaction.java +++ b/src/main/java/com/maxmind/minfraud/request/Transaction.java @@ -180,7 +180,7 @@ public Transaction build() { * @return The Account object. */ @JsonProperty("account") - public Account getAccount() { + public Account account() { return account; } @@ -188,7 +188,7 @@ public Account getAccount() { * @return The Billing object. */ @JsonProperty("billing") - public Billing getBilling() { + public Billing billing() { return billing; } @@ -196,7 +196,7 @@ public Billing getBilling() { * @return The CreditCard object. */ @JsonProperty("credit_card") - public CreditCard getCreditCard() { + public CreditCard creditCard() { return creditCard; } @@ -204,7 +204,7 @@ public CreditCard getCreditCard() { * @return The CustomInputs object. */ @JsonProperty("custom_inputs") - public CustomInputs getCustomInputs() { + public CustomInputs customInputs() { return customInputs; } @@ -212,7 +212,7 @@ public CustomInputs getCustomInputs() { * @return The Device object. */ @JsonProperty("device") - public Device getDevice() { + public Device device() { return device; } @@ -220,7 +220,7 @@ public Device getDevice() { * @return The Email object. */ @JsonProperty("email") - public Email getEmail() { + public Email email() { return email; } @@ -228,7 +228,7 @@ public Email getEmail() { * @return The Event object. */ @JsonProperty("event") - public Event getEvent() { + public Event event() { return event; } @@ -236,7 +236,7 @@ public Event getEvent() { * @return The Order object. */ @JsonProperty("order") - public Order getOrder() { + public Order order() { return order; } @@ -244,7 +244,7 @@ public Order getOrder() { * @return The Payment object. */ @JsonProperty("payment") - public Payment getPayment() { + public Payment payment() { return payment; } @@ -252,7 +252,7 @@ public Payment getPayment() { * @return The Shipping object. */ @JsonProperty("shipping") - public Shipping getShipping() { + public Shipping shipping() { return shipping; } @@ -260,7 +260,7 @@ public Shipping getShipping() { * @return A list of items in the shopping cart. */ @JsonProperty("shopping_cart") - public List getShoppingCart() { + public List shoppingCart() { return List.copyOf(shoppingCart); } } diff --git a/src/main/java/com/maxmind/minfraud/request/TransactionReport.java b/src/main/java/com/maxmind/minfraud/request/TransactionReport.java index 93b064a3..d85717c7 100644 --- a/src/main/java/com/maxmind/minfraud/request/TransactionReport.java +++ b/src/main/java/com/maxmind/minfraud/request/TransactionReport.java @@ -150,7 +150,7 @@ public TransactionReport build() { * @return The IP address used in the transaction. */ @JsonProperty("ip_address") - public InetAddress getIpAddress() { + public InetAddress ipAddress() { return ipAddress; } @@ -158,7 +158,7 @@ public InetAddress getIpAddress() { * @return The tag. */ @JsonProperty("tag") - public Tag getTag() { + public Tag tag() { return tag; } @@ -166,7 +166,7 @@ public Tag getTag() { * @return The chargeback code. */ @JsonProperty("chargeback_code") - public String getChargebackCode() { + public String chargebackCode() { return chargebackCode; } @@ -174,7 +174,7 @@ public String getChargebackCode() { * @return The maxmind_id. */ @JsonProperty("maxmind_id") - public String getMaxmindId() { + public String maxmindId() { return maxmindId; } @@ -182,7 +182,7 @@ public String getMaxmindId() { * @return The minfraud_id. */ @JsonProperty("minfraud_id") - public UUID getMinfraudId() { + public UUID minfraudId() { return minfraudId; } @@ -190,7 +190,7 @@ public UUID getMinfraudId() { * @return The notes. */ @JsonProperty("notes") - public String getNotes() { + public String notes() { return notes; } @@ -198,7 +198,7 @@ public String getNotes() { * @return The transaction_id. */ @JsonProperty("transaction_id") - public String getTransactionId() { + public String transactionId() { return transactionId; } diff --git a/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java b/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java index 3a2879cc..04584327 100644 --- a/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java +++ b/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java @@ -11,7 +11,7 @@ public class HttpExceptionTest { public void testHttpException() throws Exception { URI uri = new URI("https://www.maxmind.com/"); HttpException e = new HttpException("message", 200, uri); - assertEquals(200, e.getHttpStatus(), "correct status"); - assertEquals(uri, e.getUri(), "correct URL"); + assertEquals(200, e.httpStatus(), "correct status"); + assertEquals(uri, e.uri(), "correct URL"); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java b/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java index c87dde6e..30d3f536 100644 --- a/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java +++ b/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java @@ -13,8 +13,8 @@ public void testInvalidRequestException() throws Exception { String code = "INVALID_INPUT"; int status = 400; InvalidRequestException e = new InvalidRequestException("message", code, status, uri, null); - assertEquals(code, e.getCode(), "correct code"); - assertEquals(status, e.getHttpStatus(), "correct status"); - assertEquals(uri, e.getUri(), "correct URL"); + assertEquals(code, e.code(), "correct code"); + assertEquals(status, e.httpStatus(), "correct status"); + assertEquals(uri, e.uri(), "correct URL"); } } diff --git a/src/test/java/com/maxmind/minfraud/request/AbstractLocationTest.java b/src/test/java/com/maxmind/minfraud/request/AbstractLocationTest.java index bd21df21..b8f71ff4 100644 --- a/src/test/java/com/maxmind/minfraud/request/AbstractLocationTest.java +++ b/src/test/java/com/maxmind/minfraud/request/AbstractLocationTest.java @@ -13,49 +13,49 @@ public abstract class AbstractLocationTest { @Test public void testFirstName() { AbstractLocation loc = this.builder().firstName("frst").build(); - assertEquals("frst", loc.getFirstName()); + assertEquals("frst", loc.firstName()); } @Test public void testLastName() { AbstractLocation loc = this.builder().lastName("last").build(); - assertEquals("last", loc.getLastName()); + assertEquals("last", loc.lastName()); } @Test public void testCompany() { AbstractLocation loc = this.builder().company("company").build(); - assertEquals("company", loc.getCompany()); + assertEquals("company", loc.company()); } @Test public void testAddress() { AbstractLocation loc = this.builder().address("addr").build(); - assertEquals("addr", loc.getAddress()); + assertEquals("addr", loc.address()); } @Test public void testAddress2() { AbstractLocation loc = this.builder().address2("addr2").build(); - assertEquals("addr2", loc.getAddress2()); + assertEquals("addr2", loc.address2()); } @Test public void testCity() { AbstractLocation loc = this.builder().city("Pdx").build(); - assertEquals("Pdx", loc.getCity()); + assertEquals("Pdx", loc.city()); } @Test public void testRegion() { AbstractLocation loc = this.builder().region("MN").build(); - assertEquals("MN", loc.getRegion()); + assertEquals("MN", loc.region()); } @Test public void testCountry() { AbstractLocation loc = this.builder().country("US").build(); - assertEquals("US", loc.getCountry()); + assertEquals("US", loc.country()); } @Test @@ -85,19 +85,19 @@ public void testCountryInWrongCase() { @Test public void testPostal() { AbstractLocation loc = this.builder().postal("03231").build(); - assertEquals("03231", loc.getPostal()); + assertEquals("03231", loc.postal()); } @Test public void testPhoneNumber() { String phone = "321-321-3213"; AbstractLocation loc = this.builder().phoneNumber(phone).build(); - assertEquals(phone, loc.getPhoneNumber()); + assertEquals(phone, loc.phoneNumber()); } @Test public void testPhoneCountryCode() { AbstractLocation loc = this.builder().phoneCountryCode("1").build(); - assertEquals("1", loc.getPhoneCountryCode()); + assertEquals("1", loc.phoneCountryCode()); } } diff --git a/src/test/java/com/maxmind/minfraud/request/AccountTest.java b/src/test/java/com/maxmind/minfraud/request/AccountTest.java index 7809450a..bad66cc8 100644 --- a/src/test/java/com/maxmind/minfraud/request/AccountTest.java +++ b/src/test/java/com/maxmind/minfraud/request/AccountTest.java @@ -10,12 +10,12 @@ public class AccountTest { @Test public void testUserId() { Account account = new Builder().userId("usr").build(); - assertEquals("usr", account.getUserId()); + assertEquals("usr", account.userId()); } @Test public void testUsername() { Account account = new Builder().username("username").build(); - assertEquals("14c4b06b824ec593239362517f538b29", account.getUsernameMd5()); + assertEquals("14c4b06b824ec593239362517f538b29", account.usernameMd5()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java b/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java index edd7def2..183bc3df 100644 --- a/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java +++ b/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java @@ -14,10 +14,10 @@ public class CreditCardTest { @Test public void testIssuerIdNumber() { CreditCard cc = new Builder().issuerIdNumber("123456").build(); - assertEquals("123456", cc.getIssuerIdNumber()); + assertEquals("123456", cc.issuerIdNumber()); cc = new Builder().issuerIdNumber("12345678").build(); - assertEquals("12345678", cc.getIssuerIdNumber()); + assertEquals("12345678", cc.issuerIdNumber()); } @Test @@ -47,10 +47,10 @@ public void testIssuerIdNumberThatHasLetters() { @Test public void testLastDigits() { CreditCard cc = new Builder().lastDigits("1234").build(); - assertEquals("1234", cc.getLastDigits()); + assertEquals("1234", cc.lastDigits()); cc = new Builder().lastDigits("12").build(); - assertEquals("12", cc.getLastDigits()); + assertEquals("12", cc.lastDigits()); } @Test @@ -81,27 +81,27 @@ public void testLastDigitsThatHasLetters() { @Test public void testBankName() { CreditCard cc = new Builder().bankName("Bank").build(); - assertEquals("Bank", cc.getBankName()); + assertEquals("Bank", cc.bankName()); } @Test public void testBankPhoneCountryCode() { CreditCard cc = new Builder().bankPhoneCountryCode("1").build(); - assertEquals("1", cc.getBankPhoneCountryCode()); + assertEquals("1", cc.bankPhoneCountryCode()); } @Test public void testBankPhoneNumber() { String phone = "231-323-3123"; CreditCard cc = new Builder().bankPhoneNumber(phone).build(); - assertEquals(phone, cc.getBankPhoneNumber()); + assertEquals(phone, cc.bankPhoneNumber()); } @Test public void testCountry() { String country = "CA"; CreditCard cc = new Builder().country(country).build(); - assertEquals(country, cc.getCountry()); + assertEquals(country, cc.country()); } @ParameterizedTest @@ -116,13 +116,13 @@ public void testInvalidCountry(String country) { @Test public void testAvsResult() { CreditCard cc = new Builder().avsResult('Y').build(); - assertEquals(Character.valueOf('Y'), cc.getAvsResult()); + assertEquals(Character.valueOf('Y'), cc.avsResult()); } @Test public void testCvvResult() { CreditCard cc = new Builder().cvvResult('N').build(); - assertEquals(Character.valueOf('N'), cc.getCvvResult()); + assertEquals(Character.valueOf('N'), cc.cvvResult()); } @ParameterizedTest @@ -146,12 +146,12 @@ public void testInvalidToken(String token) { }) public void testValidToken(String token) { CreditCard cc = new Builder().token(token).build(); - assertEquals(token, cc.getToken()); + assertEquals(token, cc.token()); } @Test public void testWas3dSecureSuccessful() { CreditCard cc = new Builder().was3dSecureSuccessful(true).build(); - assertTrue(cc.getWas3dSecureSuccessful()); + assertTrue(cc.was3dSecureSuccessful()); } } diff --git a/src/test/java/com/maxmind/minfraud/request/CustomInputsTest.java b/src/test/java/com/maxmind/minfraud/request/CustomInputsTest.java index 95dc00a6..9e8064fa 100644 --- a/src/test/java/com/maxmind/minfraud/request/CustomInputsTest.java +++ b/src/test/java/com/maxmind/minfraud/request/CustomInputsTest.java @@ -16,7 +16,7 @@ public void TestPuttingTypes() { .put("float_input", 3.2f) .put("double_input", 32.123d) .put("bool_input", true) - .build().getInputs(); + .build().inputs(); assertEquals("test string", inputs.get("string_input_1")); assertEquals(19, inputs.get("int_input")); diff --git a/src/test/java/com/maxmind/minfraud/request/DeviceTest.java b/src/test/java/com/maxmind/minfraud/request/DeviceTest.java index 3c2b1881..bad9e88e 100644 --- a/src/test/java/com/maxmind/minfraud/request/DeviceTest.java +++ b/src/test/java/com/maxmind/minfraud/request/DeviceTest.java @@ -19,46 +19,46 @@ public DeviceTest() throws UnknownHostException { @Test public void testConstructorWithoutIP() { Device device = new Builder().build(); - assertNull(device.getIpAddress()); + assertNull(device.ipAddress()); } @Test public void testIpAddressThroughConstructor() { Device device = new Builder(ip).build(); - assertEquals(ip, device.getIpAddress()); + assertEquals(ip, device.ipAddress()); } @Test public void testIpAddress() { Device device = new Builder().ipAddress(ip).build(); - assertEquals(ip, device.getIpAddress()); + assertEquals(ip, device.ipAddress()); } @Test public void testUserAgent() { String ua = "Mozila 5"; Device device = new Builder(ip).userAgent(ua).build(); - assertEquals(ua, device.getUserAgent()); + assertEquals(ua, device.userAgent()); } @Test public void testAcceptLanguage() { String al = "en-US"; Device device = new Builder(ip).acceptLanguage(al).build(); - assertEquals(al, device.getAcceptLanguage()); + assertEquals(al, device.acceptLanguage()); } @Test public void testSessionAge() { Double hour = 3600d; Device device = new Builder(ip).sessionAge(hour).build(); - assertEquals(hour, device.getSessionAge()); + assertEquals(hour, device.sessionAge()); } @Test public void testSessionId() { String id = "foobar"; Device device = new Builder(ip).sessionId(id).build(); - assertEquals(id, device.getSessionId()); + assertEquals(id, device.sessionId()); } } diff --git a/src/test/java/com/maxmind/minfraud/request/EmailTest.java b/src/test/java/com/maxmind/minfraud/request/EmailTest.java index 687c2519..3fa7f7cf 100644 --- a/src/test/java/com/maxmind/minfraud/request/EmailTest.java +++ b/src/test/java/com/maxmind/minfraud/request/EmailTest.java @@ -21,15 +21,15 @@ public class EmailTest { @Test public void testAddress() { Email email = new Builder().address("test@test.org").build(); - assertEquals("test@test.org", email.getAddress(), "raw email"); - assertEquals("test.org", email.getDomain(), "domain set from email"); + assertEquals("test@test.org", email.address(), "raw email"); + assertEquals("test.org", email.domain(), "domain set from email"); } @Test public void testMultipleAtAddress() { Email email = new Builder().address("\"test@test\"@test.org").build(); - assertEquals("\"test@test\"@test.org", email.getAddress(), "raw email"); - assertEquals("test.org", email.getDomain(), "domain set from email"); + assertEquals("\"test@test\"@test.org", email.address(), "raw email"); + assertEquals("test.org", email.domain(), "domain set from email"); } @Test @@ -43,8 +43,8 @@ public void testAddressWithNoValidation() { for (String address : addresses.keySet()) { Email email = new Builder(false).address(address).build(); - assertEquals(address, email.getAddress(), "raw email"); - assertEquals(addresses.get(address), email.getDomain(), "domain set from email"); + assertEquals(address, email.address(), "raw email"); + assertEquals(addresses.get(address), email.domain(), "domain set from email"); } } @@ -53,10 +53,10 @@ public void testAddressMd5() { Email email = new Builder().address("test@test.org").hashAddress().build(); assertEquals( "476869598e748d958e819c180af31982", - email.getAddress(), + email.address(), "MD5 generated from email" ); - assertEquals("test.org", email.getDomain(), "domain set from email"); + assertEquals("test.org", email.domain(), "domain set from email"); } @Test @@ -64,16 +64,16 @@ public void testAddressMd5MultipleTimes() { Email email = new Builder().address("test@test.org").hashAddress().hashAddress().build(); assertEquals( "476869598e748d958e819c180af31982", - email.getAddress(), + email.address(), "MD5 generated from email" ); - assertEquals("test.org", email.getDomain(), "domain set from email"); + assertEquals("test.org", email.domain(), "domain set from email"); } @Test public void testHashAddressWithoutAddress() { Email email = new Builder().domain("test.org").hashAddress().build(); - assertEquals("test.org", email.getDomain(), "domain is set"); + assertEquals("test.org", email.domain(), "domain is set"); } @Test @@ -81,7 +81,7 @@ public void testMd5GetsLowercased() { Email email = new Builder().address("TEST@TEST.org").hashAddress().build(); assertEquals( "476869598e748d958e819c180af31982", - email.getAddress(), + email.address(), "MD5 generated from lowercased email" ); } @@ -89,10 +89,10 @@ public void testMd5GetsLowercased() { @Test public void testGetAddressWithoutSettingIt() { Email email = new Builder().domain("test.org").hashAddress().build(); - assertNull(email.getAddress(), "null address if none set"); + assertNull(email.address(), "null address if none set"); Email email2 = new Builder().domain("test.org").hashAddress().build(); - assertNull(email2.getAddress(), "null address if none set"); + assertNull(email2.address(), "null address if none set"); } @Test @@ -100,142 +100,142 @@ public void testNormalizing() throws NoSuchAlgorithmException { Email e; e = new Builder().address("test@maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder().address("Test@maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder(false).address(" Test@maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder().address("Test+alias@maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder().address("Test+007+008@maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder().address("Test+@maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder(false).address("Test@maxmind.com.").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals("maxmind.com.", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals("maxmind.com.", e.domain(), "domain"); e = new Builder().address("+@maxmind.com").hashAddress().build(); - assertEquals("aa57884e48f0dda9fc6f4cb2bffb1dd2", e.getAddress(), "MD5"); - assertEquals("maxmind.com", e.getDomain(), "domain"); + assertEquals("aa57884e48f0dda9fc6f4cb2bffb1dd2", e.address(), "MD5"); + assertEquals("maxmind.com", e.domain(), "domain"); e = new Builder(false).address("Test@ maxmind.com").hashAddress().build(); - assertEquals("977577b140bfb7c516e4746204fbdb01", e.getAddress(), "MD5"); - assertEquals(" maxmind.com", e.getDomain(), "domain"); + assertEquals("977577b140bfb7c516e4746204fbdb01", e.address(), "MD5"); + assertEquals(" maxmind.com", e.domain(), "domain"); e = new Builder().address("Test+foo@yahoo.com").hashAddress().build(); - assertEquals("a5f830c699fd71ad653aa59fa688c6d9", e.getAddress(), "MD5"); - assertEquals("yahoo.com", e.getDomain(), "domain"); + assertEquals("a5f830c699fd71ad653aa59fa688c6d9", e.address(), "MD5"); + assertEquals("yahoo.com", e.domain(), "domain"); e = new Builder().address("Test-foo@yahoo.com").hashAddress().build(); - assertEquals("88e478531ab3bc303f1b5da82c2e9bbb", e.getAddress(), "MD5"); - assertEquals("yahoo.com", e.getDomain(), "domain"); + assertEquals("88e478531ab3bc303f1b5da82c2e9bbb", e.address(), "MD5"); + assertEquals("yahoo.com", e.domain(), "domain"); e = new Builder().address("Test-foo-foo2@yahoo.com").hashAddress().build(); - assertEquals("88e478531ab3bc303f1b5da82c2e9bbb", e.getAddress(), "MD5"); - assertEquals("yahoo.com", e.getDomain(), "domain"); + assertEquals("88e478531ab3bc303f1b5da82c2e9bbb", e.address(), "MD5"); + assertEquals("yahoo.com", e.domain(), "domain"); e = new Builder().address("Test-foo@gmail.com").hashAddress().build(); - assertEquals("6f3ff986fa5e830dbbf08a942777a17c", e.getAddress(), "MD5"); - assertEquals("gmail.com", e.getDomain(), "domain"); + assertEquals("6f3ff986fa5e830dbbf08a942777a17c", e.address(), "MD5"); + assertEquals("gmail.com", e.domain(), "domain"); e = new Builder().address("test@gmail.com").hashAddress().build(); - assertEquals("1aedb8d9dc4751e229a335e371db8058", e.getAddress(), "MD5"); - assertEquals("gmail.com", e.getDomain(), "domain"); + assertEquals("1aedb8d9dc4751e229a335e371db8058", e.address(), "MD5"); + assertEquals("gmail.com", e.domain(), "domain"); e = new Builder().address("test@gamil.com").hashAddress().build(); - assertEquals("1aedb8d9dc4751e229a335e371db8058", e.getAddress(), "MD5"); - assertEquals("gamil.com", e.getDomain(), "domain"); + assertEquals("1aedb8d9dc4751e229a335e371db8058", e.address(), "MD5"); + assertEquals("gamil.com", e.domain(), "domain"); e = new Builder().address("test@bücher.com").hashAddress().build(); - assertEquals("24948acabac551360cd510d5e5e2b464", e.getAddress(), "MD5"); - assertEquals("bücher.com", e.getDomain(), "domain"); + assertEquals("24948acabac551360cd510d5e5e2b464", e.address(), "MD5"); + assertEquals("bücher.com", e.domain(), "domain"); e = new Builder().address("Test+alias@Bücher.com").hashAddress().build(); - assertEquals("24948acabac551360cd510d5e5e2b464", e.getAddress(), "MD5"); - assertEquals("Bücher.com", e.getDomain(), "domain"); + assertEquals("24948acabac551360cd510d5e5e2b464", e.address(), "MD5"); + assertEquals("Bücher.com", e.domain(), "domain"); e = new Builder(false).address("test").hashAddress().build(); - assertEquals("098f6bcd4621d373cade4e832627b4f6", e.getAddress(), "MD5"); - assertNull(e.getDomain(), "domain"); + assertEquals("098f6bcd4621d373cade4e832627b4f6", e.address(), "MD5"); + assertNull(e.domain(), "domain"); e = new Builder(false).address("test@").hashAddress().build(); - assertEquals("246a848af2f8394e3adbc738dbe43720", e.getAddress(), "MD5"); - assertNull(e.getDomain(), "domain"); + assertEquals("246a848af2f8394e3adbc738dbe43720", e.address(), "MD5"); + assertNull(e.domain(), "domain"); e = new Builder(false).address("test@.").hashAddress().build(); - assertEquals("246a848af2f8394e3adbc738dbe43720", e.getAddress(), "MD5"); - assertEquals(".", e.getDomain(), "domain"); + assertEquals("246a848af2f8394e3adbc738dbe43720", e.address(), "MD5"); + assertEquals(".", e.domain(), "domain"); e = new Builder(false).address("foo@googlemail.com").hashAddress().build(); - assertEquals(toMD5("foo@gmail.com"), e.getAddress(), "MD5"); - assertEquals("googlemail.com", e.getDomain(), "domain"); + assertEquals(toMD5("foo@gmail.com"), e.address(), "MD5"); + assertEquals("googlemail.com", e.domain(), "domain"); e = new Builder(false).address("foo.bar@gmail.com").hashAddress().build(); - assertEquals(toMD5("foobar@gmail.com"), e.getAddress(), "MD5"); - assertEquals("gmail.com", e.getDomain(), "domain"); + assertEquals(toMD5("foobar@gmail.com"), e.address(), "MD5"); + assertEquals("gmail.com", e.domain(), "domain"); e = new Builder(false).address("alias@user.fastmail.com").hashAddress().build(); - assertEquals(toMD5("user@fastmail.com"), e.getAddress(), "MD5"); - assertEquals("user.fastmail.com", e.getDomain(), "domain"); + assertEquals(toMD5("user@fastmail.com"), e.address(), "MD5"); + assertEquals("user.fastmail.com", e.domain(), "domain"); e = new Builder(false).address("foo@bar.example.com").hashAddress().build(); - assertEquals(toMD5("foo@bar.example.com"), e.getAddress(), "MD5"); - assertEquals("bar.example.com", e.getDomain(), "domain"); + assertEquals(toMD5("foo@bar.example.com"), e.address(), "MD5"); + assertEquals("bar.example.com", e.domain(), "domain"); e = new Builder(false).address("foo-bar@ymail.com").hashAddress().build(); - assertEquals(toMD5("foo@ymail.com"), e.getAddress(), "MD5"); - assertEquals("ymail.com", e.getDomain(), "domain"); + assertEquals(toMD5("foo@ymail.com"), e.address(), "MD5"); + assertEquals("ymail.com", e.domain(), "domain"); e = new Builder(false).address("foo@example.com.com").hashAddress().build(); - assertEquals(toMD5("foo@example.com"), e.getAddress(), "MD5"); - assertEquals("example.com.com", e.getDomain(), "domain"); + assertEquals(toMD5("foo@example.com"), e.address(), "MD5"); + assertEquals("example.com.com", e.domain(), "domain"); e = new Builder(false).address("foo@example.comfoo").hashAddress().build(); - assertEquals(toMD5("foo@example.comfoo"), e.getAddress(), "MD5"); - assertEquals("example.comfoo", e.getDomain(), "domain"); + assertEquals(toMD5("foo@example.comfoo"), e.address(), "MD5"); + assertEquals("example.comfoo", e.domain(), "domain"); e = new Builder(false).address("foo@example.cam").hashAddress().build(); - assertEquals(toMD5("foo@example.cam"), e.getAddress(), "MD5"); - assertEquals("example.cam", e.getDomain(), "domain"); + assertEquals(toMD5("foo@example.cam"), e.address(), "MD5"); + assertEquals("example.cam", e.domain(), "domain"); e = new Builder(false).address("foo@10000gmail.com").hashAddress().build(); - assertEquals(toMD5("foo@gmail.com"), e.getAddress(), "MD5"); - assertEquals("10000gmail.com", e.getDomain(), "domain"); + assertEquals(toMD5("foo@gmail.com"), e.address(), "MD5"); + assertEquals("10000gmail.com", e.domain(), "domain"); e = new Builder(false).address("foo@example.comcom").hashAddress().build(); - assertEquals(toMD5("foo@example.com"), e.getAddress(), "MD5"); - assertEquals("example.comcom", e.getDomain(), "domain"); + assertEquals(toMD5("foo@example.com"), e.address(), "MD5"); + assertEquals("example.comcom", e.domain(), "domain"); e = new Builder(false).address("foo@example.com.").hashAddress().build(); - assertEquals(toMD5("foo@example.com"), e.getAddress(), "MD5"); - assertEquals("example.com.", e.getDomain(), "domain"); + assertEquals(toMD5("foo@example.com"), e.address(), "MD5"); + assertEquals("example.com.", e.domain(), "domain"); e = new Builder(false).address("foo@example.com...").hashAddress().build(); - assertEquals(toMD5("foo@example.com"), e.getAddress(), "MD5"); - assertEquals("example.com...", e.getDomain(), "domain"); + assertEquals(toMD5("foo@example.com"), e.address(), "MD5"); + assertEquals("example.com...", e.domain(), "domain"); e = new Builder().address("example@bu\u0308cher.com").hashAddress().build(); - assertEquals("2b21bc76dab3c8b1622837c1d698936c", e.getAddress(), "MD5"); + assertEquals("2b21bc76dab3c8b1622837c1d698936c", e.address(), "MD5"); e = new Builder().address("example@b\u00FCcher.com").hashAddress().build(); - assertEquals("2b21bc76dab3c8b1622837c1d698936c", e.getAddress(), "MD5"); + assertEquals("2b21bc76dab3c8b1622837c1d698936c", e.address(), "MD5"); e = new Builder().address("bu\u0308cher@example.com").hashAddress().build(); - assertEquals("53550c712b146287a2d0dd30e5ed6f4b", e.getAddress(), "MD5"); + assertEquals("53550c712b146287a2d0dd30e5ed6f4b", e.address(), "MD5"); e = new Builder().address("b\u00FCcher@example.com").hashAddress().build(); - assertEquals("53550c712b146287a2d0dd30e5ed6f4b", e.getAddress(), "MD5"); + assertEquals("53550c712b146287a2d0dd30e5ed6f4b", e.address(), "MD5"); } private String toMD5(String s) throws NoSuchAlgorithmException { @@ -272,14 +272,14 @@ void testInvalidAddresses(String invalidAddress) { public void testDomain() { String domain = "domain.com"; Email email = new Builder().domain(domain).build(); - assertEquals(domain, email.getDomain()); + assertEquals(domain, email.domain()); } @Test public void testDomainWithoutValidation() { String domain = "bad domain @!"; Email email = new Builder(false).domain(domain).build(); - assertEquals(domain, email.getDomain()); + assertEquals(domain, email.domain()); } @ParameterizedTest(name = "Run #{index}: domain = \"{0}\"") diff --git a/src/test/java/com/maxmind/minfraud/request/EventTest.java b/src/test/java/com/maxmind/minfraud/request/EventTest.java index bbcdf77b..8c22d3ac 100644 --- a/src/test/java/com/maxmind/minfraud/request/EventTest.java +++ b/src/test/java/com/maxmind/minfraud/request/EventTest.java @@ -14,50 +14,50 @@ public class EventTest { @Test public void testParty() { Event event = new Builder().party(Party.AGENT).build(); - assertEquals(Party.AGENT, event.getParty()); + assertEquals(Party.AGENT, event.party()); event = new Builder().party(Party.CUSTOMER).build(); - assertEquals(Party.CUSTOMER, event.getParty()); + assertEquals(Party.CUSTOMER, event.party()); } @Test public void testTransactionId() { Event event = new Builder().transactionId("t12").build(); - assertEquals("t12", event.getTransactionId()); + assertEquals("t12", event.transactionId()); } @Test public void testShopId() { Event event = new Builder().shopId("s12").build(); - assertEquals("s12", event.getShopId()); + assertEquals("s12", event.shopId()); } @Test public void testTimeWithDate() { Date date = new Date(); Event event = new Builder().time(date).build(); - assertEquals(date, event.getTime()); + assertEquals(date, event.time()); } @Test public void testTimeWithZonedDateTime() { ZonedDateTime date = ZonedDateTime.now(); Event event = new Builder().time(date).build(); - assertEquals(date, event.getDateTime()); + assertEquals(date, event.dateTime()); } @Test public void testType() { Event event = new Builder().type(Type.ACCOUNT_CREATION).build(); - assertEquals(Type.ACCOUNT_CREATION, event.getType()); + assertEquals(Type.ACCOUNT_CREATION, event.type()); event = new Builder().type(Type.PAYOUT_CHANGE).build(); - assertEquals(Type.PAYOUT_CHANGE, event.getType()); + assertEquals(Type.PAYOUT_CHANGE, event.type()); event = new Builder().type(Type.CREDIT_APPLICATION).build(); - assertEquals(Type.CREDIT_APPLICATION, event.getType()); + assertEquals(Type.CREDIT_APPLICATION, event.type()); event = new Builder().type(Type.FUND_TRANSFER).build(); - assertEquals(Type.FUND_TRANSFER, event.getType()); + assertEquals(Type.FUND_TRANSFER, event.type()); } } diff --git a/src/test/java/com/maxmind/minfraud/request/OrderTest.java b/src/test/java/com/maxmind/minfraud/request/OrderTest.java index 8c682895..f74eac16 100644 --- a/src/test/java/com/maxmind/minfraud/request/OrderTest.java +++ b/src/test/java/com/maxmind/minfraud/request/OrderTest.java @@ -14,19 +14,19 @@ public class OrderTest { @Test public void testDoubleAmount() { Order order = new Builder().amount(1.1).build(); - assertEquals(BigDecimal.valueOf(1.1), order.getAmount()); + assertEquals(BigDecimal.valueOf(1.1), order.amount()); } @Test public void testAmount() { Order order = new Builder().amount(BigDecimal.valueOf(1.1)).build(); - assertEquals(BigDecimal.valueOf(1.1), order.getAmount()); + assertEquals(BigDecimal.valueOf(1.1), order.amount()); } @Test public void testCurrency() { Order order = new Builder().currency("USD").build(); - assertEquals("USD", order.getCurrency()); + assertEquals("USD", order.currency()); } @Test @@ -65,26 +65,26 @@ public void testCurrencyInWrongCase() { @Test public void testDiscountCode() { Order order = new Builder().discountCode("dsc").build(); - assertEquals("dsc", order.getDiscountCode()); + assertEquals("dsc", order.discountCode()); } @Test public void testAffiliateId() { Order order = new Builder().affiliateId("af").build(); - assertEquals("af", order.getAffiliateId()); + assertEquals("af", order.affiliateId()); } @Test public void testSubaffiliateId() { Order order = new Builder().subaffiliateId("saf").build(); - assertEquals("saf", order.getSubaffiliateId()); + assertEquals("saf", order.subaffiliateId()); } @Test public void testReferrerUri() throws Exception { URI uri = new URI("http://www.mm.com/"); Order order = new Builder().referrerUri(uri).build(); - assertEquals(uri, order.getReferrerUri()); + assertEquals(uri, order.referrerUri()); } @Test diff --git a/src/test/java/com/maxmind/minfraud/request/PaymentTest.java b/src/test/java/com/maxmind/minfraud/request/PaymentTest.java index d2367972..05a64d43 100644 --- a/src/test/java/com/maxmind/minfraud/request/PaymentTest.java +++ b/src/test/java/com/maxmind/minfraud/request/PaymentTest.java @@ -13,19 +13,19 @@ public class PaymentTest { @Test public void testMethod() { Payment payment = new Builder().method(Method.CARD).build(); - assertEquals(Method.CARD, payment.getMethod()); + assertEquals(Method.CARD, payment.method()); payment = new Builder().method(Method.DIGITAL_WALLET).build(); - assertEquals(Method.DIGITAL_WALLET, payment.getMethod()); + assertEquals(Method.DIGITAL_WALLET, payment.method()); payment = new Builder().method(Method.BUY_NOW_PAY_LATER).build(); - assertEquals(Method.BUY_NOW_PAY_LATER, payment.getMethod()); + assertEquals(Method.BUY_NOW_PAY_LATER, payment.method()); } @Test public void testProcessor() { Payment payment = new Builder().processor(Processor.ADYEN).build(); - assertEquals(Processor.ADYEN, payment.getProcessor()); + assertEquals(Processor.ADYEN, payment.processor()); } @Test @@ -37,6 +37,6 @@ public void testWasAuthorized() { @Test public void testDeclineCode() { Payment payment = new Builder().declineCode("declined").build(); - assertEquals("declined", payment.getDeclineCode()); + assertEquals("declined", payment.declineCode()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/ShippingTest.java b/src/test/java/com/maxmind/minfraud/request/ShippingTest.java index 3746d6d6..bfbc4552 100644 --- a/src/test/java/com/maxmind/minfraud/request/ShippingTest.java +++ b/src/test/java/com/maxmind/minfraud/request/ShippingTest.java @@ -15,6 +15,6 @@ Builder builder() { @Test public void testDeliverySpeed() { Shipping loc = this.builder().deliverySpeed(DeliverySpeed.EXPEDITED).build(); - assertEquals(DeliverySpeed.EXPEDITED, loc.getDeliverySpeed()); + assertEquals(DeliverySpeed.EXPEDITED, loc.deliverySpeed()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java b/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java index 92c93125..ebf28d28 100644 --- a/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java +++ b/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java @@ -11,30 +11,30 @@ public class ShoppingCartTest { @Test public void testCategory() { ShoppingCartItem item = new Builder().category("cat1").build(); - assertEquals("cat1", item.getCategory()); + assertEquals("cat1", item.category()); } @Test public void testItemId() { ShoppingCartItem item = new Builder().itemId("id5").build(); - assertEquals("id5", item.getItemId()); + assertEquals("id5", item.itemId()); } @Test public void testQuantity() { ShoppingCartItem item = new Builder().quantity(100).build(); - assertEquals(Integer.valueOf(100), item.getQuantity()); + assertEquals(Integer.valueOf(100), item.quantity()); } @Test public void testPrice() { ShoppingCartItem item = new Builder().price(BigDecimal.TEN).build(); - assertEquals(BigDecimal.TEN, item.getPrice()); + assertEquals(BigDecimal.TEN, item.price()); } @Test public void testDoublePrice() { ShoppingCartItem item = new Builder().price(10.3).build(); - assertEquals(BigDecimal.valueOf(10.3), item.getPrice()); + assertEquals(BigDecimal.valueOf(10.3), item.price()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java b/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java index fb544e64..63e2aeb0 100644 --- a/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java +++ b/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java @@ -46,25 +46,25 @@ public void testBuildValidIdentifier() { assertEquals(ip, new TransactionReport.Builder(tag) - .ipAddress(ip).build().getIpAddress()); + .ipAddress(ip).build().ipAddress()); assertEquals(maxmindId, new TransactionReport.Builder(tag) - .maxmindId(maxmindId).build().getMaxmindId()); + .maxmindId(maxmindId).build().maxmindId()); assertEquals(minfraudId, new TransactionReport.Builder(tag) - .minfraudId(minfraudId).build().getMinfraudId()); + .minfraudId(minfraudId).build().minfraudId()); assertEquals(transactionId, new TransactionReport.Builder(tag) - .transactionId(transactionId).build().getTransactionId()); + .transactionId(transactionId).build().transactionId()); } @Test public void testIpAddress() { final TransactionReport report = new Builder(tag).ipAddress(ip).build(); - assertEquals(ip, report.getIpAddress()); + assertEquals(ip, report.ipAddress()); } @Test public void testTag() { final TransactionReport report = new Builder(tag).ipAddress(ip).build(); - assertEquals(Tag.NOT_FRAUD, report.getTag()); + assertEquals(Tag.NOT_FRAUD, report.tag()); } @Test @@ -72,7 +72,7 @@ public void testChargebackCode() { final String code = "foo"; final TransactionReport report = new Builder(tag).ipAddress(ip).chargebackCode(code).build(); - assertEquals(code, report.getChargebackCode()); + assertEquals(code, report.chargebackCode()); } @Test @@ -95,28 +95,28 @@ public void testTooShortMaxmindId() { public void testValidMaxmindId() { final String id = "12345678"; final TransactionReport report = new Builder(tag).maxmindId(id).build(); - assertEquals(id, report.getMaxmindId()); + assertEquals(id, report.maxmindId()); } @Test public void testMinfraudId() { final UUID id = UUID.fromString("58fa38d8-4b87-458b-a22b-f00eda1aa20d"); final TransactionReport report = new Builder(tag).minfraudId(id).build(); - assertEquals(id, report.getMinfraudId()); + assertEquals(id, report.minfraudId()); } @Test public void testNotes() { final String notes = "foo"; final TransactionReport report = new Builder(tag).ipAddress(ip).notes(notes).build(); - assertEquals(notes, report.getNotes()); + assertEquals(notes, report.notes()); } @Test public void testTransactionID() { final String id = "foo"; final TransactionReport report = new Builder(tag).transactionId(id).build(); - assertEquals(id, report.getTransactionId()); + assertEquals(id, report.transactionId()); } // Test the example in the README diff --git a/src/test/java/com/maxmind/minfraud/request/TransactionTest.java b/src/test/java/com/maxmind/minfraud/request/TransactionTest.java index 94a968e2..dd28488e 100644 --- a/src/test/java/com/maxmind/minfraud/request/TransactionTest.java +++ b/src/test/java/com/maxmind/minfraud/request/TransactionTest.java @@ -16,41 +16,41 @@ private Transaction.Builder builder() throws UnknownHostException { @Test public void testConstructorWithoutDevice() { Transaction request = new Transaction.Builder().build(); - assertNull(request.getDevice()); + assertNull(request.device()); } @Test public void testAccount() throws Exception { Transaction request = this.builder().account(new Account.Builder().userId("1").build()).build(); - assertEquals("1", request.getAccount().getUserId()); + assertEquals("1", request.account().userId()); } @Test public void testBilling() throws Exception { Transaction request = this.builder().billing(new Billing.Builder().address("add").build()).build(); - assertEquals("add", request.getBilling().getAddress()); + assertEquals("add", request.billing().address()); } @Test public void testCreditCard() throws Exception { Transaction request = this.builder().creditCard(new CreditCard.Builder().bankName("name").build()).build(); - assertEquals("name", request.getCreditCard().getBankName()); + assertEquals("name", request.creditCard().bankName()); } @Test public void testCustomInputs() throws Exception { Transaction request = this.builder().customInputs( new CustomInputs.Builder().put("key", "value").build()).build(); - assertEquals("value", request.getCustomInputs().getInputs().get("key")); + assertEquals("value", request.customInputs().inputs().get("key")); } @Test public void testDevice() throws Exception { Transaction request = this.builder().build(); - assertEquals(InetAddress.getByName("152.216.7.110"), request.getDevice().getIpAddress()); + assertEquals(InetAddress.getByName("152.216.7.110"), request.device().ipAddress()); } @Test @@ -63,41 +63,41 @@ public void testDeviceThroughMethod() throws Exception { .device(device) .build(); - assertEquals(ip, request.getDevice().getIpAddress()); + assertEquals(ip, request.device().ipAddress()); } @Test public void testEmail() throws Exception { Transaction request = this.builder().email(new Email.Builder().domain("test.com").build()).build(); - assertEquals("test.com", request.getEmail().getDomain()); + assertEquals("test.com", request.email().domain()); } @Test public void testEvent() throws Exception { Transaction request = this.builder().event(new Event.Builder().shopId("1").build()).build(); - assertEquals("1", request.getEvent().getShopId()); + assertEquals("1", request.event().shopId()); } @Test public void testOrder() throws Exception { Transaction request = this.builder().order(new Order.Builder().affiliateId("af1").build()).build(); - assertEquals("af1", request.getOrder().getAffiliateId()); + assertEquals("af1", request.order().affiliateId()); } @Test public void testPayment() throws Exception { Transaction request = this.builder().payment(new Payment.Builder().declineCode("d").build()).build(); - assertEquals("d", request.getPayment().getDeclineCode()); + assertEquals("d", request.payment().declineCode()); } @Test public void testShipping() throws Exception { Transaction request = this.builder().shipping(new Shipping.Builder().lastName("l").build()).build(); - assertEquals("l", request.getShipping().getLastName()); + assertEquals("l", request.shipping().lastName()); } @Test @@ -105,6 +105,6 @@ public void testShoppingCart() throws Exception { Transaction request = this.builder().addShoppingCartItem(new ShoppingCartItem.Builder().itemId("1").build()) .build(); - assertEquals("1", request.getShoppingCart().get(0).getItemId()); + assertEquals("1", request.shoppingCart().get(0).itemId()); } } From 0409a37e66bc22c9d8301d363fd2c21d94660496 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 14:47:44 -0700 Subject: [PATCH 4/8] Use var for local variable declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This updates local variables throughout the codebase to use var instead of explicit type names, making the code more concise while maintaining readability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../maxmind/minfraud/WebServiceClient.java | 20 ++--- .../minfraud/WebServiceClientTest.java | 88 +++++++++---------- .../minfraud/exception/HttpExceptionTest.java | 4 +- .../InvalidRequestExceptionTest.java | 8 +- .../maxmind/minfraud/request/AccountTest.java | 4 +- .../minfraud/request/CreditCardTest.java | 24 ++--- .../maxmind/minfraud/request/DeviceTest.java | 22 ++--- .../maxmind/minfraud/request/EmailTest.java | 32 +++---- .../maxmind/minfraud/request/EventTest.java | 16 ++-- .../maxmind/minfraud/request/OrderTest.java | 20 ++--- .../maxmind/minfraud/request/PaymentTest.java | 8 +- .../minfraud/request/RequestTestHelper.java | 4 +- .../minfraud/request/ShippingTest.java | 2 +- .../minfraud/request/ShoppingCartTest.java | 10 +-- .../request/TransactionReportTest.java | 34 +++---- .../minfraud/request/TransactionTest.java | 30 +++---- .../minfraud/response/AbstractOutputTest.java | 4 +- .../maxmind/minfraud/response/EmailTest.java | 4 +- 18 files changed, 167 insertions(+), 167 deletions(-) diff --git a/src/main/java/com/maxmind/minfraud/WebServiceClient.java b/src/main/java/com/maxmind/minfraud/WebServiceClient.java index f9a561db..00ffc9d9 100644 --- a/src/main/java/com/maxmind/minfraud/WebServiceClient.java +++ b/src/main/java/com/maxmind/minfraud/WebServiceClient.java @@ -306,8 +306,8 @@ public void reportTransaction(TransactionReport transaction) throws IOException, if (transaction == null) { throw new IllegalArgumentException("transaction report must not be null"); } - URI uri = createUri(WebServiceClient.pathBase + "transactions/report"); - HttpRequest request = requestFor(transaction, uri); + var uri = createUri(WebServiceClient.pathBase + "transactions/report"); + var request = requestFor(transaction, uri); HttpResponse response = null; try { @@ -328,8 +328,8 @@ private T responseFor(String service, AbstractModel transaction, Class cl if (transaction == null) { throw new IllegalArgumentException("transaction must not be null"); } - URI uri = createUri(WebServiceClient.pathBase + service); - HttpRequest request = requestFor(transaction, uri); + var uri = createUri(WebServiceClient.pathBase + service); + var request = requestFor(transaction, uri); HttpResponse response = null; try { @@ -346,7 +346,7 @@ private T responseFor(String service, AbstractModel transaction, Class cl private HttpRequest requestFor(AbstractModel transaction, URI uri) throws MinFraudException, IOException { - HttpRequest.Builder builder = HttpRequest.newBuilder() + var builder = HttpRequest.newBuilder() .uri(uri) .header("Accept", "application/json") .header("Authorization", authHeader) @@ -365,7 +365,7 @@ private HttpRequest requestFor(AbstractModel transaction, URI uri) private void maybeThrowException(HttpResponse response, URI uri) throws IOException, MinFraudException { - int status = response.statusCode(); + var status = response.statusCode(); if (status >= 400 && status < 500) { this.handle4xxStatus(response, uri); } else if (status >= 500 && status < 600) { @@ -383,7 +383,7 @@ private T handleResponse(HttpResponse response, URI uri, Class< throws MinFraudException, IOException { maybeThrowException(response, uri); - InjectableValues inject = new Std().addValue( + var inject = new Std().addValue( "locales", locales); try (InputStream stream = response.body()) { @@ -398,7 +398,7 @@ private void handle4xxStatus(HttpResponse response, URI uri) throws IOException, InsufficientFundsException, InvalidRequestException, AuthenticationException, PermissionRequiredException { - int status = response.statusCode(); + var status = response.statusCode(); String body; try (InputStream stream = response.body()) { @@ -425,8 +425,8 @@ private void handleErrorWithJsonBody(Map content, throws HttpException, InsufficientFundsException, InvalidRequestException, AuthenticationException, PermissionRequiredException { - String error = content.get("error"); - String code = content.get("code"); + var error = content.get("error"); + var code = content.get("code"); if (error == null || code == null) { throw new HttpException( diff --git a/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java b/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java index 7de5b025..6b08ee52 100644 --- a/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java +++ b/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java @@ -57,19 +57,19 @@ public class WebServiceClientTest { @Test public void testReportTransaction() throws Exception { - String responseContent = ""; - WebServiceClient client = createSuccessClient("transactions/report", 204, + var responseContent = ""; + var client = createSuccessClient("transactions/report", 204, responseContent); - TransactionReport request = fullTransactionReport(); + var request = fullTransactionReport(); client.reportTransaction(request); } @Test public void testFullScoreTransaction() throws Exception { - String responseContent = readJsonFile("score-response"); - WebServiceClient client = createSuccessClient("score", 200, responseContent); - Transaction request = fullTransaction(); - ScoreResponse response = client.score(request); + var responseContent = readJsonFile("score-response"); + var client = createSuccessClient("score", 200, responseContent); + var request = fullTransaction(); + var response = client.score(request); JSONAssert.assertEquals(responseContent, response.toJson(), true); verifyRequestFor(wireMock, "score", "full-request"); @@ -77,10 +77,10 @@ public void testFullScoreTransaction() throws Exception { @Test public void testFullScoreTransactionWithEmailMd5() throws Exception { - String responseContent = readJsonFile("score-response"); - WebServiceClient client = createSuccessClient("score", 200, responseContent); - Transaction request = fullTransactionEmailMd5(); - ScoreResponse response = client.score(request); + var responseContent = readJsonFile("score-response"); + var client = createSuccessClient("score", 200, responseContent); + var request = fullTransactionEmailMd5(); + var response = client.score(request); JSONAssert.assertEquals(responseContent, response.toJson(), true); verifyRequestFor(wireMock, "score", "full-request-email-md5"); @@ -88,10 +88,10 @@ public void testFullScoreTransactionWithEmailMd5() throws Exception { @Test public void testFullInsightsTransaction() throws Exception { - String responseContent = readJsonFile("insights-response"); - WebServiceClient client = createSuccessClient("insights", 200, responseContent); - Transaction request = fullTransaction(); - InsightsResponse response = client.insights(request); + var responseContent = readJsonFile("insights-response"); + var client = createSuccessClient("insights", 200, responseContent); + var request = fullTransaction(); + var response = client.insights(request); // We use non-strict checking as there is some extra stuff in the serialized // object, most notably the "name" field in the GeoIP2 InsightsResponse subobjects. @@ -118,7 +118,7 @@ public void testFullInsightsTransaction() throws Exception { assertTrue(response.getCreditCard().isVirtual()); - List reasons = response.getIpAddress().getRiskReasons(); + var reasons = response.getIpAddress().getRiskReasons(); assertEquals(2, reasons.size(), "two IP risk reasons"); assertEquals( @@ -130,10 +130,10 @@ public void testFullInsightsTransaction() throws Exception { @Test public void testFullFactorsTransaction() throws Exception { - String responseContent = readJsonFile("factors-response"); - WebServiceClient client = createSuccessClient("factors", 200, responseContent); - Transaction request = fullTransaction(); - FactorsResponse response = client.factors(request); + var responseContent = readJsonFile("factors-response"); + var client = createSuccessClient("factors", 200, responseContent); + var request = fullTransaction(); + var response = client.factors(request); // We use non-strict checking as there is some extra stuff in the serialized // object, most notably the "name" field in the GeoIP2 InsightsResponse subobjects. @@ -161,8 +161,8 @@ public void testFullFactorsTransaction() throws Exception { @Test public void testRequestEncoding() throws Exception { - WebServiceClient client = createSuccessClient("insights", 200, "{}"); - Transaction request = new Transaction.Builder( + var client = createSuccessClient("insights", 200, "{}"); + var request = new Transaction.Builder( new Device.Builder(InetAddress.getByName("1.1.1.1")).build() ).shipping( new Shipping.Builder() @@ -178,9 +178,9 @@ public void testRequestEncoding() throws Exception { @Test public void test200WithNoBody() throws Exception { - WebServiceClient client = createSuccessClient("insights", 200, ""); - Transaction request = fullTransaction(); - Exception ex = assertThrows(MinFraudException.class, () -> client.insights(request)); + var client = createSuccessClient("insights", 200, ""); + var request = fullTransaction(); + var ex = assertThrows(MinFraudException.class, () -> client.insights(request)); assertThat(ex.getMessage(), matchesPattern("Received a 200 response but could not decode it as JSON")); @@ -188,10 +188,10 @@ public void test200WithNoBody() throws Exception { @Test public void test200WithInvalidJson() throws Exception { - WebServiceClient client = createSuccessClient("insights", 200, "{"); - Transaction request = fullTransaction(); + var client = createSuccessClient("insights", 200, "{"); + var request = fullTransaction(); - Exception ex = assertThrows(MinFraudException.class, () -> client.insights(request)); + var ex = assertThrows(MinFraudException.class, () -> client.insights(request)); assertEquals("Received a 200 response but could not decode it as JSON", ex.getMessage()); @@ -199,7 +199,7 @@ public void test200WithInvalidJson() throws Exception { @Test public void testInsufficientCredit() { - Exception ex = assertThrows(InsufficientFundsException.class, () -> createInsightsError( + var ex = assertThrows(InsufficientFundsException.class, () -> createInsightsError( 402, "application/json", "{\"code\":\"INSUFFICIENT_FUNDS\",\"error\":\"out of credit\"}" @@ -214,7 +214,7 @@ public void testInsufficientCredit() { "LICENSE_KEY_REQUIRED", "USER_ID_REQUIRED"}) public void testInvalidAuth(String code) { - Exception ex = assertThrows(AuthenticationException.class, () -> + var ex = assertThrows(AuthenticationException.class, () -> createInsightsError( 401, "application/json", @@ -226,7 +226,7 @@ public void testInvalidAuth(String code) { @Test public void testPermissionRequired() { - Exception ex = assertThrows(PermissionRequiredException.class, () -> createInsightsError( + var ex = assertThrows(PermissionRequiredException.class, () -> createInsightsError( 403, "application/json", "{\"code\":\"PERMISSION_REQUIRED\",\"error\":\"Permission required\"}" @@ -236,7 +236,7 @@ public void testPermissionRequired() { @Test public void testInvalidRequest() { - Exception ex = assertThrows(InvalidRequestException.class, () -> + var ex = assertThrows(InvalidRequestException.class, () -> createInsightsError( 400, "application/json", @@ -248,7 +248,7 @@ public void testInvalidRequest() { @Test public void test400WithInvalidJson() { - Exception ex = assertThrows(HttpException.class, () -> + var ex = assertThrows(HttpException.class, () -> createInsightsError( 400, "application/json", @@ -261,7 +261,7 @@ public void test400WithInvalidJson() { @Test public void test400WithNoBody() { - Exception ex = assertThrows(HttpException.class, () -> + var ex = assertThrows(HttpException.class, () -> createInsightsError( 400, "application/json", @@ -274,7 +274,7 @@ public void test400WithNoBody() { @Test public void test400WithUnexpectedContentType() { - Exception ex = assertThrows(HttpException.class, () -> + var ex = assertThrows(HttpException.class, () -> createInsightsError( 400, "text/plain", @@ -288,7 +288,7 @@ public void test400WithUnexpectedContentType() { @Test public void test400WithUnexpectedJson() { - Exception ex = assertThrows(HttpException.class, () -> + var ex = assertThrows(HttpException.class, () -> createInsightsError( 400, "application/json", @@ -302,7 +302,7 @@ public void test400WithUnexpectedJson() { @Test public void test300() { - Exception ex = assertThrows(HttpException.class, () -> + var ex = assertThrows(HttpException.class, () -> createInsightsError( 300, "application/json", @@ -315,7 +315,7 @@ public void test300() { @Test public void test500() { - Exception ex = assertThrows(HttpException.class, () -> + var ex = assertThrows(HttpException.class, () -> createInsightsError( 500, "application/json", @@ -363,9 +363,9 @@ private WebServiceClient createClient(String service, int status, String content @Test public void testHttpClientWorks() { - HttpClient customClient = HttpClient.newBuilder().build(); + var customClient = HttpClient.newBuilder().build(); - WebServiceClient client = new WebServiceClient.Builder(6, "0123456789") + var client = new WebServiceClient.Builder(6, "0123456789") .httpClient(customClient) .build(); @@ -375,9 +375,9 @@ public void testHttpClientWorks() { @Test public void testHttpClientWithConnectTimeoutThrowsException() { - HttpClient customClient = HttpClient.newBuilder().build(); + var customClient = HttpClient.newBuilder().build(); - Exception ex = assertThrows(IllegalArgumentException.class, () -> + var ex = assertThrows(IllegalArgumentException.class, () -> new WebServiceClient.Builder(6, "0123456789") .httpClient(customClient) .connectTimeout(Duration.ofSeconds(5)) @@ -390,9 +390,9 @@ public void testHttpClientWithConnectTimeoutThrowsException() { @Test public void testHttpClientWithProxyThrowsException() { - HttpClient customClient = HttpClient.newBuilder().build(); + var customClient = HttpClient.newBuilder().build(); - Exception ex = assertThrows(IllegalArgumentException.class, () -> + var ex = assertThrows(IllegalArgumentException.class, () -> new WebServiceClient.Builder(6, "0123456789") .httpClient(customClient) .proxy(java.net.ProxySelector.of(null)) diff --git a/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java b/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java index 04584327..aebd4d39 100644 --- a/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java +++ b/src/test/java/com/maxmind/minfraud/exception/HttpExceptionTest.java @@ -9,8 +9,8 @@ public class HttpExceptionTest { @Test public void testHttpException() throws Exception { - URI uri = new URI("https://www.maxmind.com/"); - HttpException e = new HttpException("message", 200, uri); + var uri = new URI("https://www.maxmind.com/"); + var e = new HttpException("message", 200, uri); assertEquals(200, e.httpStatus(), "correct status"); assertEquals(uri, e.uri(), "correct URL"); } diff --git a/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java b/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java index 30d3f536..2f15d384 100644 --- a/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java +++ b/src/test/java/com/maxmind/minfraud/exception/InvalidRequestExceptionTest.java @@ -9,10 +9,10 @@ public class InvalidRequestExceptionTest { @Test public void testInvalidRequestException() throws Exception { - URI uri = new URI("https://www.maxmind.com/"); - String code = "INVALID_INPUT"; - int status = 400; - InvalidRequestException e = new InvalidRequestException("message", code, status, uri, null); + var uri = new URI("https://www.maxmind.com/"); + var code = "INVALID_INPUT"; + var status = 400; + var e = new InvalidRequestException("message", code, status, uri, null); assertEquals(code, e.code(), "correct code"); assertEquals(status, e.httpStatus(), "correct status"); assertEquals(uri, e.uri(), "correct URL"); diff --git a/src/test/java/com/maxmind/minfraud/request/AccountTest.java b/src/test/java/com/maxmind/minfraud/request/AccountTest.java index bad66cc8..8af097fb 100644 --- a/src/test/java/com/maxmind/minfraud/request/AccountTest.java +++ b/src/test/java/com/maxmind/minfraud/request/AccountTest.java @@ -9,13 +9,13 @@ public class AccountTest { @Test public void testUserId() { - Account account = new Builder().userId("usr").build(); + var account = new Builder().userId("usr").build(); assertEquals("usr", account.userId()); } @Test public void testUsername() { - Account account = new Builder().username("username").build(); + var account = new Builder().username("username").build(); assertEquals("14c4b06b824ec593239362517f538b29", account.usernameMd5()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java b/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java index 183bc3df..9c720289 100644 --- a/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java +++ b/src/test/java/com/maxmind/minfraud/request/CreditCardTest.java @@ -13,7 +13,7 @@ public class CreditCardTest { @Test public void testIssuerIdNumber() { - CreditCard cc = new Builder().issuerIdNumber("123456").build(); + var cc = new Builder().issuerIdNumber("123456").build(); assertEquals("123456", cc.issuerIdNumber()); cc = new Builder().issuerIdNumber("12345678").build(); @@ -46,7 +46,7 @@ public void testIssuerIdNumberThatHasLetters() { @Test public void testLastDigits() { - CreditCard cc = new Builder().lastDigits("1234").build(); + var cc = new Builder().lastDigits("1234").build(); assertEquals("1234", cc.lastDigits()); cc = new Builder().lastDigits("12").build(); @@ -80,27 +80,27 @@ public void testLastDigitsThatHasLetters() { @Test public void testBankName() { - CreditCard cc = new Builder().bankName("Bank").build(); + var cc = new Builder().bankName("Bank").build(); assertEquals("Bank", cc.bankName()); } @Test public void testBankPhoneCountryCode() { - CreditCard cc = new Builder().bankPhoneCountryCode("1").build(); + var cc = new Builder().bankPhoneCountryCode("1").build(); assertEquals("1", cc.bankPhoneCountryCode()); } @Test public void testBankPhoneNumber() { - String phone = "231-323-3123"; - CreditCard cc = new Builder().bankPhoneNumber(phone).build(); + var phone = "231-323-3123"; + var cc = new Builder().bankPhoneNumber(phone).build(); assertEquals(phone, cc.bankPhoneNumber()); } @Test public void testCountry() { - String country = "CA"; - CreditCard cc = new Builder().country(country).build(); + var country = "CA"; + var cc = new Builder().country(country).build(); assertEquals(country, cc.country()); } @@ -115,13 +115,13 @@ public void testInvalidCountry(String country) { @Test public void testAvsResult() { - CreditCard cc = new Builder().avsResult('Y').build(); + var cc = new Builder().avsResult('Y').build(); assertEquals(Character.valueOf('Y'), cc.avsResult()); } @Test public void testCvvResult() { - CreditCard cc = new Builder().cvvResult('N').build(); + var cc = new Builder().cvvResult('N').build(); assertEquals(Character.valueOf('N'), cc.cvvResult()); } @@ -145,13 +145,13 @@ public void testInvalidToken(String token) { "valid_token" }) public void testValidToken(String token) { - CreditCard cc = new Builder().token(token).build(); + var cc = new Builder().token(token).build(); assertEquals(token, cc.token()); } @Test public void testWas3dSecureSuccessful() { - CreditCard cc = new Builder().was3dSecureSuccessful(true).build(); + var cc = new Builder().was3dSecureSuccessful(true).build(); assertTrue(cc.was3dSecureSuccessful()); } } diff --git a/src/test/java/com/maxmind/minfraud/request/DeviceTest.java b/src/test/java/com/maxmind/minfraud/request/DeviceTest.java index bad9e88e..b3b49952 100644 --- a/src/test/java/com/maxmind/minfraud/request/DeviceTest.java +++ b/src/test/java/com/maxmind/minfraud/request/DeviceTest.java @@ -18,47 +18,47 @@ public DeviceTest() throws UnknownHostException { @Test public void testConstructorWithoutIP() { - Device device = new Builder().build(); + var device = new Builder().build(); assertNull(device.ipAddress()); } @Test public void testIpAddressThroughConstructor() { - Device device = new Builder(ip).build(); + var device = new Builder(ip).build(); assertEquals(ip, device.ipAddress()); } @Test public void testIpAddress() { - Device device = new Builder().ipAddress(ip).build(); + var device = new Builder().ipAddress(ip).build(); assertEquals(ip, device.ipAddress()); } @Test public void testUserAgent() { - String ua = "Mozila 5"; - Device device = new Builder(ip).userAgent(ua).build(); + var ua = "Mozila 5"; + var device = new Builder(ip).userAgent(ua).build(); assertEquals(ua, device.userAgent()); } @Test public void testAcceptLanguage() { - String al = "en-US"; - Device device = new Builder(ip).acceptLanguage(al).build(); + var al = "en-US"; + var device = new Builder(ip).acceptLanguage(al).build(); assertEquals(al, device.acceptLanguage()); } @Test public void testSessionAge() { - Double hour = 3600d; - Device device = new Builder(ip).sessionAge(hour).build(); + var hour = 3600d; + var device = new Builder(ip).sessionAge(hour).build(); assertEquals(hour, device.sessionAge()); } @Test public void testSessionId() { - String id = "foobar"; - Device device = new Builder(ip).sessionId(id).build(); + var id = "foobar"; + var device = new Builder(ip).sessionId(id).build(); assertEquals(id, device.sessionId()); } } diff --git a/src/test/java/com/maxmind/minfraud/request/EmailTest.java b/src/test/java/com/maxmind/minfraud/request/EmailTest.java index 3fa7f7cf..3c4bab4b 100644 --- a/src/test/java/com/maxmind/minfraud/request/EmailTest.java +++ b/src/test/java/com/maxmind/minfraud/request/EmailTest.java @@ -20,21 +20,21 @@ public class EmailTest { @Test public void testAddress() { - Email email = new Builder().address("test@test.org").build(); + var email = new Builder().address("test@test.org").build(); assertEquals("test@test.org", email.address(), "raw email"); assertEquals("test.org", email.domain(), "domain set from email"); } @Test public void testMultipleAtAddress() { - Email email = new Builder().address("\"test@test\"@test.org").build(); + var email = new Builder().address("\"test@test\"@test.org").build(); assertEquals("\"test@test\"@test.org", email.address(), "raw email"); assertEquals("test.org", email.domain(), "domain set from email"); } @Test public void testAddressWithNoValidation() { - Map addresses = new HashMap<>() {{ + var addresses = new HashMap() {{ put("test", null); put("@test", "test"); put("test@", null); @@ -42,7 +42,7 @@ public void testAddressWithNoValidation() { }}; for (String address : addresses.keySet()) { - Email email = new Builder(false).address(address).build(); + var email = new Builder(false).address(address).build(); assertEquals(address, email.address(), "raw email"); assertEquals(addresses.get(address), email.domain(), "domain set from email"); } @@ -50,7 +50,7 @@ public void testAddressWithNoValidation() { @Test public void testAddressMd5() { - Email email = new Builder().address("test@test.org").hashAddress().build(); + var email = new Builder().address("test@test.org").hashAddress().build(); assertEquals( "476869598e748d958e819c180af31982", email.address(), @@ -61,7 +61,7 @@ public void testAddressMd5() { @Test public void testAddressMd5MultipleTimes() { - Email email = new Builder().address("test@test.org").hashAddress().hashAddress().build(); + var email = new Builder().address("test@test.org").hashAddress().hashAddress().build(); assertEquals( "476869598e748d958e819c180af31982", email.address(), @@ -72,13 +72,13 @@ public void testAddressMd5MultipleTimes() { @Test public void testHashAddressWithoutAddress() { - Email email = new Builder().domain("test.org").hashAddress().build(); + var email = new Builder().domain("test.org").hashAddress().build(); assertEquals("test.org", email.domain(), "domain is set"); } @Test public void testMd5GetsLowercased() { - Email email = new Builder().address("TEST@TEST.org").hashAddress().build(); + var email = new Builder().address("TEST@TEST.org").hashAddress().build(); assertEquals( "476869598e748d958e819c180af31982", email.address(), @@ -88,10 +88,10 @@ public void testMd5GetsLowercased() { @Test public void testGetAddressWithoutSettingIt() { - Email email = new Builder().domain("test.org").hashAddress().build(); + var email = new Builder().domain("test.org").hashAddress().build(); assertNull(email.address(), "null address if none set"); - Email email2 = new Builder().domain("test.org").hashAddress().build(); + var email2 = new Builder().domain("test.org").hashAddress().build(); assertNull(email2.address(), "null address if none set"); } @@ -239,9 +239,9 @@ public void testNormalizing() throws NoSuchAlgorithmException { } private String toMD5(String s) throws NoSuchAlgorithmException { - MessageDigest d = MessageDigest.getInstance("MD5"); + var d = MessageDigest.getInstance("MD5"); d.update(s.getBytes(StandardCharsets.UTF_8)); - BigInteger i = new BigInteger(1, d.digest()); + var i = new BigInteger(1, d.digest()); return String.format("%032x", i); } @@ -270,15 +270,15 @@ void testInvalidAddresses(String invalidAddress) { @Test public void testDomain() { - String domain = "domain.com"; - Email email = new Builder().domain(domain).build(); + var domain = "domain.com"; + var email = new Builder().domain(domain).build(); assertEquals(domain, email.domain()); } @Test public void testDomainWithoutValidation() { - String domain = "bad domain @!"; - Email email = new Builder(false).domain(domain).build(); + var domain = "bad domain @!"; + var email = new Builder(false).domain(domain).build(); assertEquals(domain, email.domain()); } diff --git a/src/test/java/com/maxmind/minfraud/request/EventTest.java b/src/test/java/com/maxmind/minfraud/request/EventTest.java index 8c22d3ac..da2211cf 100644 --- a/src/test/java/com/maxmind/minfraud/request/EventTest.java +++ b/src/test/java/com/maxmind/minfraud/request/EventTest.java @@ -13,7 +13,7 @@ public class EventTest { @Test public void testParty() { - Event event = new Builder().party(Party.AGENT).build(); + var event = new Builder().party(Party.AGENT).build(); assertEquals(Party.AGENT, event.party()); event = new Builder().party(Party.CUSTOMER).build(); @@ -22,33 +22,33 @@ public void testParty() { @Test public void testTransactionId() { - Event event = new Builder().transactionId("t12").build(); + var event = new Builder().transactionId("t12").build(); assertEquals("t12", event.transactionId()); } @Test public void testShopId() { - Event event = new Builder().shopId("s12").build(); + var event = new Builder().shopId("s12").build(); assertEquals("s12", event.shopId()); } @Test public void testTimeWithDate() { - Date date = new Date(); - Event event = new Builder().time(date).build(); + var date = new Date(); + var event = new Builder().time(date).build(); assertEquals(date, event.time()); } @Test public void testTimeWithZonedDateTime() { - ZonedDateTime date = ZonedDateTime.now(); - Event event = new Builder().time(date).build(); + var date = ZonedDateTime.now(); + var event = new Builder().time(date).build(); assertEquals(date, event.dateTime()); } @Test public void testType() { - Event event = new Builder().type(Type.ACCOUNT_CREATION).build(); + var event = new Builder().type(Type.ACCOUNT_CREATION).build(); assertEquals(Type.ACCOUNT_CREATION, event.type()); event = new Builder().type(Type.PAYOUT_CHANGE).build(); diff --git a/src/test/java/com/maxmind/minfraud/request/OrderTest.java b/src/test/java/com/maxmind/minfraud/request/OrderTest.java index f74eac16..3086558b 100644 --- a/src/test/java/com/maxmind/minfraud/request/OrderTest.java +++ b/src/test/java/com/maxmind/minfraud/request/OrderTest.java @@ -13,19 +13,19 @@ public class OrderTest { @Test public void testDoubleAmount() { - Order order = new Builder().amount(1.1).build(); + var order = new Builder().amount(1.1).build(); assertEquals(BigDecimal.valueOf(1.1), order.amount()); } @Test public void testAmount() { - Order order = new Builder().amount(BigDecimal.valueOf(1.1)).build(); + var order = new Builder().amount(BigDecimal.valueOf(1.1)).build(); assertEquals(BigDecimal.valueOf(1.1), order.amount()); } @Test public void testCurrency() { - Order order = new Builder().currency("USD").build(); + var order = new Builder().currency("USD").build(); assertEquals("USD", order.currency()); } @@ -64,38 +64,38 @@ public void testCurrencyInWrongCase() { @Test public void testDiscountCode() { - Order order = new Builder().discountCode("dsc").build(); + var order = new Builder().discountCode("dsc").build(); assertEquals("dsc", order.discountCode()); } @Test public void testAffiliateId() { - Order order = new Builder().affiliateId("af").build(); + var order = new Builder().affiliateId("af").build(); assertEquals("af", order.affiliateId()); } @Test public void testSubaffiliateId() { - Order order = new Builder().subaffiliateId("saf").build(); + var order = new Builder().subaffiliateId("saf").build(); assertEquals("saf", order.subaffiliateId()); } @Test public void testReferrerUri() throws Exception { - URI uri = new URI("http://www.mm.com/"); - Order order = new Builder().referrerUri(uri).build(); + var uri = new URI("http://www.mm.com/"); + var order = new Builder().referrerUri(uri).build(); assertEquals(uri, order.referrerUri()); } @Test public void testIsGift() { - Order order = new Builder().isGift(true).build(); + var order = new Builder().isGift(true).build(); assertTrue(order.isGift()); } @Test public void testHasGiftMessage() { - Order order = new Builder().hasGiftMessage(true).build(); + var order = new Builder().hasGiftMessage(true).build(); assertTrue(order.hasGiftMessage()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/PaymentTest.java b/src/test/java/com/maxmind/minfraud/request/PaymentTest.java index 05a64d43..2263da86 100644 --- a/src/test/java/com/maxmind/minfraud/request/PaymentTest.java +++ b/src/test/java/com/maxmind/minfraud/request/PaymentTest.java @@ -12,7 +12,7 @@ public class PaymentTest { @Test public void testMethod() { - Payment payment = new Builder().method(Method.CARD).build(); + var payment = new Builder().method(Method.CARD).build(); assertEquals(Method.CARD, payment.method()); payment = new Builder().method(Method.DIGITAL_WALLET).build(); @@ -24,19 +24,19 @@ public void testMethod() { @Test public void testProcessor() { - Payment payment = new Builder().processor(Processor.ADYEN).build(); + var payment = new Builder().processor(Processor.ADYEN).build(); assertEquals(Processor.ADYEN, payment.processor()); } @Test public void testWasAuthorized() { - Payment payment = new Builder().wasAuthorized(true).build(); + var payment = new Builder().wasAuthorized(true).build(); assertTrue(payment.wasAuthorized()); } @Test public void testDeclineCode() { - Payment payment = new Builder().declineCode("declined").build(); + var payment = new Builder().declineCode("declined").build(); assertEquals("declined", payment.declineCode()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/RequestTestHelper.java b/src/test/java/com/maxmind/minfraud/request/RequestTestHelper.java index 6319ec8e..1ba4315a 100644 --- a/src/test/java/com/maxmind/minfraud/request/RequestTestHelper.java +++ b/src/test/java/com/maxmind/minfraud/request/RequestTestHelper.java @@ -157,14 +157,14 @@ private static Transaction makeTransaction(Email e) throws Exception { public static String readJsonFile(String name) throws IOException, URISyntaxException { - URL resource = RequestTestHelper.class + var resource = RequestTestHelper.class .getResource("/test-data/" + name + ".json"); return Files.readString(Paths.get(resource.toURI())); } public static void verifyRequestFor(WireMockExtension wireMock, String service, String jsonFile) throws IOException, URISyntaxException { - String requestBody = readJsonFile(jsonFile); + var requestBody = readJsonFile(jsonFile); wireMock.verify(postRequestedFor(urlMatching("/minfraud/v2.0/" + service)) .withRequestBody(equalToJson(requestBody)) diff --git a/src/test/java/com/maxmind/minfraud/request/ShippingTest.java b/src/test/java/com/maxmind/minfraud/request/ShippingTest.java index bfbc4552..4107122d 100644 --- a/src/test/java/com/maxmind/minfraud/request/ShippingTest.java +++ b/src/test/java/com/maxmind/minfraud/request/ShippingTest.java @@ -14,7 +14,7 @@ Builder builder() { @Test public void testDeliverySpeed() { - Shipping loc = this.builder().deliverySpeed(DeliverySpeed.EXPEDITED).build(); + var loc = this.builder().deliverySpeed(DeliverySpeed.EXPEDITED).build(); assertEquals(DeliverySpeed.EXPEDITED, loc.deliverySpeed()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java b/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java index ebf28d28..336b6e54 100644 --- a/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java +++ b/src/test/java/com/maxmind/minfraud/request/ShoppingCartTest.java @@ -10,31 +10,31 @@ public class ShoppingCartTest { @Test public void testCategory() { - ShoppingCartItem item = new Builder().category("cat1").build(); + var item = new Builder().category("cat1").build(); assertEquals("cat1", item.category()); } @Test public void testItemId() { - ShoppingCartItem item = new Builder().itemId("id5").build(); + var item = new Builder().itemId("id5").build(); assertEquals("id5", item.itemId()); } @Test public void testQuantity() { - ShoppingCartItem item = new Builder().quantity(100).build(); + var item = new Builder().quantity(100).build(); assertEquals(Integer.valueOf(100), item.quantity()); } @Test public void testPrice() { - ShoppingCartItem item = new Builder().price(BigDecimal.TEN).build(); + var item = new Builder().price(BigDecimal.TEN).build(); assertEquals(BigDecimal.TEN, item.price()); } @Test public void testDoublePrice() { - ShoppingCartItem item = new Builder().price(10.3).build(); + var item = new Builder().price(10.3).build(); assertEquals(BigDecimal.valueOf(10.3), item.price()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java b/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java index 63e2aeb0..c07b3f48 100644 --- a/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java +++ b/src/test/java/com/maxmind/minfraud/request/TransactionReportTest.java @@ -39,10 +39,10 @@ public void testBuildInvalidIdentifier() { @Test public void testBuildValidIdentifier() { - final String maxmindId = "12345678"; - final UUID minfraudId = UUID.fromString( + final var maxmindId = "12345678"; + final var minfraudId = UUID.fromString( "58fa38d8-4b87-458b-a22b-f00eda1aa20d"); - final String transactionId = "abc123"; + final var transactionId = "abc123"; assertEquals(ip, new TransactionReport.Builder(tag) @@ -57,20 +57,20 @@ public void testBuildValidIdentifier() { @Test public void testIpAddress() { - final TransactionReport report = new Builder(tag).ipAddress(ip).build(); + final var report = new Builder(tag).ipAddress(ip).build(); assertEquals(ip, report.ipAddress()); } @Test public void testTag() { - final TransactionReport report = new Builder(tag).ipAddress(ip).build(); + final var report = new Builder(tag).ipAddress(ip).build(); assertEquals(Tag.NOT_FRAUD, report.tag()); } @Test public void testChargebackCode() { - final String code = "foo"; - final TransactionReport report = + final var code = "foo"; + final var report = new Builder(tag).ipAddress(ip).chargebackCode(code).build(); assertEquals(code, report.chargebackCode()); } @@ -93,36 +93,36 @@ public void testTooShortMaxmindId() { @Test public void testValidMaxmindId() { - final String id = "12345678"; - final TransactionReport report = new Builder(tag).maxmindId(id).build(); + final var id = "12345678"; + final var report = new Builder(tag).maxmindId(id).build(); assertEquals(id, report.maxmindId()); } @Test public void testMinfraudId() { - final UUID id = UUID.fromString("58fa38d8-4b87-458b-a22b-f00eda1aa20d"); - final TransactionReport report = new Builder(tag).minfraudId(id).build(); + final var id = UUID.fromString("58fa38d8-4b87-458b-a22b-f00eda1aa20d"); + final var report = new Builder(tag).minfraudId(id).build(); assertEquals(id, report.minfraudId()); } @Test public void testNotes() { - final String notes = "foo"; - final TransactionReport report = new Builder(tag).ipAddress(ip).notes(notes).build(); + final var notes = "foo"; + final var report = new Builder(tag).ipAddress(ip).notes(notes).build(); assertEquals(notes, report.notes()); } @Test public void testTransactionID() { - final String id = "foo"; - final TransactionReport report = new Builder(tag).transactionId(id).build(); + final var id = "foo"; + final var report = new Builder(tag).transactionId(id).build(); assertEquals(id, report.transactionId()); } // Test the example in the README @Test public void testAllFields() throws Exception { - final TransactionReport report = new TransactionReport.Builder(Tag.NOT_FRAUD) + final var report = new TransactionReport.Builder(Tag.NOT_FRAUD) .chargebackCode("mycode") .ipAddress(InetAddress.getByName("1.1.1.1")) .maxmindId("12345678") @@ -131,7 +131,7 @@ public void testAllFields() throws Exception { .transactionId("foo") .build(); - final String expectedJSON = "{" + + final var expectedJSON = "{" + "ip_address:'1.1.1.1'," + "tag:'not_fraud'," + "chargeback_code:'mycode'," + diff --git a/src/test/java/com/maxmind/minfraud/request/TransactionTest.java b/src/test/java/com/maxmind/minfraud/request/TransactionTest.java index dd28488e..918b516a 100644 --- a/src/test/java/com/maxmind/minfraud/request/TransactionTest.java +++ b/src/test/java/com/maxmind/minfraud/request/TransactionTest.java @@ -15,51 +15,51 @@ private Transaction.Builder builder() throws UnknownHostException { @Test public void testConstructorWithoutDevice() { - Transaction request = new Transaction.Builder().build(); + var request = new Transaction.Builder().build(); assertNull(request.device()); } @Test public void testAccount() throws Exception { - Transaction request = + var request = this.builder().account(new Account.Builder().userId("1").build()).build(); assertEquals("1", request.account().userId()); } @Test public void testBilling() throws Exception { - Transaction request = + var request = this.builder().billing(new Billing.Builder().address("add").build()).build(); assertEquals("add", request.billing().address()); } @Test public void testCreditCard() throws Exception { - Transaction request = + var request = this.builder().creditCard(new CreditCard.Builder().bankName("name").build()).build(); assertEquals("name", request.creditCard().bankName()); } @Test public void testCustomInputs() throws Exception { - Transaction request = this.builder().customInputs( + var request = this.builder().customInputs( new CustomInputs.Builder().put("key", "value").build()).build(); assertEquals("value", request.customInputs().inputs().get("key")); } @Test public void testDevice() throws Exception { - Transaction request = this.builder().build(); + var request = this.builder().build(); assertEquals(InetAddress.getByName("152.216.7.110"), request.device().ipAddress()); } @Test public void testDeviceThroughMethod() throws Exception { - InetAddress ip = InetAddress.getByName("152.216.7.110"); + var ip = InetAddress.getByName("152.216.7.110"); - Device device = new Device.Builder().ipAddress(ip).build(); + var device = new Device.Builder().ipAddress(ip).build(); - Transaction request = new Transaction.Builder() + var request = new Transaction.Builder() .device(device) .build(); @@ -68,41 +68,41 @@ public void testDeviceThroughMethod() throws Exception { @Test public void testEmail() throws Exception { - Transaction request = + var request = this.builder().email(new Email.Builder().domain("test.com").build()).build(); assertEquals("test.com", request.email().domain()); } @Test public void testEvent() throws Exception { - Transaction request = this.builder().event(new Event.Builder().shopId("1").build()).build(); + var request = this.builder().event(new Event.Builder().shopId("1").build()).build(); assertEquals("1", request.event().shopId()); } @Test public void testOrder() throws Exception { - Transaction request = + var request = this.builder().order(new Order.Builder().affiliateId("af1").build()).build(); assertEquals("af1", request.order().affiliateId()); } @Test public void testPayment() throws Exception { - Transaction request = + var request = this.builder().payment(new Payment.Builder().declineCode("d").build()).build(); assertEquals("d", request.payment().declineCode()); } @Test public void testShipping() throws Exception { - Transaction request = + var request = this.builder().shipping(new Shipping.Builder().lastName("l").build()).build(); assertEquals("l", request.shipping().lastName()); } @Test public void testShoppingCart() throws Exception { - Transaction request = + var request = this.builder().addShoppingCartItem(new ShoppingCartItem.Builder().itemId("1").build()) .build(); assertEquals("1", request.shoppingCart().get(0).itemId()); diff --git a/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java b/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java index 53d62fdc..12d5eee3 100644 --- a/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java +++ b/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java @@ -16,7 +16,7 @@ public abstract class AbstractOutputTest { T deserialize(Class cls, String json) throws IOException { - ObjectMapper mapper = JsonMapper.builder() + var mapper = JsonMapper.builder() .addModule(new JavaTimeModule()) .defaultDateFormat(new StdDateFormat().withColonInTimeZone(true)) .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) @@ -26,7 +26,7 @@ T deserialize(Class cls, String json) throws IOException { .serializationInclusion(JsonInclude.Include.NON_NULL) .serializationInclusion(JsonInclude.Include.NON_EMPTY) .build(); - InjectableValues inject = new Std().addValue( + var inject = new Std().addValue( "locales", Collections.singletonList("en")); return mapper.readerFor(cls).with(inject).readValue(json); } diff --git a/src/test/java/com/maxmind/minfraud/response/EmailTest.java b/src/test/java/com/maxmind/minfraud/response/EmailTest.java index 5c71c468..e715b614 100644 --- a/src/test/java/com/maxmind/minfraud/response/EmailTest.java +++ b/src/test/java/com/maxmind/minfraud/response/EmailTest.java @@ -14,7 +14,7 @@ public class EmailTest extends AbstractOutputTest { @Test public void testEmail() throws Exception { - Email email = this.deserialize( + var email = this.deserialize( Email.class, JSON.std .composeString() @@ -40,7 +40,7 @@ public void testEmail() throws Exception { @Test public void testEmailWithoutFirstSeen() throws Exception { - Email email = this.deserialize( + var email = this.deserialize( Email.class, JSON.std .composeString() From a39c908347d84b0415c4c51f67e10b2fc6570a45 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 14:55:00 -0700 Subject: [PATCH 5/8] Use record-style accessors in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update all test files to use record-style accessor methods (without the 'get' prefix) instead of the deprecated getter methods. This eliminates deprecation warnings and follows the new record-based API patterns introduced in version 4.0.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../minfraud/WebServiceClientTest.java | 40 +++++++++---------- .../minfraud/response/BillingAddressTest.java | 8 ++-- .../minfraud/response/CreditCardTest.java | 8 ++-- .../maxmind/minfraud/response/DeviceTest.java | 8 ++-- .../minfraud/response/DispositionTest.java | 6 +-- .../minfraud/response/EmailDomainTest.java | 2 +- .../maxmind/minfraud/response/EmailTest.java | 8 ++-- .../response/FactorsResponseTest.java | 26 ++++++------ .../minfraud/response/GeoIp2LocationTest.java | 2 +- .../response/InsightsResponseTest.java | 36 ++++++++--------- .../minfraud/response/IpAddressTest.java | 26 ++++++------ .../maxmind/minfraud/response/IssuerTest.java | 4 +- .../maxmind/minfraud/response/PhoneTest.java | 6 +-- .../maxmind/minfraud/response/ReasonTest.java | 4 +- .../response/RiskScoreReasonTest.java | 10 ++--- .../minfraud/response/ScoreResponseTest.java | 14 +++---- .../response/ShippingAddressTest.java | 10 ++--- .../minfraud/response/WarningTest.java | 6 +-- 18 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java b/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java index 6b08ee52..920bc206 100644 --- a/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java +++ b/src/test/java/com/maxmind/minfraud/WebServiceClientTest.java @@ -99,31 +99,31 @@ public void testFullInsightsTransaction() throws Exception { JSONAssert.assertEquals(responseContent, response.toJson(), false); verifyRequestFor(wireMock, "insights", "full-request"); assertTrue( - response.getIpAddress().getCountry().isInEuropeanUnion(), - "response.getIpAddress().getCountry().isInEuropeanUnion() does not return true" + response.ipAddress().country().isInEuropeanUnion(), + "response.ipAddress().country().isInEuropeanUnion() does not return true" ); assertFalse( - response.getIpAddress().getRegisteredCountry().isInEuropeanUnion(), - "response.getIpAddress().getRegisteredCountry().isInEuropeanUnion() does not return false" + response.ipAddress().registeredCountry().isInEuropeanUnion(), + "response.ipAddress().registeredCountry().isInEuropeanUnion() does not return false" ); assertTrue( - response.getIpAddress().getRepresentedCountry().isInEuropeanUnion(), - "response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return true" + response.ipAddress().representedCountry().isInEuropeanUnion(), + "response.ipAddress().representedCountry().isInEuropeanUnion() does not return true" ); - assertEquals("2018-04-05T15:34:40-07:00", response.getDevice().getLocalTime()); + assertEquals("2018-04-05T15:34:40-07:00", response.device().localTime()); - assertEquals("152.216.7.110", response.getIpAddress().getTraits().getIpAddress()); + assertEquals("152.216.7.110", response.ipAddress().traits().ipAddress().getHostAddress()); assertEquals("81.2.69.0/24", - response.getIpAddress().getTraits().getNetwork().toString()); + response.ipAddress().traits().network().toString()); - assertTrue(response.getCreditCard().isVirtual()); + assertTrue(response.creditCard().isVirtual()); - var reasons = response.getIpAddress().getRiskReasons(); + var reasons = response.ipAddress().riskReasons(); assertEquals(2, reasons.size(), "two IP risk reasons"); assertEquals( "MINFRAUD_NETWORK_ACTIVITY", - reasons.get(1).getCode(), + reasons.get(1).code(), "second IP risk reason code" ); } @@ -141,22 +141,22 @@ public void testFullFactorsTransaction() throws Exception { JSONAssert.assertEquals(responseContent, response.toJson(), false); verifyRequestFor(wireMock, "factors", "full-request"); assertTrue( - response.getIpAddress().getCountry().isInEuropeanUnion(), - "response.getIpAddress().getCountry().isInEuropeanUnion() does not return true" + response.ipAddress().country().isInEuropeanUnion(), + "response.ipAddress().country().isInEuropeanUnion() does not return true" ); assertTrue( - response.getIpAddress().getRegisteredCountry().isInEuropeanUnion(), - "response.getIpAddress().getRegisteredCountry().isInEuropeanUnion() does not return true" + response.ipAddress().registeredCountry().isInEuropeanUnion(), + "response.ipAddress().registeredCountry().isInEuropeanUnion() does not return true" ); assertFalse( - response.getIpAddress().getRepresentedCountry().isInEuropeanUnion(), - "response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return false" + response.ipAddress().representedCountry().isInEuropeanUnion(), + "response.ipAddress().representedCountry().isInEuropeanUnion() does not return false" ); - assertEquals("152.216.7.110", response.getIpAddress().getTraits().getIpAddress()); + assertEquals("152.216.7.110", response.ipAddress().traits().ipAddress().getHostAddress()); assertEquals("81.2.69.0/24", - response.getIpAddress().getTraits().getNetwork().toString()); + response.ipAddress().traits().network().toString()); } @Test diff --git a/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java b/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java index e4a68b4d..dc147a9c 100644 --- a/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java +++ b/src/test/java/com/maxmind/minfraud/response/BillingAddressTest.java @@ -28,18 +28,18 @@ public void testBillingAddress() throws Exception { assertTrue(address.isPostalInCity(), "correct isPostalInCity"); assertEquals( 100, - address.getDistanceToIpLocation().longValue(), - "correct getDistanceToIpLocation" + address.distanceToIpLocation().longValue(), + "correct distanceToIpLocation" ); assertEquals( 32.1, - address.getLongitude(), + address.longitude(), DELTA, "correct longitude" ); assertEquals( 43.1, - address.getLatitude(), + address.latitude(), DELTA, "correct latitude" ); diff --git a/src/test/java/com/maxmind/minfraud/response/CreditCardTest.java b/src/test/java/com/maxmind/minfraud/response/CreditCardTest.java index 8f31c843..a55a73f4 100644 --- a/src/test/java/com/maxmind/minfraud/response/CreditCardTest.java +++ b/src/test/java/com/maxmind/minfraud/response/CreditCardTest.java @@ -29,10 +29,10 @@ public void testCreditCard() throws Exception { .finish() ); - assertEquals("Bank", cc.getIssuer().getName()); - assertEquals("US", cc.getCountry()); - assertEquals("Visa", cc.getBrand()); - assertEquals("credit", cc.getType()); + assertEquals("Bank", cc.issuer().name()); + assertEquals("US", cc.country()); + assertEquals("Visa", cc.brand()); + assertEquals("credit", cc.type()); assertTrue(cc.isBusiness()); assertTrue(cc.isPrepaid()); assertTrue(cc.isVirtual()); diff --git a/src/test/java/com/maxmind/minfraud/response/DeviceTest.java b/src/test/java/com/maxmind/minfraud/response/DeviceTest.java index 72dfd6f2..4d2338b9 100644 --- a/src/test/java/com/maxmind/minfraud/response/DeviceTest.java +++ b/src/test/java/com/maxmind/minfraud/response/DeviceTest.java @@ -23,11 +23,11 @@ public void testDevice() throws Exception { .finish() ); - assertEquals(99.0, device.getConfidence(), 1e-15); - assertEquals(UUID.fromString("C8D3BE1A-BE26-11E5-8C50-1B575C37265F"), device.getId()); - assertEquals("2016-06-08T14:16:38Z", device.getLastSeen()); + assertEquals(99.0, device.confidence(), 1e-15); + assertEquals(UUID.fromString("C8D3BE1A-BE26-11E5-8C50-1B575C37265F"), device.id()); + assertEquals("2016-06-08T14:16:38Z", device.lastSeen()); assertEquals("2016-06-08T14:16:38Z", device.getLastSeenDateTime().toString()); - assertEquals("2018-04-05T15:21:01-07:00", device.getLocalTime()); + assertEquals("2018-04-05T15:21:01-07:00", device.localTime()); assertEquals("2018-04-05T15:21:01-07:00", device.getLocalDateTime().toString()); } diff --git a/src/test/java/com/maxmind/minfraud/response/DispositionTest.java b/src/test/java/com/maxmind/minfraud/response/DispositionTest.java index 2e27121d..fc37295d 100644 --- a/src/test/java/com/maxmind/minfraud/response/DispositionTest.java +++ b/src/test/java/com/maxmind/minfraud/response/DispositionTest.java @@ -21,8 +21,8 @@ public void testDisposition() throws Exception { .finish() ); - assertEquals("accept", disposition.getAction()); - assertEquals("default", disposition.getReason()); - assertEquals("the label", disposition.getRuleLabel()); + assertEquals("accept", disposition.action()); + assertEquals("default", disposition.reason()); + assertEquals("the label", disposition.ruleLabel()); } } diff --git a/src/test/java/com/maxmind/minfraud/response/EmailDomainTest.java b/src/test/java/com/maxmind/minfraud/response/EmailDomainTest.java index 27f09198..e57651a1 100644 --- a/src/test/java/com/maxmind/minfraud/response/EmailDomainTest.java +++ b/src/test/java/com/maxmind/minfraud/response/EmailDomainTest.java @@ -20,6 +20,6 @@ public void testEmailDomain() throws Exception { .finish() ); - assertEquals(LocalDate.parse("2014-02-03"), domain.getFirstSeen()); + assertEquals(LocalDate.parse("2014-02-03"), domain.firstSeen()); } } diff --git a/src/test/java/com/maxmind/minfraud/response/EmailTest.java b/src/test/java/com/maxmind/minfraud/response/EmailTest.java index e715b614..3484390e 100644 --- a/src/test/java/com/maxmind/minfraud/response/EmailTest.java +++ b/src/test/java/com/maxmind/minfraud/response/EmailTest.java @@ -30,11 +30,11 @@ public void testEmail() throws Exception { .finish() ); - assertEquals(LocalDate.parse("2014-02-03"), email.getDomain().getFirstSeen()); + assertEquals(LocalDate.parse("2014-02-03"), email.domain().firstSeen()); assertFalse(email.isDisposable()); assertFalse(email.isFree()); assertTrue(email.isHighRisk()); - assertEquals("2017-01-02", email.getFirstSeen()); + assertEquals("2017-01-02", email.firstSeen()); assertEquals(LocalDate.parse("2017-01-02"), email.getFirstSeenDate()); } @@ -51,11 +51,11 @@ public void testEmailWithoutFirstSeen() throws Exception { .finish() ); - assertNotNull(email.getDomain()); + assertNotNull(email.domain()); assertNull(email.isDisposable()); assertFalse(email.isFree()); assertTrue(email.isHighRisk()); - assertNull(email.getFirstSeen()); + assertNull(email.firstSeen()); assertNull(email.getFirstSeenDate()); } } diff --git a/src/test/java/com/maxmind/minfraud/response/FactorsResponseTest.java b/src/test/java/com/maxmind/minfraud/response/FactorsResponseTest.java index 6f415863..fcc9fe02 100644 --- a/src/test/java/com/maxmind/minfraud/response/FactorsResponseTest.java +++ b/src/test/java/com/maxmind/minfraud/response/FactorsResponseTest.java @@ -45,42 +45,42 @@ public void testFactors() throws Exception { .finish() ); - assertTrue(factors.getShippingPhone().isVoip(), "correct shipping phone isVoip"); - assertFalse(factors.getShippingPhone().matchesPostal(), "correct shipping phone matchesPostal"); - assertFalse(factors.getBillingPhone().isVoip(), "correct billing phone isVoip"); - assertTrue(factors.getBillingPhone().matchesPostal(), "correct billing phone matchesPostal"); + assertTrue(factors.shippingPhone().isVoip(), "correct shipping phone isVoip"); + assertFalse(factors.shippingPhone().matchesPostal(), "correct shipping phone matchesPostal"); + assertFalse(factors.billingPhone().isVoip(), "correct billing phone isVoip"); + assertTrue(factors.billingPhone().matchesPostal(), "correct billing phone matchesPostal"); assertEquals( Double.valueOf(1.20), - factors.getFundsRemaining(), + factors.fundsRemaining(), "correct funnds remaining" ); - assertEquals(UUID.fromString(id), factors.getId(), "correct ID"); + assertEquals(UUID.fromString(id), factors.id(), "correct ID"); assertEquals( Integer.valueOf(123), - factors.getQueriesRemaining(), + factors.queriesRemaining(), "correct queries remaining" ); assertEquals( Double.valueOf(0.01), - factors.getRiskScore(), + factors.riskScore(), "correct risk score" ); - assertEquals(1, factors.getRiskScoreReasons().size()); + assertEquals(1, factors.riskScoreReasons().size()); assertEquals( Double.valueOf(45), - factors.getRiskScoreReasons().get(0).getMultiplier(), + factors.riskScoreReasons().get(0).multiplier(), "risk multiplier" ); - assertEquals(1, factors.getRiskScoreReasons().get(0).getReasons().size()); + assertEquals(1, factors.riskScoreReasons().get(0).reasons().size()); assertEquals( "ANONYMOUS_IP", - factors.getRiskScoreReasons().get(0).getReasons().get(0).getCode(), + factors.riskScoreReasons().get(0).reasons().get(0).code(), "risk reason code" ); assertEquals( "Risk due to IP being an Anonymous IP", - factors.getRiskScoreReasons().get(0).getReasons().get(0).getReason(), + factors.riskScoreReasons().get(0).reasons().get(0).reason(), "risk reason" ); } diff --git a/src/test/java/com/maxmind/minfraud/response/GeoIp2LocationTest.java b/src/test/java/com/maxmind/minfraud/response/GeoIp2LocationTest.java index 08dac1b9..64a0b59c 100644 --- a/src/test/java/com/maxmind/minfraud/response/GeoIp2LocationTest.java +++ b/src/test/java/com/maxmind/minfraud/response/GeoIp2LocationTest.java @@ -20,7 +20,7 @@ public void testGetLocalTime() throws Exception { .finish() ); - assertEquals(time, location.getLocalTime()); + assertEquals(time, location.localTime()); assertEquals(time, location.getLocalDateTime().toString()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/response/InsightsResponseTest.java b/src/test/java/com/maxmind/minfraud/response/InsightsResponseTest.java index 23b73e30..b9a36735 100644 --- a/src/test/java/com/maxmind/minfraud/response/InsightsResponseTest.java +++ b/src/test/java/com/maxmind/minfraud/response/InsightsResponseTest.java @@ -67,58 +67,58 @@ public void testInsights() throws Exception { .finish() ); - assertEquals("accept", insights.getDisposition().getAction(), "disposition"); + assertEquals("accept", insights.disposition().action(), "disposition"); assertEquals( LocalDate.parse("2014-02-03"), - insights.getEmail().getDomain().getFirstSeen(), + insights.email().domain().firstSeen(), "email domain first seen" ); assertEquals( "US", - insights.getIpAddress().getCountry().getIsoCode(), + insights.ipAddress().country().isoCode(), "correct country ISO" ); - assertTrue(insights.getCreditCard().isBusiness(), "correct credit card is business"); - assertTrue(insights.getCreditCard().isPrepaid(), "correct credit card prepaid"); + assertTrue(insights.creditCard().isBusiness(), "correct credit card is business"); + assertTrue(insights.creditCard().isPrepaid(), "correct credit card prepaid"); assertTrue( - insights.getShippingAddress().isInIpCountry(), + insights.shippingAddress().isInIpCountry(), "correct shipping address is in IP country" ); - assertTrue(insights.getShippingPhone().isVoip(), "correct shipping phone isVoip"); + assertTrue(insights.shippingPhone().isVoip(), "correct shipping phone isVoip"); assertFalse( - insights.getShippingPhone().matchesPostal(), + insights.shippingPhone().matchesPostal(), "correct shipping phone matchesPostal" ); assertTrue( - insights.getBillingAddress().isInIpCountry(), + insights.billingAddress().isInIpCountry(), "correct billing address is in IP country" ); - assertFalse(insights.getBillingPhone().isVoip(), "correct billing phone isVoip"); + assertFalse(insights.billingPhone().isVoip(), "correct billing phone isVoip"); assertTrue( - insights.getBillingPhone().matchesPostal(), + insights.billingPhone().matchesPostal(), "correct billing phone matchesPostal" ); assertEquals( Double.valueOf(1.20), - insights.getFundsRemaining(), + insights.fundsRemaining(), "correct funds remaining" ); - assertEquals(UUID.fromString(id), insights.getId(), "correct ID"); + assertEquals(UUID.fromString(id), insights.id(), "correct ID"); assertEquals( Integer.valueOf(123), - insights.getQueriesRemaining(), + insights.queriesRemaining(), "correct queries remaining" ); - assertEquals(Double.valueOf(0.01), insights.getRiskScore(), "correct risk score"); + assertEquals(Double.valueOf(0.01), insights.riskScore(), "correct risk score"); assertEquals( "INVALID_INPUT", - insights.getWarnings().get(0).getCode(), + insights.warnings().get(0).code(), "correct warning code" ); - assertEquals("152.216.7.110", insights.getIpAddress().getTraits().getIpAddress()); - assertEquals("81.2.69.0/24", insights.getIpAddress().getTraits().getNetwork().toString()); + assertEquals("152.216.7.110", insights.ipAddress().traits().ipAddress().getHostAddress()); + assertEquals("81.2.69.0/24", insights.ipAddress().traits().network().toString()); } } diff --git a/src/test/java/com/maxmind/minfraud/response/IpAddressTest.java b/src/test/java/com/maxmind/minfraud/response/IpAddressTest.java index a48b4927..6cbdf0db 100644 --- a/src/test/java/com/maxmind/minfraud/response/IpAddressTest.java +++ b/src/test/java/com/maxmind/minfraud/response/IpAddressTest.java @@ -46,32 +46,32 @@ public void testIpAddress() throws Exception { .finish() ); - assertEquals(Double.valueOf(99), address.getRisk(), "IP risk"); - assertEquals(time, address.getLocation().getLocalTime(), "correct local time"); - assertEquals("1.2.0.0/16", address.getTraits().getNetwork().toString()); - assertTrue(address.getTraits().isAnonymous(), "isAnonymous"); - assertTrue(address.getTraits().isAnonymousVpn(), "isAnonymousVpn"); - assertTrue(address.getTraits().isHostingProvider(), "isHostingProvider"); - assertTrue(address.getTraits().isPublicProxy(), "isPublicProxy"); - assertTrue(address.getTraits().isTorExitNode(), "isTorExitNode"); + assertEquals(Double.valueOf(99), address.risk(), "IP risk"); + assertEquals(time, address.location().localTime(), "correct local time"); + assertEquals("1.2.0.0/16", address.traits().network().toString()); + assertTrue(address.traits().isAnonymous(), "isAnonymous"); + assertTrue(address.traits().isAnonymousVpn(), "isAnonymousVpn"); + assertTrue(address.traits().isHostingProvider(), "isHostingProvider"); + assertTrue(address.traits().isPublicProxy(), "isPublicProxy"); + assertTrue(address.traits().isTorExitNode(), "isTorExitNode"); assertEquals( "310", - address.getTraits().getMobileCountryCode(), + address.traits().mobileCountryCode(), "mobile country code" ); assertEquals( "004", - address.getTraits().getMobileNetworkCode(), + address.traits().mobileNetworkCode(), "mobile network code" ); assertEquals( "ANONYMOUS_IP", - address.getRiskReasons().get(0).getCode(), + address.riskReasons().get(0).code(), "IP risk reason code" ); assertEquals( "some reason", - address.getRiskReasons().get(0).getReason(), + address.riskReasons().get(0).reason(), "IP risk reason" ); } @@ -83,6 +83,6 @@ public void testEmptyObject() throws Exception { "{}" ); - assertNotNull(address.getRiskReasons()); + assertNotNull(address.riskReasons()); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/response/IssuerTest.java b/src/test/java/com/maxmind/minfraud/response/IssuerTest.java index e9c38d04..e9844d73 100644 --- a/src/test/java/com/maxmind/minfraud/response/IssuerTest.java +++ b/src/test/java/com/maxmind/minfraud/response/IssuerTest.java @@ -25,9 +25,9 @@ public void testIssuer() throws Exception { .finish() ); - assertEquals("Bank", issuer.getName(), "bank name"); + assertEquals("Bank", issuer.name(), "bank name"); assertTrue(issuer.matchesProvidedName(), "provided name matches"); - assertEquals(phone, issuer.getPhoneNumber(), "phone"); + assertEquals(phone, issuer.phoneNumber(), "phone"); assertTrue(issuer.matchesProvidedPhoneNumber(), "provided phone matches"); } } \ No newline at end of file diff --git a/src/test/java/com/maxmind/minfraud/response/PhoneTest.java b/src/test/java/com/maxmind/minfraud/response/PhoneTest.java index decc4193..b6e00a13 100644 --- a/src/test/java/com/maxmind/minfraud/response/PhoneTest.java +++ b/src/test/java/com/maxmind/minfraud/response/PhoneTest.java @@ -25,10 +25,10 @@ public void testPhone() throws Exception { .finish() ); - assertEquals("US", phone.getCountry()); + assertEquals("US", phone.country()); assertTrue(phone.isVoip()); assertFalse(phone.matchesPostal()); - assertEquals("Operator", phone.getNetworkOperator()); - assertEquals("fixed", phone.getNumberType()); + assertEquals("Operator", phone.networkOperator()); + assertEquals("fixed", phone.numberType()); } } diff --git a/src/test/java/com/maxmind/minfraud/response/ReasonTest.java b/src/test/java/com/maxmind/minfraud/response/ReasonTest.java index 5a1b706c..9ea1db6c 100644 --- a/src/test/java/com/maxmind/minfraud/response/ReasonTest.java +++ b/src/test/java/com/maxmind/minfraud/response/ReasonTest.java @@ -23,8 +23,8 @@ public void testReason() throws Exception { .finish() ); - assertEquals(code, reason.getCode(), "code"); - assertEquals(msg, reason.getReason(), "reason"); + assertEquals(code, reason.code(), "code"); + assertEquals(msg, reason.reason(), "reason"); } } diff --git a/src/test/java/com/maxmind/minfraud/response/RiskScoreReasonTest.java b/src/test/java/com/maxmind/minfraud/response/RiskScoreReasonTest.java index 0911ae47..3eb0a269 100644 --- a/src/test/java/com/maxmind/minfraud/response/RiskScoreReasonTest.java +++ b/src/test/java/com/maxmind/minfraud/response/RiskScoreReasonTest.java @@ -26,16 +26,16 @@ public void testRiskScoreReason() throws Exception { .finish() ); - assertEquals(Double.valueOf(45), reason.getMultiplier(), "multiplier"); - assertEquals(1, reason.getReasons().size()); + assertEquals(Double.valueOf(45), reason.multiplier(), "multiplier"); + assertEquals(1, reason.reasons().size()); assertEquals( "ANONYMOUS_IP", - reason.getReasons().get(0).getCode(), + reason.reasons().get(0).code(), "risk reason code" ); assertEquals( "Risk due to IP being an Anonymous IP", - reason.getReasons().get(0).getReason(), + reason.reasons().get(0).reason(), "risk reason" ); } @@ -47,6 +47,6 @@ public void testEmptyObject() throws Exception { "{}" ); - assertNotNull(reason.getReasons()); + assertNotNull(reason.reasons()); } } diff --git a/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java b/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java index a2aa379a..923a28e4 100644 --- a/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java +++ b/src/test/java/com/maxmind/minfraud/response/ScoreResponseTest.java @@ -35,12 +35,12 @@ public void testScore() throws Exception { .finish() ); - assertEquals(UUID.fromString(id), score.getId(), "correct ID"); - assertEquals(Double.valueOf(1.20), score.getFundsRemaining(), "correct funds remaining"); - assertEquals(Integer.valueOf(123), score.getQueriesRemaining(), "queries remaining"); - assertEquals(Double.valueOf(0.01), score.getRiskScore(), "risk score"); - assertEquals("manual_review", score.getDisposition().getAction(), "disposition"); - assertEquals(Double.valueOf(0.02), score.getIpAddress().getRisk(), "IP risk"); - assertEquals("INVALID_INPUT", score.getWarnings().get(0).getCode(), "warning code"); + assertEquals(UUID.fromString(id), score.id(), "correct ID"); + assertEquals(Double.valueOf(1.20), score.fundsRemaining(), "correct funds remaining"); + assertEquals(Integer.valueOf(123), score.queriesRemaining(), "queries remaining"); + assertEquals(Double.valueOf(0.01), score.riskScore(), "risk score"); + assertEquals("manual_review", score.disposition().action(), "disposition"); + assertEquals(Double.valueOf(0.02), score.ipAddress().risk(), "IP risk"); + assertEquals("INVALID_INPUT", score.warnings().get(0).code(), "warning code"); } } diff --git a/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java b/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java index b8474ddc..1f0f66d7 100644 --- a/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java +++ b/src/test/java/com/maxmind/minfraud/response/ShippingAddressTest.java @@ -32,18 +32,18 @@ public void testShippingAddress() throws Exception { assertTrue(address.isPostalInCity(), "correct isPostalInCity"); assertEquals( 100, - address.getDistanceToIpLocation().longValue(), - "correct getDistanceToIpLocation" + address.distanceToIpLocation().longValue(), + "correct distanceToIpLocation" ); assertEquals( 32.1, - address.getLongitude(), + address.longitude(), DELTA, "correct longitude" ); assertEquals( 43.1, - address.getLatitude(), + address.latitude(), DELTA, "correct latitude" ); @@ -51,7 +51,7 @@ public void testShippingAddress() throws Exception { assertFalse(address.isHighRisk(), "is high risk"); assertEquals( Integer.valueOf(200), - address.getDistanceToBillingAddress(), + address.distanceToBillingAddress(), "distance to billing address" ); } diff --git a/src/test/java/com/maxmind/minfraud/response/WarningTest.java b/src/test/java/com/maxmind/minfraud/response/WarningTest.java index b9122a44..03f7ff4a 100644 --- a/src/test/java/com/maxmind/minfraud/response/WarningTest.java +++ b/src/test/java/com/maxmind/minfraud/response/WarningTest.java @@ -25,9 +25,9 @@ public void testWarning() throws Exception { .finish() ); - assertEquals(code, warning.getCode(), "code"); - assertEquals(msg, warning.getWarning(), "warning message"); - assertEquals(pointer, warning.getInputPointer(), "input_pointer"); + assertEquals(code, warning.code(), "code"); + assertEquals(msg, warning.warning(), "warning message"); + assertEquals(pointer, warning.inputPointer(), "input_pointer"); } } From 6c42ded67b6612f7779d90abca4534029b12e542 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 15:22:52 -0700 Subject: [PATCH 6/8] Replace Collections.singletonList() with List.of() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the more modern and concise List.of() factory method instead of Collections.singletonList() for creating immutable single-element lists. This is the preferred approach in Java 9+. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/main/java/com/maxmind/minfraud/WebServiceClient.java | 2 +- .../com/maxmind/minfraud/response/AbstractOutputTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/maxmind/minfraud/WebServiceClient.java b/src/main/java/com/maxmind/minfraud/WebServiceClient.java index 00ffc9d9..0fb5e561 100644 --- a/src/main/java/com/maxmind/minfraud/WebServiceClient.java +++ b/src/main/java/com/maxmind/minfraud/WebServiceClient.java @@ -103,7 +103,7 @@ public static final class Builder { Duration connectTimeout; Duration requestTimeout; - List locales = Collections.singletonList("en"); + List locales = List.of("en"); private ProxySelector proxy; private HttpClient httpClient; diff --git a/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java b/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java index 12d5eee3..1b424aca 100644 --- a/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java +++ b/src/test/java/com/maxmind/minfraud/response/AbstractOutputTest.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.databind.util.StdDateFormat; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.io.IOException; -import java.util.Collections; +import java.util.List; public abstract class AbstractOutputTest { @@ -27,7 +27,7 @@ T deserialize(Class cls, String json) throws IOException { .serializationInclusion(JsonInclude.Include.NON_EMPTY) .build(); var inject = new Std().addValue( - "locales", Collections.singletonList("en")); + "locales", List.of("en")); return mapper.readerFor(cls).with(inject).readValue(json); } } From 55080f9a2693a76a38ec26e63a48fdf3f57cd0bc Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 15:23:52 -0700 Subject: [PATCH 7/8] Make AbstractLocation a sealed class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seal AbstractLocation to explicitly declare its only permitted subclasses (Billing and Shipping). This makes the type hierarchy more explicit and enables better pattern matching and exhaustiveness checking in Java 17+. Note: MinFraudException was already using sealed classes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../java/com/maxmind/minfraud/request/AbstractLocation.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java b/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java index b8452e34..904676e0 100644 --- a/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java +++ b/src/main/java/com/maxmind/minfraud/request/AbstractLocation.java @@ -7,7 +7,8 @@ /** * This class represents the shared location behavior between Billing and Shipping. */ -public abstract class AbstractLocation extends AbstractModel { +public abstract sealed class AbstractLocation extends AbstractModel + permits Billing, Shipping { private final String firstName; private final String lastName; private final String company; From 9b5036901c9a01a69de9e5d65bdd85bc0b486a34 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 23 Oct 2025 15:31:24 -0700 Subject: [PATCH 8/8] Add repository for snapshot releases --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 854e25a1..00b79aaa 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,19 @@ goschwald@maxmind.com + + + Central Portal Snapshots + central-portal-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + + false + + + true + + + com.fasterxml.jackson.core