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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Open Payments Java SDK

[![CI](https://github.com/bonifacekabaso/open-payments-java/actions/workflows/ci.yml/badge.svg)](https://github.com/bonifacekabaso/open-payments-java/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/bonifacekabaso/open-payments-java/branch/main/graph/badge.svg)](https://codecov.io/gh/bonifacekabaso/open-payments-java)
[![CI](https://github.com/boniface/open-payments-java/actions/workflows/ci.yml/badge.svg)](https://github.com/bonifacekabaso/open-payments-java/actions/workflows/ci.yml)
[![Security & Quality](https://img.shields.io/github/actions/workflow/status/boniface/open-payments-java/ci.yml?label=Security%20%26%20Quality&query=jobs.security-and-quality.conclusion)](https://github.com/bonifacekabaso/open-payments-java/actions/workflows/ci.yml)
[![JaCoCo](https://img.shields.io/badge/JaCoCo-Coverage-green.svg)](https://github.com/boniface/open-payments-java/actions/workflows/ci.yml)
[![Java](https://img.shields.io/badge/Java-25-orange.svg)](https://openjdk.java.net/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Project Stage](https://img.shields.io/badge/Project%20Stage-Development-yellow.svg)]()
Expand Down Expand Up @@ -34,12 +35,12 @@ graph TD
ASE["<b>Financial Accounts<b/> <br/> <small>(Ledger, Wallet, etc)</small>"]

subgraph SDK["Open Payments API Servers"]

Auth["Authorization Server <br/> (GNAP Protocol)"]
Resource["Resource Server Payments <br/> (Payment, Quotes...)"]
Auth ~~~ Note
Resource ~~~ Note

Note["Operated by Account Service Entity (ASE)<br/> (Bank, Wallet Provider, Payment Processor)"]
end

Expand Down Expand Up @@ -267,4 +268,3 @@ Licensed under the [Apache License 2.0](LICENSE).
---

**Status**: 🚧 Under Development | **Version**: 1.0-SNAPSHOT | **Java**: 25+

7 changes: 2 additions & 5 deletions config/pmd/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

<!-- Best Practices -->
<rule ref="category/java/bestpractices.xml">
<exclude name="JUnitTestsShouldIncludeAssert"/>
<exclude name="JUnitTestContainsTooManyAsserts"/>
<!-- Tests often have duplicate literals for readability -->
<exclude name="AvoidDuplicateLiterals"/>
<!-- Exclude rules that don't exist in PMD 7.17.0 or are not applicable -->
</rule>

<!-- Code Style -->
<rule ref="category/java/codestyle.xml">
<exclude name="UseExplicitTypes"/>
<exclude name="AtLeastOneConstructor"/>
<exclude name="OnlyOneReturn"/>
<exclude name="ShortVariable"/>
Expand Down Expand Up @@ -45,7 +43,6 @@

<!-- Error Prone -->
<rule ref="category/java/errorprone.xml">
<exclude name="BeanMembersShouldSerialize"/>
<!-- Java records intentionally have fields with same name as accessor methods -->
<exclude name="AvoidFieldNameMatchingMethodName"/>
<!-- DataflowAnomalyAnalysis removed in PMD 7.x -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@
* client.addRequestInterceptor(gnap);
* }</pre>
*/
public final class AuthenticationInterceptor implements RequestInterceptor {

private final String authorizationHeaderValue;
public record AuthenticationInterceptor(String authorizationHeaderValue) implements RequestInterceptor {

/**
* Creates an authentication interceptor with the given Authorization header value.
*
* @param authorizationHeaderValue
* the full value for the Authorization header
*/
private AuthenticationInterceptor(String authorizationHeaderValue) {
this.authorizationHeaderValue = Objects.requireNonNull(authorizationHeaderValue,
"authorizationHeaderValue must not be null");
public AuthenticationInterceptor {
Objects.requireNonNull(authorizationHeaderValue, "authorizationHeaderValue must not be null");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,18 @@
* client.addResponseInterceptor(errorHandler);
* }</pre>
*/
public final class ErrorHandlingInterceptor implements ResponseInterceptor {
public record ErrorHandlingInterceptor(ObjectMapper objectMapper) implements ResponseInterceptor {

private static final Logger LOGGER = Logger.getLogger(ErrorHandlingInterceptor.class.getName());

private final ObjectMapper objectMapper;

/**
* Creates an error handling interceptor.
*
* @param objectMapper
* the JSON object mapper for parsing error responses
*/
public ErrorHandlingInterceptor(ObjectMapper objectMapper) {
this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper must not be null");
public ErrorHandlingInterceptor {
Objects.requireNonNull(objectMapper, "objectMapper must not be null");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
* client.addRequestInterceptor(new LoggingRequestInterceptor());
* }</pre>
*/
public final class LoggingRequestInterceptor implements RequestInterceptor {
public record LoggingRequestInterceptor(Level logLevel, boolean logHeaders,
boolean logBody) implements RequestInterceptor {

private static final Logger LOGGER = Logger.getLogger(LoggingRequestInterceptor.class.getName());

private final Level logLevel;
private final boolean logHeaders;
private final boolean logBody;

/**
* Creates a logging interceptor with INFO level and headers logging enabled.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@
* client.addResponseInterceptor(new LoggingResponseInterceptor());
* }</pre>
*/
public final class LoggingResponseInterceptor implements ResponseInterceptor {
public record LoggingResponseInterceptor(Level logLevel, Level errorLogLevel, boolean logHeaders,
boolean logBody) implements ResponseInterceptor {

private static final Logger LOGGER = Logger.getLogger(LoggingResponseInterceptor.class.getName());
private static final int MAX_BODY_LOG_LENGTH = 1000;

private final Level logLevel;
private final Level errorLogLevel;
private final boolean logHeaders;
private final boolean logBody;

/**
* Creates a logging interceptor with INFO level for success and WARNING for errors.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@
* <p>
* Thread-safe and can be reused across multiple requests.
*/
public final class DefaultIncomingPaymentService implements IncomingPaymentService {
public record DefaultIncomingPaymentService(HttpClient httpClient,
ObjectMapper objectMapper) implements IncomingPaymentService {

private static final String CONTENT_TYPE_JSON = "application/json";
private static final String ACCEPT_HEADER = "Accept";
private static final String INCOMING_PAYMENTS_PATH = "/incoming-payments";
private static final String COMPLETE_PATH = "/complete";

private final HttpClient httpClient;
private final ObjectMapper objectMapper;

/**
* Creates a new DefaultIncomingPaymentService.
*
Expand All @@ -47,9 +45,9 @@ public final class DefaultIncomingPaymentService implements IncomingPaymentServi
* @throws NullPointerException
* if any parameter is null
*/
public DefaultIncomingPaymentService(HttpClient httpClient, ObjectMapper objectMapper) {
this.httpClient = Objects.requireNonNull(httpClient, "httpClient must not be null");
this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper must not be null");
public DefaultIncomingPaymentService {
Objects.requireNonNull(httpClient, "httpClient must not be null");
Objects.requireNonNull(objectMapper, "objectMapper must not be null");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
* <p>
* Thread-safe and can be reused across multiple requests.
*/
public final class DefaultOutgoingPaymentService implements OutgoingPaymentService {
public record DefaultOutgoingPaymentService(HttpClient httpClient,
ObjectMapper objectMapper) implements OutgoingPaymentService {

private static final String CONTENT_TYPE_JSON = "application/json";
private static final String ACCEPT_HEADER = "Accept";
private static final String OUTGOING_PAYMENTS_PATH = "/outgoing-payments";

private final HttpClient httpClient;
private final ObjectMapper objectMapper;

/**
* Creates a new DefaultOutgoingPaymentService.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@
* <p>
* Thread-safe and can be reused across multiple requests.
*/
public final class DefaultQuoteService implements QuoteService {
public record DefaultQuoteService(HttpClient httpClient, ObjectMapper objectMapper) implements QuoteService {

private static final String CONTENT_TYPE_JSON = "application/json";
private static final String ACCEPT_HEADER = "Accept";
private static final String QUOTES_PATH = "/quotes";

private final HttpClient httpClient;
private final ObjectMapper objectMapper;

/**
* Creates a new DefaultQuoteService.
*
Expand All @@ -44,9 +41,9 @@ public final class DefaultQuoteService implements QuoteService {
* @throws NullPointerException
* if any parameter is null
*/
public DefaultQuoteService(HttpClient httpClient, ObjectMapper objectMapper) {
this.httpClient = Objects.requireNonNull(httpClient, "httpClient must not be null");
this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper must not be null");
public DefaultQuoteService {
Objects.requireNonNull(httpClient, "httpClient must not be null");
Objects.requireNonNull(objectMapper, "objectMapper must not be null");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
* <p>
* Thread-safe and can be reused across multiple requests.
*/
public final class DefaultWalletAddressService implements WalletAddressService {
public record DefaultWalletAddressService(HttpClient httpClient,
ObjectMapper objectMapper) implements WalletAddressService {

private static final String CONTENT_TYPE_JSON = "application/json";
private static final String JWKS_PATH = "/jwks.json";

private final HttpClient httpClient;
private final ObjectMapper objectMapper;

/**
* Creates a new DefaultWalletAddressService.
*
Expand All @@ -41,9 +39,9 @@ public final class DefaultWalletAddressService implements WalletAddressService {
* @throws NullPointerException
* if any parameter is null
*/
public DefaultWalletAddressService(HttpClient httpClient, ObjectMapper objectMapper) {
this.httpClient = Objects.requireNonNull(httpClient, "httpClient must not be null");
this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper must not be null");
public DefaultWalletAddressService {
Objects.requireNonNull(httpClient, "httpClient must not be null");
Objects.requireNonNull(objectMapper, "objectMapper must not be null");
}

@Override
Expand Down
Loading