-
Couldn't load subscription status.
- Fork 8
Modernize API in preparation for major release #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
oschwald
commented
Oct 23, 2025
- Update to geoip2 5.0.0-SNAPSHOT
- Convert response classes to Java records
- Use record-style method naming for request and exception classes
- Use var for local variable declarations
- Use record-style accessors in tests
- Replace Collections.singletonList() with List.of()
- Make AbstractLocation a sealed class
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modernizes the minFraud API in preparation for a major release by converting response classes to Java records, adopting record-style method naming across request and exception classes, and updating to geoip2 5.0.0-SNAPSHOT.
Key changes:
- Converted all response classes from traditional classes to Java records with deprecated getter methods for backward compatibility
- Renamed accessor methods in request and exception classes from
get*()to record-style naming (e.g.,getUserId()→userId()) - Updated geoip2 dependency to 5.0.0-SNAPSHOT and refactored affected classes to use composition instead of inheritance
Reviewed Changes
Copilot reviewed 78 out of 78 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Added snapshot repository configuration and updated geoip2 dependency to 5.0.0-SNAPSHOT |
| CHANGELOG.md | Documented all breaking changes and new features for the major release |
| src/main/java/com/maxmind/minfraud/JsonSerializable.java | Added new interface for JSON serialization to replace AbstractModel |
| src/main/java/com/maxmind/minfraud/response/*.java | Converted response classes to records with deprecated getters |
| src/main/java/com/maxmind/minfraud/request/*.java | Updated to use record-style accessor naming |
| src/main/java/com/maxmind/minfraud/exception/*.java | Updated to use record-style accessor naming |
| src/test/java/**/*.java | Updated tests to use new record-style accessors and modernized with var declarations |
| src/test/resources/test-data/*.json | Removed deprecated is_satellite_provider field and added represented_country test data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @return The risk associated with the IP address. | ||
| */ | ||
| Double getRisk(); | ||
| Double risk(); |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new risk() method lacks documentation. Add a JavaDoc comment explaining what this method returns, consistent with the existing deprecated method's documentation.
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
beda13f to
9b50369
Compare