From c2b0096e23c9d556cab87020ea064cb5f164ad3b Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:43:26 +0000 Subject: [PATCH] SDK regeneration --- README.md | 16 +- reference.md | 475 +++++++++++++++++- .../com/basistheory/core/Environment.java | 6 + .../merchant/AsyncMerchantClient.java | 15 +- .../merchant/AsyncRawMerchantClient.java | 10 +- .../applepay/merchant/MerchantClient.java | 15 +- .../applepay/merchant/RawMerchantClient.java | 7 +- .../certificates/AsyncCertificatesClient.java | 59 +++ .../AsyncRawCertificatesClient.java | 279 ++++++++++ .../certificates/CertificatesClient.java | 56 +++ .../certificates/RawCertificatesClient.java | 220 ++++++++ ...ayMerchantCertificatesRegisterRequest.java | 205 ++++++++ .../googlepay/AsyncGooglePayClient.java | 10 + .../resources/googlepay/GooglePayClient.java | 10 + .../merchant/AsyncMerchantClient.java | 67 +++ .../merchant/AsyncRawMerchantClient.java | 262 ++++++++++ .../googlepay/merchant/MerchantClient.java | 65 +++ .../googlepay/merchant/RawMerchantClient.java | 205 ++++++++ .../certificates/AsyncCertificatesClient.java | 59 +++ .../AsyncRawCertificatesClient.java | 279 ++++++++++ .../certificates/CertificatesClient.java | 57 +++ .../certificates/RawCertificatesClient.java | 220 ++++++++ ...ayMerchantCertificatesRegisterRequest.java | 123 +++++ .../GooglePayMerchantRegisterRequest.java | 96 ++++ .../requests/GooglePayCreateRequest.java | 32 +- .../types/ApplePayMerchantCertificates.java | 312 ++++++++++++ .../basistheory/types/GooglePayMerchant.java | 194 +++++++ .../types/GooglePayMerchantCertificates.java | 231 +++++++++ .../types/ProxyTransformOptions.java | 37 +- .../com/basistheory/types/RuntimeOptions.java | 58 ++- .../types/ThreeDsBrandingOptions.java | 96 ++++ .../types/ThreeDsCallbackUrls.java | 33 +- 32 files changed, 3778 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncCertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncRawCertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/applepay/merchant/certificates/CertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/applepay/merchant/certificates/RawCertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/applepay/merchant/certificates/requests/ApplePayMerchantCertificatesRegisterRequest.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/AsyncMerchantClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/AsyncRawMerchantClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/MerchantClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/RawMerchantClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncCertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncRawCertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/certificates/CertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/certificates/RawCertificatesClient.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/certificates/requests/GooglePayMerchantCertificatesRegisterRequest.java create mode 100644 src/main/java/com/basistheory/resources/googlepay/merchant/requests/GooglePayMerchantRegisterRequest.java create mode 100644 src/main/java/com/basistheory/types/ApplePayMerchantCertificates.java create mode 100644 src/main/java/com/basistheory/types/GooglePayMerchant.java create mode 100644 src/main/java/com/basistheory/types/GooglePayMerchantCertificates.java create mode 100644 src/main/java/com/basistheory/types/ThreeDsBrandingOptions.java diff --git a/README.md b/README.md index 2b95013..d23b468 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,20 @@ The BasisTheory Java library provides convenient access to the BasisTheory APIs from Java. +## Table of Contents + +- [Documentation](#documentation) +- [Usage](#usage) +- [Environments](#environments) +- [Base Url](#base-url) +- [Exception Handling](#exception-handling) +- [Advanced](#advanced) + - [Custom Client](#custom-client) + - [Retries](#retries) + - [Timeouts](#timeouts) +- [Contributing](#contributing) +- [Installation](#installation) + ## Documentation API reference documentation is available [here](https://api.basistheory.com). @@ -40,7 +54,7 @@ import com.basistheory.core.Environment; BasisTheoryApiClient client = BasisTheoryApiClient .builder() - .environment(Environment.Default) + .environment(Environment.default) .build(); ``` diff --git a/reference.md b/reference.md index 3fa92df..917a48a 100644 --- a/reference.md +++ b/reference.md @@ -769,6 +769,14 @@ client.googlePay().create( **googlePaymentData:** `Optional` + + + +
+
+ +**merchantRegistrationId:** `Optional` +
@@ -4085,7 +4093,7 @@ client.accountUpdater().realTime().invoke( ## ApplePay Merchant -
client.applePay.merchant.get(id) -> ApplePayToken +
client.applePay.merchant.get(id) -> ApplePayMerchant
@@ -4426,6 +4434,188 @@ client.applePay().session().create(
+ + +
+ +## ApplePay Merchant Certificates +
client.applePay.merchant.certificates.get(merchantId, id) -> ApplePayMerchantCertificates +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.applePay().merchant().certificates().get("merchantId", "id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantId:** `String` + +
+
+ +
+
+ +**id:** `String` + +
+
+
+
+ + +
+
+
+ +
client.applePay.merchant.certificates.delete(merchantId, id) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.applePay().merchant().certificates().delete("merchantId", "id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantId:** `String` + +
+
+ +
+
+ +**id:** `String` + +
+
+
+
+ + +
+
+
+ +
client.applePay.merchant.certificates.create(merchantId, request) -> ApplePayMerchantCertificates +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.applePay().merchant().certificates().create( + "merchantId", + ApplePayMerchantCertificatesRegisterRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantId:** `String` + +
+
+ +
+
+ +**merchantCertificateData:** `Optional` + +
+
+ +
+
+ +**merchantCertificatePassword:** `Optional` + +
+
+ +
+
+ +**paymentProcessorCertificateData:** `Optional` + +
+
+ +
+
+ +**paymentProcessorCertificatePassword:** `Optional` + +
+
+ +
+
+ +**domain:** `Optional` + +
+
+
+
+ +
@@ -4467,6 +4657,289 @@ client.documents().data().get("documentId"); + + +
+ +## GooglePay Merchant +
client.googlePay.merchant.get(id) -> GooglePayMerchant +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.googlePay().merchant().get("id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` + +
+
+
+
+ + +
+
+
+ +
client.googlePay.merchant.delete(id) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.googlePay().merchant().delete("id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` + +
+
+
+
+ + +
+
+
+ +
client.googlePay.merchant.create(request) -> GooglePayMerchant +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.googlePay().merchant().create( + GooglePayMerchantRegisterRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantIdentifier:** `Optional` + +
+
+
+
+ + +
+
+
+ +## GooglePay Merchant Certificates +
client.googlePay.merchant.certificates.get(merchantId, id) -> GooglePayMerchantCertificates +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.googlePay().merchant().certificates().get("merchantId", "id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantId:** `String` + +
+
+ +
+
+ +**id:** `String` + +
+
+
+
+ + +
+
+
+ +
client.googlePay.merchant.certificates.delete(merchantId, id) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.googlePay().merchant().certificates().delete("merchantId", "id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantId:** `String` + +
+
+ +
+
+ +**id:** `String` + +
+
+
+
+ + +
+
+
+ +
client.googlePay.merchant.certificates.create(merchantId, request) -> GooglePayMerchantCertificates +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.googlePay().merchant().certificates().create( + "merchantId", + GooglePayMerchantCertificatesRegisterRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**merchantId:** `String` + +
+
+ +
+
+ +**merchantCertificateData:** `Optional` + +
+
+ +
+
+ +**merchantCertificatePassword:** `Optional` + +
+
+
+
+ +
diff --git a/src/main/java/com/basistheory/core/Environment.java b/src/main/java/com/basistheory/core/Environment.java index 9896f77..f67df52 100644 --- a/src/main/java/com/basistheory/core/Environment.java +++ b/src/main/java/com/basistheory/core/Environment.java @@ -6,6 +6,12 @@ public final class Environment { public static final Environment DEFAULT = new Environment("https://api.basistheory.com"); + public static final Environment US_PRODUCTION = new Environment("https://api.basistheory.com"); + + public static final Environment EU_PRODUCTION = new Environment("https://api.basistheory.com"); + + public static final Environment TEST = new Environment("https://api.test.basistheory.com"); + private final String url; private Environment(String url) { diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/AsyncMerchantClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/AsyncMerchantClient.java index 539620b..a0abff3 100644 --- a/src/main/java/com/basistheory/resources/applepay/merchant/AsyncMerchantClient.java +++ b/src/main/java/com/basistheory/resources/applepay/merchant/AsyncMerchantClient.java @@ -5,19 +5,24 @@ import com.basistheory.core.ClientOptions; import com.basistheory.core.RequestOptions; +import com.basistheory.core.Suppliers; +import com.basistheory.resources.applepay.merchant.certificates.AsyncCertificatesClient; import com.basistheory.resources.applepay.merchant.requests.ApplePayMerchantRegisterRequest; import com.basistheory.types.ApplePayMerchant; -import com.basistheory.types.ApplePayToken; import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; public class AsyncMerchantClient { protected final ClientOptions clientOptions; private final AsyncRawMerchantClient rawClient; + protected final Supplier certificatesClient; + public AsyncMerchantClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.rawClient = new AsyncRawMerchantClient(clientOptions); + this.certificatesClient = Suppliers.memoize(() -> new AsyncCertificatesClient(clientOptions)); } /** @@ -27,11 +32,11 @@ public AsyncRawMerchantClient withRawResponse() { return this.rawClient; } - public CompletableFuture get(String id) { + public CompletableFuture get(String id) { return this.rawClient.get(id).thenApply(response -> response.body()); } - public CompletableFuture get(String id, RequestOptions requestOptions) { + public CompletableFuture get(String id, RequestOptions requestOptions) { return this.rawClient.get(id, requestOptions).thenApply(response -> response.body()); } @@ -55,4 +60,8 @@ public CompletableFuture create( ApplePayMerchantRegisterRequest request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } + + public AsyncCertificatesClient certificates() { + return this.certificatesClient.get(); + } } diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/AsyncRawMerchantClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/AsyncRawMerchantClient.java index 5b83bea..ab1b104 100644 --- a/src/main/java/com/basistheory/resources/applepay/merchant/AsyncRawMerchantClient.java +++ b/src/main/java/com/basistheory/resources/applepay/merchant/AsyncRawMerchantClient.java @@ -15,7 +15,6 @@ import com.basistheory.errors.UnauthorizedError; import com.basistheory.resources.applepay.merchant.requests.ApplePayMerchantRegisterRequest; import com.basistheory.types.ApplePayMerchant; -import com.basistheory.types.ApplePayToken; import com.basistheory.types.ProblemDetails; import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; @@ -38,11 +37,12 @@ public AsyncRawMerchantClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public CompletableFuture> get(String id) { + public CompletableFuture> get(String id) { return get(id, null); } - public CompletableFuture> get(String id, RequestOptions requestOptions) { + public CompletableFuture> get( + String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("apple-pay/merchant-registration") @@ -58,14 +58,14 @@ public CompletableFuture> get(String i if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new BasisTheoryApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplePayToken.class), + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplePayMerchant.class), response)); return; } diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/MerchantClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/MerchantClient.java index 1c1dda3..853c451 100644 --- a/src/main/java/com/basistheory/resources/applepay/merchant/MerchantClient.java +++ b/src/main/java/com/basistheory/resources/applepay/merchant/MerchantClient.java @@ -5,18 +5,23 @@ import com.basistheory.core.ClientOptions; import com.basistheory.core.RequestOptions; +import com.basistheory.core.Suppliers; +import com.basistheory.resources.applepay.merchant.certificates.CertificatesClient; import com.basistheory.resources.applepay.merchant.requests.ApplePayMerchantRegisterRequest; import com.basistheory.types.ApplePayMerchant; -import com.basistheory.types.ApplePayToken; +import java.util.function.Supplier; public class MerchantClient { protected final ClientOptions clientOptions; private final RawMerchantClient rawClient; + protected final Supplier certificatesClient; + public MerchantClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.rawClient = new RawMerchantClient(clientOptions); + this.certificatesClient = Suppliers.memoize(() -> new CertificatesClient(clientOptions)); } /** @@ -26,11 +31,11 @@ public RawMerchantClient withRawResponse() { return this.rawClient; } - public ApplePayToken get(String id) { + public ApplePayMerchant get(String id) { return this.rawClient.get(id).body(); } - public ApplePayToken get(String id, RequestOptions requestOptions) { + public ApplePayMerchant get(String id, RequestOptions requestOptions) { return this.rawClient.get(id, requestOptions).body(); } @@ -53,4 +58,8 @@ public ApplePayMerchant create(ApplePayMerchantRegisterRequest request) { public ApplePayMerchant create(ApplePayMerchantRegisterRequest request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } + + public CertificatesClient certificates() { + return this.certificatesClient.get(); + } } diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/RawMerchantClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/RawMerchantClient.java index 3149afe..2013011 100644 --- a/src/main/java/com/basistheory/resources/applepay/merchant/RawMerchantClient.java +++ b/src/main/java/com/basistheory/resources/applepay/merchant/RawMerchantClient.java @@ -15,7 +15,6 @@ import com.basistheory.errors.UnauthorizedError; import com.basistheory.resources.applepay.merchant.requests.ApplePayMerchantRegisterRequest; import com.basistheory.types.ApplePayMerchant; -import com.basistheory.types.ApplePayToken; import com.basistheory.types.ProblemDetails; import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; @@ -34,11 +33,11 @@ public RawMerchantClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public BasisTheoryApiHttpResponse get(String id) { + public BasisTheoryApiHttpResponse get(String id) { return get(id, null); } - public BasisTheoryApiHttpResponse get(String id, RequestOptions requestOptions) { + public BasisTheoryApiHttpResponse get(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("apple-pay/merchant-registration") @@ -58,7 +57,7 @@ public BasisTheoryApiHttpResponse get(String id, RequestOptions r ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new BasisTheoryApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplePayToken.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplePayMerchant.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncCertificatesClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncCertificatesClient.java new file mode 100644 index 0000000..11c750d --- /dev/null +++ b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncCertificatesClient.java @@ -0,0 +1,59 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.applepay.merchant.certificates; + +import com.basistheory.core.ClientOptions; +import com.basistheory.core.RequestOptions; +import com.basistheory.resources.applepay.merchant.certificates.requests.ApplePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.ApplePayMerchantCertificates; +import java.util.concurrent.CompletableFuture; + +public class AsyncCertificatesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCertificatesClient rawClient; + + public AsyncCertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCertificatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCertificatesClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture get(String merchantId, String id) { + return this.rawClient.get(merchantId, id).thenApply(response -> response.body()); + } + + public CompletableFuture get( + String merchantId, String id, RequestOptions requestOptions) { + return this.rawClient.get(merchantId, id, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture delete(String merchantId, String id) { + return this.rawClient.delete(merchantId, id).thenApply(response -> response.body()); + } + + public CompletableFuture delete(String merchantId, String id, RequestOptions requestOptions) { + return this.rawClient.delete(merchantId, id, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture create(String merchantId) { + return this.rawClient.create(merchantId).thenApply(response -> response.body()); + } + + public CompletableFuture create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request) { + return this.rawClient.create(merchantId, request).thenApply(response -> response.body()); + } + + public CompletableFuture create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + return this.rawClient.create(merchantId, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncRawCertificatesClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncRawCertificatesClient.java new file mode 100644 index 0000000..7ecc008 --- /dev/null +++ b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/AsyncRawCertificatesClient.java @@ -0,0 +1,279 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.applepay.merchant.certificates; + +import com.basistheory.core.BasisTheoryApiApiException; +import com.basistheory.core.BasisTheoryApiHttpResponse; +import com.basistheory.core.BasisTheoryException; +import com.basistheory.core.ClientOptions; +import com.basistheory.core.MediaTypes; +import com.basistheory.core.ObjectMappers; +import com.basistheory.core.RequestOptions; +import com.basistheory.errors.ForbiddenError; +import com.basistheory.errors.NotFoundError; +import com.basistheory.errors.UnauthorizedError; +import com.basistheory.resources.applepay.merchant.certificates.requests.ApplePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.ApplePayMerchantCertificates; +import com.basistheory.types.ProblemDetails; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCertificatesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> get( + String merchantId, String id) { + return get(merchantId, id, null); + } + + public CompletableFuture> get( + String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("apple-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ApplePayMerchantCertificates.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> delete(String merchantId, String id) { + return delete(merchantId, id, null); + } + + public CompletableFuture> delete( + String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("apple-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> create(String merchantId) { + return create( + merchantId, + ApplePayMerchantCertificatesRegisterRequest.builder().build()); + } + + public CompletableFuture> create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request) { + return create(merchantId, request, null); + } + + public CompletableFuture> create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("apple-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BasisTheoryException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ApplePayMerchantCertificates.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/certificates/CertificatesClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/CertificatesClient.java new file mode 100644 index 0000000..5b292f5 --- /dev/null +++ b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/CertificatesClient.java @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.applepay.merchant.certificates; + +import com.basistheory.core.ClientOptions; +import com.basistheory.core.RequestOptions; +import com.basistheory.resources.applepay.merchant.certificates.requests.ApplePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.ApplePayMerchantCertificates; + +public class CertificatesClient { + protected final ClientOptions clientOptions; + + private final RawCertificatesClient rawClient; + + public CertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCertificatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCertificatesClient withRawResponse() { + return this.rawClient; + } + + public ApplePayMerchantCertificates get(String merchantId, String id) { + return this.rawClient.get(merchantId, id).body(); + } + + public ApplePayMerchantCertificates get(String merchantId, String id, RequestOptions requestOptions) { + return this.rawClient.get(merchantId, id, requestOptions).body(); + } + + public void delete(String merchantId, String id) { + this.rawClient.delete(merchantId, id).body(); + } + + public void delete(String merchantId, String id, RequestOptions requestOptions) { + this.rawClient.delete(merchantId, id, requestOptions).body(); + } + + public ApplePayMerchantCertificates create(String merchantId) { + return this.rawClient.create(merchantId).body(); + } + + public ApplePayMerchantCertificates create(String merchantId, ApplePayMerchantCertificatesRegisterRequest request) { + return this.rawClient.create(merchantId, request).body(); + } + + public ApplePayMerchantCertificates create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + return this.rawClient.create(merchantId, request, requestOptions).body(); + } +} diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/certificates/RawCertificatesClient.java b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/RawCertificatesClient.java new file mode 100644 index 0000000..f5f9517 --- /dev/null +++ b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/RawCertificatesClient.java @@ -0,0 +1,220 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.applepay.merchant.certificates; + +import com.basistheory.core.BasisTheoryApiApiException; +import com.basistheory.core.BasisTheoryApiHttpResponse; +import com.basistheory.core.BasisTheoryException; +import com.basistheory.core.ClientOptions; +import com.basistheory.core.MediaTypes; +import com.basistheory.core.ObjectMappers; +import com.basistheory.core.RequestOptions; +import com.basistheory.errors.ForbiddenError; +import com.basistheory.errors.NotFoundError; +import com.basistheory.errors.UnauthorizedError; +import com.basistheory.resources.applepay.merchant.certificates.requests.ApplePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.ApplePayMerchantCertificates; +import com.basistheory.types.ProblemDetails; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCertificatesClient { + protected final ClientOptions clientOptions; + + public RawCertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BasisTheoryApiHttpResponse get(String merchantId, String id) { + return get(merchantId, id, null); + } + + public BasisTheoryApiHttpResponse get( + String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("apple-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplePayMerchantCertificates.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + + public BasisTheoryApiHttpResponse delete(String merchantId, String id) { + return delete(merchantId, id, null); + } + + public BasisTheoryApiHttpResponse delete(String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("apple-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + + public BasisTheoryApiHttpResponse create(String merchantId) { + return create( + merchantId, + ApplePayMerchantCertificatesRegisterRequest.builder().build()); + } + + public BasisTheoryApiHttpResponse create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request) { + return create(merchantId, request, null); + } + + public BasisTheoryApiHttpResponse create( + String merchantId, ApplePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("apple-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BasisTheoryException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplePayMerchantCertificates.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/basistheory/resources/applepay/merchant/certificates/requests/ApplePayMerchantCertificatesRegisterRequest.java b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/requests/ApplePayMerchantCertificatesRegisterRequest.java new file mode 100644 index 0000000..edfa313 --- /dev/null +++ b/src/main/java/com/basistheory/resources/applepay/merchant/certificates/requests/ApplePayMerchantCertificatesRegisterRequest.java @@ -0,0 +1,205 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.applepay.merchant.certificates.requests; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ApplePayMerchantCertificatesRegisterRequest.Builder.class) +public final class ApplePayMerchantCertificatesRegisterRequest { + private final Optional merchantCertificateData; + + private final Optional merchantCertificatePassword; + + private final Optional paymentProcessorCertificateData; + + private final Optional paymentProcessorCertificatePassword; + + private final Optional domain; + + private final Map additionalProperties; + + private ApplePayMerchantCertificatesRegisterRequest( + Optional merchantCertificateData, + Optional merchantCertificatePassword, + Optional paymentProcessorCertificateData, + Optional paymentProcessorCertificatePassword, + Optional domain, + Map additionalProperties) { + this.merchantCertificateData = merchantCertificateData; + this.merchantCertificatePassword = merchantCertificatePassword; + this.paymentProcessorCertificateData = paymentProcessorCertificateData; + this.paymentProcessorCertificatePassword = paymentProcessorCertificatePassword; + this.domain = domain; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("merchant_certificate_data") + public Optional getMerchantCertificateData() { + return merchantCertificateData; + } + + @JsonProperty("merchant_certificate_password") + public Optional getMerchantCertificatePassword() { + return merchantCertificatePassword; + } + + @JsonProperty("payment_processor_certificate_data") + public Optional getPaymentProcessorCertificateData() { + return paymentProcessorCertificateData; + } + + @JsonProperty("payment_processor_certificate_password") + public Optional getPaymentProcessorCertificatePassword() { + return paymentProcessorCertificatePassword; + } + + @JsonProperty("domain") + public Optional getDomain() { + return domain; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApplePayMerchantCertificatesRegisterRequest + && equalTo((ApplePayMerchantCertificatesRegisterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApplePayMerchantCertificatesRegisterRequest other) { + return merchantCertificateData.equals(other.merchantCertificateData) + && merchantCertificatePassword.equals(other.merchantCertificatePassword) + && paymentProcessorCertificateData.equals(other.paymentProcessorCertificateData) + && paymentProcessorCertificatePassword.equals(other.paymentProcessorCertificatePassword) + && domain.equals(other.domain); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.merchantCertificateData, + this.merchantCertificatePassword, + this.paymentProcessorCertificateData, + this.paymentProcessorCertificatePassword, + this.domain); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional merchantCertificateData = Optional.empty(); + + private Optional merchantCertificatePassword = Optional.empty(); + + private Optional paymentProcessorCertificateData = Optional.empty(); + + private Optional paymentProcessorCertificatePassword = Optional.empty(); + + private Optional domain = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ApplePayMerchantCertificatesRegisterRequest other) { + merchantCertificateData(other.getMerchantCertificateData()); + merchantCertificatePassword(other.getMerchantCertificatePassword()); + paymentProcessorCertificateData(other.getPaymentProcessorCertificateData()); + paymentProcessorCertificatePassword(other.getPaymentProcessorCertificatePassword()); + domain(other.getDomain()); + return this; + } + + @JsonSetter(value = "merchant_certificate_data", nulls = Nulls.SKIP) + public Builder merchantCertificateData(Optional merchantCertificateData) { + this.merchantCertificateData = merchantCertificateData; + return this; + } + + public Builder merchantCertificateData(String merchantCertificateData) { + this.merchantCertificateData = Optional.ofNullable(merchantCertificateData); + return this; + } + + @JsonSetter(value = "merchant_certificate_password", nulls = Nulls.SKIP) + public Builder merchantCertificatePassword(Optional merchantCertificatePassword) { + this.merchantCertificatePassword = merchantCertificatePassword; + return this; + } + + public Builder merchantCertificatePassword(String merchantCertificatePassword) { + this.merchantCertificatePassword = Optional.ofNullable(merchantCertificatePassword); + return this; + } + + @JsonSetter(value = "payment_processor_certificate_data", nulls = Nulls.SKIP) + public Builder paymentProcessorCertificateData(Optional paymentProcessorCertificateData) { + this.paymentProcessorCertificateData = paymentProcessorCertificateData; + return this; + } + + public Builder paymentProcessorCertificateData(String paymentProcessorCertificateData) { + this.paymentProcessorCertificateData = Optional.ofNullable(paymentProcessorCertificateData); + return this; + } + + @JsonSetter(value = "payment_processor_certificate_password", nulls = Nulls.SKIP) + public Builder paymentProcessorCertificatePassword(Optional paymentProcessorCertificatePassword) { + this.paymentProcessorCertificatePassword = paymentProcessorCertificatePassword; + return this; + } + + public Builder paymentProcessorCertificatePassword(String paymentProcessorCertificatePassword) { + this.paymentProcessorCertificatePassword = Optional.ofNullable(paymentProcessorCertificatePassword); + return this; + } + + @JsonSetter(value = "domain", nulls = Nulls.SKIP) + public Builder domain(Optional domain) { + this.domain = domain; + return this; + } + + public Builder domain(String domain) { + this.domain = Optional.ofNullable(domain); + return this; + } + + public ApplePayMerchantCertificatesRegisterRequest build() { + return new ApplePayMerchantCertificatesRegisterRequest( + merchantCertificateData, + merchantCertificatePassword, + paymentProcessorCertificateData, + paymentProcessorCertificatePassword, + domain, + additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/AsyncGooglePayClient.java b/src/main/java/com/basistheory/resources/googlepay/AsyncGooglePayClient.java index a219bc7..a6232b5 100644 --- a/src/main/java/com/basistheory/resources/googlepay/AsyncGooglePayClient.java +++ b/src/main/java/com/basistheory/resources/googlepay/AsyncGooglePayClient.java @@ -5,19 +5,25 @@ import com.basistheory.core.ClientOptions; import com.basistheory.core.RequestOptions; +import com.basistheory.core.Suppliers; +import com.basistheory.resources.googlepay.merchant.AsyncMerchantClient; import com.basistheory.resources.googlepay.requests.GooglePayCreateRequest; import com.basistheory.types.GooglePayCreateResponse; import com.basistheory.types.GooglePayToken; import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; public class AsyncGooglePayClient { protected final ClientOptions clientOptions; private final AsyncRawGooglePayClient rawClient; + protected final Supplier merchantClient; + public AsyncGooglePayClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.rawClient = new AsyncRawGooglePayClient(clientOptions); + this.merchantClient = Suppliers.memoize(() -> new AsyncMerchantClient(clientOptions)); } /** @@ -55,4 +61,8 @@ public CompletableFuture delete(String id) { public CompletableFuture delete(String id, RequestOptions requestOptions) { return this.rawClient.delete(id, requestOptions).thenApply(response -> response.body()); } + + public AsyncMerchantClient merchant() { + return this.merchantClient.get(); + } } diff --git a/src/main/java/com/basistheory/resources/googlepay/GooglePayClient.java b/src/main/java/com/basistheory/resources/googlepay/GooglePayClient.java index 3470520..cc93308 100644 --- a/src/main/java/com/basistheory/resources/googlepay/GooglePayClient.java +++ b/src/main/java/com/basistheory/resources/googlepay/GooglePayClient.java @@ -5,18 +5,24 @@ import com.basistheory.core.ClientOptions; import com.basistheory.core.RequestOptions; +import com.basistheory.core.Suppliers; +import com.basistheory.resources.googlepay.merchant.MerchantClient; import com.basistheory.resources.googlepay.requests.GooglePayCreateRequest; import com.basistheory.types.GooglePayCreateResponse; import com.basistheory.types.GooglePayToken; +import java.util.function.Supplier; public class GooglePayClient { protected final ClientOptions clientOptions; private final RawGooglePayClient rawClient; + protected final Supplier merchantClient; + public GooglePayClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.rawClient = new RawGooglePayClient(clientOptions); + this.merchantClient = Suppliers.memoize(() -> new MerchantClient(clientOptions)); } /** @@ -53,4 +59,8 @@ public String delete(String id) { public String delete(String id, RequestOptions requestOptions) { return this.rawClient.delete(id, requestOptions).body(); } + + public MerchantClient merchant() { + return this.merchantClient.get(); + } } diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/AsyncMerchantClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/AsyncMerchantClient.java new file mode 100644 index 0000000..cbb3951 --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/AsyncMerchantClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant; + +import com.basistheory.core.ClientOptions; +import com.basistheory.core.RequestOptions; +import com.basistheory.core.Suppliers; +import com.basistheory.resources.googlepay.merchant.certificates.AsyncCertificatesClient; +import com.basistheory.resources.googlepay.merchant.requests.GooglePayMerchantRegisterRequest; +import com.basistheory.types.GooglePayMerchant; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +public class AsyncMerchantClient { + protected final ClientOptions clientOptions; + + private final AsyncRawMerchantClient rawClient; + + protected final Supplier certificatesClient; + + public AsyncMerchantClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawMerchantClient(clientOptions); + this.certificatesClient = Suppliers.memoize(() -> new AsyncCertificatesClient(clientOptions)); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawMerchantClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture get(String id) { + return this.rawClient.get(id).thenApply(response -> response.body()); + } + + public CompletableFuture get(String id, RequestOptions requestOptions) { + return this.rawClient.get(id, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture delete(String id) { + return this.rawClient.delete(id).thenApply(response -> response.body()); + } + + public CompletableFuture delete(String id, RequestOptions requestOptions) { + return this.rawClient.delete(id, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture create() { + return this.rawClient.create().thenApply(response -> response.body()); + } + + public CompletableFuture create(GooglePayMerchantRegisterRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + public CompletableFuture create( + GooglePayMerchantRegisterRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + public AsyncCertificatesClient certificates() { + return this.certificatesClient.get(); + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/AsyncRawMerchantClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/AsyncRawMerchantClient.java new file mode 100644 index 0000000..8d1c2df --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/AsyncRawMerchantClient.java @@ -0,0 +1,262 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant; + +import com.basistheory.core.BasisTheoryApiApiException; +import com.basistheory.core.BasisTheoryApiHttpResponse; +import com.basistheory.core.BasisTheoryException; +import com.basistheory.core.ClientOptions; +import com.basistheory.core.MediaTypes; +import com.basistheory.core.ObjectMappers; +import com.basistheory.core.RequestOptions; +import com.basistheory.errors.ForbiddenError; +import com.basistheory.errors.NotFoundError; +import com.basistheory.errors.UnauthorizedError; +import com.basistheory.resources.googlepay.merchant.requests.GooglePayMerchantRegisterRequest; +import com.basistheory.types.GooglePayMerchant; +import com.basistheory.types.ProblemDetails; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawMerchantClient { + protected final ClientOptions clientOptions; + + public AsyncRawMerchantClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> get(String id) { + return get(id, null); + } + + public CompletableFuture> get( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GooglePayMerchant.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> delete(String id) { + return delete(id, null); + } + + public CompletableFuture> delete(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> create() { + return create(GooglePayMerchantRegisterRequest.builder().build()); + } + + public CompletableFuture> create( + GooglePayMerchantRegisterRequest request) { + return create(request, null); + } + + public CompletableFuture> create( + GooglePayMerchantRegisterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BasisTheoryException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GooglePayMerchant.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/MerchantClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/MerchantClient.java new file mode 100644 index 0000000..83bd155 --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/MerchantClient.java @@ -0,0 +1,65 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant; + +import com.basistheory.core.ClientOptions; +import com.basistheory.core.RequestOptions; +import com.basistheory.core.Suppliers; +import com.basistheory.resources.googlepay.merchant.certificates.CertificatesClient; +import com.basistheory.resources.googlepay.merchant.requests.GooglePayMerchantRegisterRequest; +import com.basistheory.types.GooglePayMerchant; +import java.util.function.Supplier; + +public class MerchantClient { + protected final ClientOptions clientOptions; + + private final RawMerchantClient rawClient; + + protected final Supplier certificatesClient; + + public MerchantClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawMerchantClient(clientOptions); + this.certificatesClient = Suppliers.memoize(() -> new CertificatesClient(clientOptions)); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawMerchantClient withRawResponse() { + return this.rawClient; + } + + public GooglePayMerchant get(String id) { + return this.rawClient.get(id).body(); + } + + public GooglePayMerchant get(String id, RequestOptions requestOptions) { + return this.rawClient.get(id, requestOptions).body(); + } + + public void delete(String id) { + this.rawClient.delete(id).body(); + } + + public void delete(String id, RequestOptions requestOptions) { + this.rawClient.delete(id, requestOptions).body(); + } + + public GooglePayMerchant create() { + return this.rawClient.create().body(); + } + + public GooglePayMerchant create(GooglePayMerchantRegisterRequest request) { + return this.rawClient.create(request).body(); + } + + public GooglePayMerchant create(GooglePayMerchantRegisterRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).body(); + } + + public CertificatesClient certificates() { + return this.certificatesClient.get(); + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/RawMerchantClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/RawMerchantClient.java new file mode 100644 index 0000000..8987592 --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/RawMerchantClient.java @@ -0,0 +1,205 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant; + +import com.basistheory.core.BasisTheoryApiApiException; +import com.basistheory.core.BasisTheoryApiHttpResponse; +import com.basistheory.core.BasisTheoryException; +import com.basistheory.core.ClientOptions; +import com.basistheory.core.MediaTypes; +import com.basistheory.core.ObjectMappers; +import com.basistheory.core.RequestOptions; +import com.basistheory.errors.ForbiddenError; +import com.basistheory.errors.NotFoundError; +import com.basistheory.errors.UnauthorizedError; +import com.basistheory.resources.googlepay.merchant.requests.GooglePayMerchantRegisterRequest; +import com.basistheory.types.GooglePayMerchant; +import com.basistheory.types.ProblemDetails; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawMerchantClient { + protected final ClientOptions clientOptions; + + public RawMerchantClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BasisTheoryApiHttpResponse get(String id) { + return get(id, null); + } + + public BasisTheoryApiHttpResponse get(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GooglePayMerchant.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + + public BasisTheoryApiHttpResponse delete(String id) { + return delete(id, null); + } + + public BasisTheoryApiHttpResponse delete(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + + public BasisTheoryApiHttpResponse create() { + return create(GooglePayMerchantRegisterRequest.builder().build()); + } + + public BasisTheoryApiHttpResponse create(GooglePayMerchantRegisterRequest request) { + return create(request, null); + } + + public BasisTheoryApiHttpResponse create( + GooglePayMerchantRegisterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BasisTheoryException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GooglePayMerchant.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncCertificatesClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncCertificatesClient.java new file mode 100644 index 0000000..4becc7f --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncCertificatesClient.java @@ -0,0 +1,59 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant.certificates; + +import com.basistheory.core.ClientOptions; +import com.basistheory.core.RequestOptions; +import com.basistheory.resources.googlepay.merchant.certificates.requests.GooglePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.GooglePayMerchantCertificates; +import java.util.concurrent.CompletableFuture; + +public class AsyncCertificatesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCertificatesClient rawClient; + + public AsyncCertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCertificatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCertificatesClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture get(String merchantId, String id) { + return this.rawClient.get(merchantId, id).thenApply(response -> response.body()); + } + + public CompletableFuture get( + String merchantId, String id, RequestOptions requestOptions) { + return this.rawClient.get(merchantId, id, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture delete(String merchantId, String id) { + return this.rawClient.delete(merchantId, id).thenApply(response -> response.body()); + } + + public CompletableFuture delete(String merchantId, String id, RequestOptions requestOptions) { + return this.rawClient.delete(merchantId, id, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture create(String merchantId) { + return this.rawClient.create(merchantId).thenApply(response -> response.body()); + } + + public CompletableFuture create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request) { + return this.rawClient.create(merchantId, request).thenApply(response -> response.body()); + } + + public CompletableFuture create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + return this.rawClient.create(merchantId, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncRawCertificatesClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncRawCertificatesClient.java new file mode 100644 index 0000000..b8df28c --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/AsyncRawCertificatesClient.java @@ -0,0 +1,279 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant.certificates; + +import com.basistheory.core.BasisTheoryApiApiException; +import com.basistheory.core.BasisTheoryApiHttpResponse; +import com.basistheory.core.BasisTheoryException; +import com.basistheory.core.ClientOptions; +import com.basistheory.core.MediaTypes; +import com.basistheory.core.ObjectMappers; +import com.basistheory.core.RequestOptions; +import com.basistheory.errors.ForbiddenError; +import com.basistheory.errors.NotFoundError; +import com.basistheory.errors.UnauthorizedError; +import com.basistheory.resources.googlepay.merchant.certificates.requests.GooglePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.GooglePayMerchantCertificates; +import com.basistheory.types.ProblemDetails; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCertificatesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> get( + String merchantId, String id) { + return get(merchantId, id, null); + } + + public CompletableFuture> get( + String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GooglePayMerchantCertificates.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> delete(String merchantId, String id) { + return delete(merchantId, id, null); + } + + public CompletableFuture> delete( + String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> create(String merchantId) { + return create( + merchantId, + GooglePayMerchantCertificatesRegisterRequest.builder().build()); + } + + public CompletableFuture> create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request) { + return create(merchantId, request, null); + } + + public CompletableFuture> create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BasisTheoryException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GooglePayMerchantCertificates.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BasisTheoryException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/CertificatesClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/CertificatesClient.java new file mode 100644 index 0000000..f181a90 --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/CertificatesClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant.certificates; + +import com.basistheory.core.ClientOptions; +import com.basistheory.core.RequestOptions; +import com.basistheory.resources.googlepay.merchant.certificates.requests.GooglePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.GooglePayMerchantCertificates; + +public class CertificatesClient { + protected final ClientOptions clientOptions; + + private final RawCertificatesClient rawClient; + + public CertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCertificatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCertificatesClient withRawResponse() { + return this.rawClient; + } + + public GooglePayMerchantCertificates get(String merchantId, String id) { + return this.rawClient.get(merchantId, id).body(); + } + + public GooglePayMerchantCertificates get(String merchantId, String id, RequestOptions requestOptions) { + return this.rawClient.get(merchantId, id, requestOptions).body(); + } + + public void delete(String merchantId, String id) { + this.rawClient.delete(merchantId, id).body(); + } + + public void delete(String merchantId, String id, RequestOptions requestOptions) { + this.rawClient.delete(merchantId, id, requestOptions).body(); + } + + public GooglePayMerchantCertificates create(String merchantId) { + return this.rawClient.create(merchantId).body(); + } + + public GooglePayMerchantCertificates create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request) { + return this.rawClient.create(merchantId, request).body(); + } + + public GooglePayMerchantCertificates create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + return this.rawClient.create(merchantId, request, requestOptions).body(); + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/RawCertificatesClient.java b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/RawCertificatesClient.java new file mode 100644 index 0000000..ca37598 --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/RawCertificatesClient.java @@ -0,0 +1,220 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant.certificates; + +import com.basistheory.core.BasisTheoryApiApiException; +import com.basistheory.core.BasisTheoryApiHttpResponse; +import com.basistheory.core.BasisTheoryException; +import com.basistheory.core.ClientOptions; +import com.basistheory.core.MediaTypes; +import com.basistheory.core.ObjectMappers; +import com.basistheory.core.RequestOptions; +import com.basistheory.errors.ForbiddenError; +import com.basistheory.errors.NotFoundError; +import com.basistheory.errors.UnauthorizedError; +import com.basistheory.resources.googlepay.merchant.certificates.requests.GooglePayMerchantCertificatesRegisterRequest; +import com.basistheory.types.GooglePayMerchantCertificates; +import com.basistheory.types.ProblemDetails; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCertificatesClient { + protected final ClientOptions clientOptions; + + public RawCertificatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BasisTheoryApiHttpResponse get(String merchantId, String id) { + return get(merchantId, id, null); + } + + public BasisTheoryApiHttpResponse get( + String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GooglePayMerchantCertificates.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + + public BasisTheoryApiHttpResponse delete(String merchantId, String id) { + return delete(merchantId, id, null); + } + + public BasisTheoryApiHttpResponse delete(String merchantId, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + + public BasisTheoryApiHttpResponse create(String merchantId) { + return create( + merchantId, + GooglePayMerchantCertificatesRegisterRequest.builder().build()); + } + + public BasisTheoryApiHttpResponse create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request) { + return create(merchantId, request, null); + } + + public BasisTheoryApiHttpResponse create( + String merchantId, GooglePayMerchantCertificatesRegisterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("google-pay/merchant-registration") + .addPathSegment(merchantId) + .addPathSegments("certificates") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BasisTheoryException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BasisTheoryApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GooglePayMerchantCertificates.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BasisTheoryApiApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/requests/GooglePayMerchantCertificatesRegisterRequest.java b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/requests/GooglePayMerchantCertificatesRegisterRequest.java new file mode 100644 index 0000000..b96dc7a --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/certificates/requests/GooglePayMerchantCertificatesRegisterRequest.java @@ -0,0 +1,123 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant.certificates.requests; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GooglePayMerchantCertificatesRegisterRequest.Builder.class) +public final class GooglePayMerchantCertificatesRegisterRequest { + private final Optional merchantCertificateData; + + private final Optional merchantCertificatePassword; + + private final Map additionalProperties; + + private GooglePayMerchantCertificatesRegisterRequest( + Optional merchantCertificateData, + Optional merchantCertificatePassword, + Map additionalProperties) { + this.merchantCertificateData = merchantCertificateData; + this.merchantCertificatePassword = merchantCertificatePassword; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("merchant_certificate_data") + public Optional getMerchantCertificateData() { + return merchantCertificateData; + } + + @JsonProperty("merchant_certificate_password") + public Optional getMerchantCertificatePassword() { + return merchantCertificatePassword; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GooglePayMerchantCertificatesRegisterRequest + && equalTo((GooglePayMerchantCertificatesRegisterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GooglePayMerchantCertificatesRegisterRequest other) { + return merchantCertificateData.equals(other.merchantCertificateData) + && merchantCertificatePassword.equals(other.merchantCertificatePassword); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.merchantCertificateData, this.merchantCertificatePassword); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional merchantCertificateData = Optional.empty(); + + private Optional merchantCertificatePassword = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GooglePayMerchantCertificatesRegisterRequest other) { + merchantCertificateData(other.getMerchantCertificateData()); + merchantCertificatePassword(other.getMerchantCertificatePassword()); + return this; + } + + @JsonSetter(value = "merchant_certificate_data", nulls = Nulls.SKIP) + public Builder merchantCertificateData(Optional merchantCertificateData) { + this.merchantCertificateData = merchantCertificateData; + return this; + } + + public Builder merchantCertificateData(String merchantCertificateData) { + this.merchantCertificateData = Optional.ofNullable(merchantCertificateData); + return this; + } + + @JsonSetter(value = "merchant_certificate_password", nulls = Nulls.SKIP) + public Builder merchantCertificatePassword(Optional merchantCertificatePassword) { + this.merchantCertificatePassword = merchantCertificatePassword; + return this; + } + + public Builder merchantCertificatePassword(String merchantCertificatePassword) { + this.merchantCertificatePassword = Optional.ofNullable(merchantCertificatePassword); + return this; + } + + public GooglePayMerchantCertificatesRegisterRequest build() { + return new GooglePayMerchantCertificatesRegisterRequest( + merchantCertificateData, merchantCertificatePassword, additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/merchant/requests/GooglePayMerchantRegisterRequest.java b/src/main/java/com/basistheory/resources/googlepay/merchant/requests/GooglePayMerchantRegisterRequest.java new file mode 100644 index 0000000..87a9fcd --- /dev/null +++ b/src/main/java/com/basistheory/resources/googlepay/merchant/requests/GooglePayMerchantRegisterRequest.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.resources.googlepay.merchant.requests; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GooglePayMerchantRegisterRequest.Builder.class) +public final class GooglePayMerchantRegisterRequest { + private final Optional merchantIdentifier; + + private final Map additionalProperties; + + private GooglePayMerchantRegisterRequest( + Optional merchantIdentifier, Map additionalProperties) { + this.merchantIdentifier = merchantIdentifier; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("merchant_identifier") + public Optional getMerchantIdentifier() { + return merchantIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GooglePayMerchantRegisterRequest && equalTo((GooglePayMerchantRegisterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GooglePayMerchantRegisterRequest other) { + return merchantIdentifier.equals(other.merchantIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.merchantIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional merchantIdentifier = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GooglePayMerchantRegisterRequest other) { + merchantIdentifier(other.getMerchantIdentifier()); + return this; + } + + @JsonSetter(value = "merchant_identifier", nulls = Nulls.SKIP) + public Builder merchantIdentifier(Optional merchantIdentifier) { + this.merchantIdentifier = merchantIdentifier; + return this; + } + + public Builder merchantIdentifier(String merchantIdentifier) { + this.merchantIdentifier = Optional.ofNullable(merchantIdentifier); + return this; + } + + public GooglePayMerchantRegisterRequest build() { + return new GooglePayMerchantRegisterRequest(merchantIdentifier, additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/resources/googlepay/requests/GooglePayCreateRequest.java b/src/main/java/com/basistheory/resources/googlepay/requests/GooglePayCreateRequest.java index 18af5eb..f3ed208 100644 --- a/src/main/java/com/basistheory/resources/googlepay/requests/GooglePayCreateRequest.java +++ b/src/main/java/com/basistheory/resources/googlepay/requests/GooglePayCreateRequest.java @@ -25,14 +25,18 @@ public final class GooglePayCreateRequest { private final Optional googlePaymentData; + private final Optional merchantRegistrationId; + private final Map additionalProperties; private GooglePayCreateRequest( Optional expiresAt, Optional googlePaymentData, + Optional merchantRegistrationId, Map additionalProperties) { this.expiresAt = expiresAt; this.googlePaymentData = googlePaymentData; + this.merchantRegistrationId = merchantRegistrationId; this.additionalProperties = additionalProperties; } @@ -46,6 +50,11 @@ public Optional getGooglePaymentData() { return googlePaymentData; } + @JsonProperty("merchant_registration_id") + public Optional getMerchantRegistrationId() { + return merchantRegistrationId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -58,12 +67,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(GooglePayCreateRequest other) { - return expiresAt.equals(other.expiresAt) && googlePaymentData.equals(other.googlePaymentData); + return expiresAt.equals(other.expiresAt) + && googlePaymentData.equals(other.googlePaymentData) + && merchantRegistrationId.equals(other.merchantRegistrationId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expiresAt, this.googlePaymentData); + return Objects.hash(this.expiresAt, this.googlePaymentData, this.merchantRegistrationId); } @java.lang.Override @@ -81,6 +92,8 @@ public static final class Builder { private Optional googlePaymentData = Optional.empty(); + private Optional merchantRegistrationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -89,6 +102,7 @@ private Builder() {} public Builder from(GooglePayCreateRequest other) { expiresAt(other.getExpiresAt()); googlePaymentData(other.getGooglePaymentData()); + merchantRegistrationId(other.getMerchantRegistrationId()); return this; } @@ -114,8 +128,20 @@ public Builder googlePaymentData(GooglePayMethodToken googlePaymentData) { return this; } + @JsonSetter(value = "merchant_registration_id", nulls = Nulls.SKIP) + public Builder merchantRegistrationId(Optional merchantRegistrationId) { + this.merchantRegistrationId = merchantRegistrationId; + return this; + } + + public Builder merchantRegistrationId(String merchantRegistrationId) { + this.merchantRegistrationId = Optional.ofNullable(merchantRegistrationId); + return this; + } + public GooglePayCreateRequest build() { - return new GooglePayCreateRequest(expiresAt, googlePaymentData, additionalProperties); + return new GooglePayCreateRequest( + expiresAt, googlePaymentData, merchantRegistrationId, additionalProperties); } } } diff --git a/src/main/java/com/basistheory/types/ApplePayMerchantCertificates.java b/src/main/java/com/basistheory/types/ApplePayMerchantCertificates.java new file mode 100644 index 0000000..8f36fd7 --- /dev/null +++ b/src/main/java/com/basistheory/types/ApplePayMerchantCertificates.java @@ -0,0 +1,312 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.types; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ApplePayMerchantCertificates.Builder.class) +public final class ApplePayMerchantCertificates { + private final Optional id; + + private final Optional tenantId; + + private final Optional domain; + + private final Optional merchantCertificateExpirationDate; + + private final Optional merchantCertificateFingerprint; + + private final Optional paymentProcessorCertificateExpirationDate; + + private final Optional paymentProcessorCertificateFingerprint; + + private final Optional createdBy; + + private final Optional createdAt; + + private final Map additionalProperties; + + private ApplePayMerchantCertificates( + Optional id, + Optional tenantId, + Optional domain, + Optional merchantCertificateExpirationDate, + Optional merchantCertificateFingerprint, + Optional paymentProcessorCertificateExpirationDate, + Optional paymentProcessorCertificateFingerprint, + Optional createdBy, + Optional createdAt, + Map additionalProperties) { + this.id = id; + this.tenantId = tenantId; + this.domain = domain; + this.merchantCertificateExpirationDate = merchantCertificateExpirationDate; + this.merchantCertificateFingerprint = merchantCertificateFingerprint; + this.paymentProcessorCertificateExpirationDate = paymentProcessorCertificateExpirationDate; + this.paymentProcessorCertificateFingerprint = paymentProcessorCertificateFingerprint; + this.createdBy = createdBy; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("tenant_id") + public Optional getTenantId() { + return tenantId; + } + + @JsonProperty("domain") + public Optional getDomain() { + return domain; + } + + @JsonProperty("merchant_certificate_expiration_date") + public Optional getMerchantCertificateExpirationDate() { + return merchantCertificateExpirationDate; + } + + @JsonProperty("merchant_certificate_fingerprint") + public Optional getMerchantCertificateFingerprint() { + return merchantCertificateFingerprint; + } + + @JsonProperty("payment_processor_certificate_expiration_date") + public Optional getPaymentProcessorCertificateExpirationDate() { + return paymentProcessorCertificateExpirationDate; + } + + @JsonProperty("payment_processor_certificate_fingerprint") + public Optional getPaymentProcessorCertificateFingerprint() { + return paymentProcessorCertificateFingerprint; + } + + @JsonProperty("created_by") + public Optional getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApplePayMerchantCertificates && equalTo((ApplePayMerchantCertificates) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApplePayMerchantCertificates other) { + return id.equals(other.id) + && tenantId.equals(other.tenantId) + && domain.equals(other.domain) + && merchantCertificateExpirationDate.equals(other.merchantCertificateExpirationDate) + && merchantCertificateFingerprint.equals(other.merchantCertificateFingerprint) + && paymentProcessorCertificateExpirationDate.equals(other.paymentProcessorCertificateExpirationDate) + && paymentProcessorCertificateFingerprint.equals(other.paymentProcessorCertificateFingerprint) + && createdBy.equals(other.createdBy) + && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.tenantId, + this.domain, + this.merchantCertificateExpirationDate, + this.merchantCertificateFingerprint, + this.paymentProcessorCertificateExpirationDate, + this.paymentProcessorCertificateFingerprint, + this.createdBy, + this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional tenantId = Optional.empty(); + + private Optional domain = Optional.empty(); + + private Optional merchantCertificateExpirationDate = Optional.empty(); + + private Optional merchantCertificateFingerprint = Optional.empty(); + + private Optional paymentProcessorCertificateExpirationDate = Optional.empty(); + + private Optional paymentProcessorCertificateFingerprint = Optional.empty(); + + private Optional createdBy = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ApplePayMerchantCertificates other) { + id(other.getId()); + tenantId(other.getTenantId()); + domain(other.getDomain()); + merchantCertificateExpirationDate(other.getMerchantCertificateExpirationDate()); + merchantCertificateFingerprint(other.getMerchantCertificateFingerprint()); + paymentProcessorCertificateExpirationDate(other.getPaymentProcessorCertificateExpirationDate()); + paymentProcessorCertificateFingerprint(other.getPaymentProcessorCertificateFingerprint()); + createdBy(other.getCreatedBy()); + createdAt(other.getCreatedAt()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) + public Builder tenantId(Optional tenantId) { + this.tenantId = tenantId; + return this; + } + + public Builder tenantId(String tenantId) { + this.tenantId = Optional.ofNullable(tenantId); + return this; + } + + @JsonSetter(value = "domain", nulls = Nulls.SKIP) + public Builder domain(Optional domain) { + this.domain = domain; + return this; + } + + public Builder domain(String domain) { + this.domain = Optional.ofNullable(domain); + return this; + } + + @JsonSetter(value = "merchant_certificate_expiration_date", nulls = Nulls.SKIP) + public Builder merchantCertificateExpirationDate(Optional merchantCertificateExpirationDate) { + this.merchantCertificateExpirationDate = merchantCertificateExpirationDate; + return this; + } + + public Builder merchantCertificateExpirationDate(OffsetDateTime merchantCertificateExpirationDate) { + this.merchantCertificateExpirationDate = Optional.ofNullable(merchantCertificateExpirationDate); + return this; + } + + @JsonSetter(value = "merchant_certificate_fingerprint", nulls = Nulls.SKIP) + public Builder merchantCertificateFingerprint(Optional merchantCertificateFingerprint) { + this.merchantCertificateFingerprint = merchantCertificateFingerprint; + return this; + } + + public Builder merchantCertificateFingerprint(String merchantCertificateFingerprint) { + this.merchantCertificateFingerprint = Optional.ofNullable(merchantCertificateFingerprint); + return this; + } + + @JsonSetter(value = "payment_processor_certificate_expiration_date", nulls = Nulls.SKIP) + public Builder paymentProcessorCertificateExpirationDate( + Optional paymentProcessorCertificateExpirationDate) { + this.paymentProcessorCertificateExpirationDate = paymentProcessorCertificateExpirationDate; + return this; + } + + public Builder paymentProcessorCertificateExpirationDate( + OffsetDateTime paymentProcessorCertificateExpirationDate) { + this.paymentProcessorCertificateExpirationDate = + Optional.ofNullable(paymentProcessorCertificateExpirationDate); + return this; + } + + @JsonSetter(value = "payment_processor_certificate_fingerprint", nulls = Nulls.SKIP) + public Builder paymentProcessorCertificateFingerprint(Optional paymentProcessorCertificateFingerprint) { + this.paymentProcessorCertificateFingerprint = paymentProcessorCertificateFingerprint; + return this; + } + + public Builder paymentProcessorCertificateFingerprint(String paymentProcessorCertificateFingerprint) { + this.paymentProcessorCertificateFingerprint = Optional.ofNullable(paymentProcessorCertificateFingerprint); + return this; + } + + @JsonSetter(value = "created_by", nulls = Nulls.SKIP) + public Builder createdBy(Optional createdBy) { + this.createdBy = createdBy; + return this; + } + + public Builder createdBy(String createdBy) { + this.createdBy = Optional.ofNullable(createdBy); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + public ApplePayMerchantCertificates build() { + return new ApplePayMerchantCertificates( + id, + tenantId, + domain, + merchantCertificateExpirationDate, + merchantCertificateFingerprint, + paymentProcessorCertificateExpirationDate, + paymentProcessorCertificateFingerprint, + createdBy, + createdAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/types/GooglePayMerchant.java b/src/main/java/com/basistheory/types/GooglePayMerchant.java new file mode 100644 index 0000000..cc69e3b --- /dev/null +++ b/src/main/java/com/basistheory/types/GooglePayMerchant.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.types; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GooglePayMerchant.Builder.class) +public final class GooglePayMerchant { + private final Optional id; + + private final Optional tenantId; + + private final Optional merchantIdentifier; + + private final Optional createdBy; + + private final Optional createdAt; + + private final Map additionalProperties; + + private GooglePayMerchant( + Optional id, + Optional tenantId, + Optional merchantIdentifier, + Optional createdBy, + Optional createdAt, + Map additionalProperties) { + this.id = id; + this.tenantId = tenantId; + this.merchantIdentifier = merchantIdentifier; + this.createdBy = createdBy; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("tenant_id") + public Optional getTenantId() { + return tenantId; + } + + @JsonProperty("merchant_identifier") + public Optional getMerchantIdentifier() { + return merchantIdentifier; + } + + @JsonProperty("created_by") + public Optional getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GooglePayMerchant && equalTo((GooglePayMerchant) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GooglePayMerchant other) { + return id.equals(other.id) + && tenantId.equals(other.tenantId) + && merchantIdentifier.equals(other.merchantIdentifier) + && createdBy.equals(other.createdBy) + && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.tenantId, this.merchantIdentifier, this.createdBy, this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional tenantId = Optional.empty(); + + private Optional merchantIdentifier = Optional.empty(); + + private Optional createdBy = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GooglePayMerchant other) { + id(other.getId()); + tenantId(other.getTenantId()); + merchantIdentifier(other.getMerchantIdentifier()); + createdBy(other.getCreatedBy()); + createdAt(other.getCreatedAt()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) + public Builder tenantId(Optional tenantId) { + this.tenantId = tenantId; + return this; + } + + public Builder tenantId(String tenantId) { + this.tenantId = Optional.ofNullable(tenantId); + return this; + } + + @JsonSetter(value = "merchant_identifier", nulls = Nulls.SKIP) + public Builder merchantIdentifier(Optional merchantIdentifier) { + this.merchantIdentifier = merchantIdentifier; + return this; + } + + public Builder merchantIdentifier(String merchantIdentifier) { + this.merchantIdentifier = Optional.ofNullable(merchantIdentifier); + return this; + } + + @JsonSetter(value = "created_by", nulls = Nulls.SKIP) + public Builder createdBy(Optional createdBy) { + this.createdBy = createdBy; + return this; + } + + public Builder createdBy(String createdBy) { + this.createdBy = Optional.ofNullable(createdBy); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + public GooglePayMerchant build() { + return new GooglePayMerchant(id, tenantId, merchantIdentifier, createdBy, createdAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/types/GooglePayMerchantCertificates.java b/src/main/java/com/basistheory/types/GooglePayMerchantCertificates.java new file mode 100644 index 0000000..2281c64 --- /dev/null +++ b/src/main/java/com/basistheory/types/GooglePayMerchantCertificates.java @@ -0,0 +1,231 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.types; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GooglePayMerchantCertificates.Builder.class) +public final class GooglePayMerchantCertificates { + private final Optional id; + + private final Optional tenantId; + + private final Optional merchantCertificateExpirationDate; + + private final Optional merchantCertificateFingerprint; + + private final Optional createdBy; + + private final Optional createdAt; + + private final Map additionalProperties; + + private GooglePayMerchantCertificates( + Optional id, + Optional tenantId, + Optional merchantCertificateExpirationDate, + Optional merchantCertificateFingerprint, + Optional createdBy, + Optional createdAt, + Map additionalProperties) { + this.id = id; + this.tenantId = tenantId; + this.merchantCertificateExpirationDate = merchantCertificateExpirationDate; + this.merchantCertificateFingerprint = merchantCertificateFingerprint; + this.createdBy = createdBy; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("tenant_id") + public Optional getTenantId() { + return tenantId; + } + + @JsonProperty("merchant_certificate_expiration_date") + public Optional getMerchantCertificateExpirationDate() { + return merchantCertificateExpirationDate; + } + + @JsonProperty("merchant_certificate_fingerprint") + public Optional getMerchantCertificateFingerprint() { + return merchantCertificateFingerprint; + } + + @JsonProperty("created_by") + public Optional getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GooglePayMerchantCertificates && equalTo((GooglePayMerchantCertificates) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GooglePayMerchantCertificates other) { + return id.equals(other.id) + && tenantId.equals(other.tenantId) + && merchantCertificateExpirationDate.equals(other.merchantCertificateExpirationDate) + && merchantCertificateFingerprint.equals(other.merchantCertificateFingerprint) + && createdBy.equals(other.createdBy) + && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.tenantId, + this.merchantCertificateExpirationDate, + this.merchantCertificateFingerprint, + this.createdBy, + this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional tenantId = Optional.empty(); + + private Optional merchantCertificateExpirationDate = Optional.empty(); + + private Optional merchantCertificateFingerprint = Optional.empty(); + + private Optional createdBy = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GooglePayMerchantCertificates other) { + id(other.getId()); + tenantId(other.getTenantId()); + merchantCertificateExpirationDate(other.getMerchantCertificateExpirationDate()); + merchantCertificateFingerprint(other.getMerchantCertificateFingerprint()); + createdBy(other.getCreatedBy()); + createdAt(other.getCreatedAt()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) + public Builder tenantId(Optional tenantId) { + this.tenantId = tenantId; + return this; + } + + public Builder tenantId(String tenantId) { + this.tenantId = Optional.ofNullable(tenantId); + return this; + } + + @JsonSetter(value = "merchant_certificate_expiration_date", nulls = Nulls.SKIP) + public Builder merchantCertificateExpirationDate(Optional merchantCertificateExpirationDate) { + this.merchantCertificateExpirationDate = merchantCertificateExpirationDate; + return this; + } + + public Builder merchantCertificateExpirationDate(OffsetDateTime merchantCertificateExpirationDate) { + this.merchantCertificateExpirationDate = Optional.ofNullable(merchantCertificateExpirationDate); + return this; + } + + @JsonSetter(value = "merchant_certificate_fingerprint", nulls = Nulls.SKIP) + public Builder merchantCertificateFingerprint(Optional merchantCertificateFingerprint) { + this.merchantCertificateFingerprint = merchantCertificateFingerprint; + return this; + } + + public Builder merchantCertificateFingerprint(String merchantCertificateFingerprint) { + this.merchantCertificateFingerprint = Optional.ofNullable(merchantCertificateFingerprint); + return this; + } + + @JsonSetter(value = "created_by", nulls = Nulls.SKIP) + public Builder createdBy(Optional createdBy) { + this.createdBy = createdBy; + return this; + } + + public Builder createdBy(String createdBy) { + this.createdBy = Optional.ofNullable(createdBy); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + public GooglePayMerchantCertificates build() { + return new GooglePayMerchantCertificates( + id, + tenantId, + merchantCertificateExpirationDate, + merchantCertificateFingerprint, + createdBy, + createdAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/types/ProxyTransformOptions.java b/src/main/java/com/basistheory/types/ProxyTransformOptions.java index 8be3a3a..0245fdd 100644 --- a/src/main/java/com/basistheory/types/ProxyTransformOptions.java +++ b/src/main/java/com/basistheory/types/ProxyTransformOptions.java @@ -32,6 +32,8 @@ public final class ProxyTransformOptions { private final Optional>> dependencies; + private final Optional warmConcurrency; + private final Map additionalProperties; private ProxyTransformOptions( @@ -41,6 +43,7 @@ private ProxyTransformOptions( Optional location, Optional runtime, Optional>> dependencies, + Optional warmConcurrency, Map additionalProperties) { this.token = token; this.identifier = identifier; @@ -48,6 +51,7 @@ private ProxyTransformOptions( this.location = location; this.runtime = runtime; this.dependencies = dependencies; + this.warmConcurrency = warmConcurrency; this.additionalProperties = additionalProperties; } @@ -81,6 +85,11 @@ public Optional>> getDependencies() { return dependencies; } + @JsonProperty("warm_concurrency") + public Optional getWarmConcurrency() { + return warmConcurrency; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -98,12 +107,20 @@ private boolean equalTo(ProxyTransformOptions other) { && value.equals(other.value) && location.equals(other.location) && runtime.equals(other.runtime) - && dependencies.equals(other.dependencies); + && dependencies.equals(other.dependencies) + && warmConcurrency.equals(other.warmConcurrency); } @java.lang.Override public int hashCode() { - return Objects.hash(this.token, this.identifier, this.value, this.location, this.runtime, this.dependencies); + return Objects.hash( + this.token, + this.identifier, + this.value, + this.location, + this.runtime, + this.dependencies, + this.warmConcurrency); } @java.lang.Override @@ -129,6 +146,8 @@ public static final class Builder { private Optional>> dependencies = Optional.empty(); + private Optional warmConcurrency = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -141,6 +160,7 @@ public Builder from(ProxyTransformOptions other) { location(other.getLocation()); runtime(other.getRuntime()); dependencies(other.getDependencies()); + warmConcurrency(other.getWarmConcurrency()); return this; } @@ -210,9 +230,20 @@ public Builder dependencies(Map> dependencies) { return this; } + @JsonSetter(value = "warm_concurrency", nulls = Nulls.SKIP) + public Builder warmConcurrency(Optional warmConcurrency) { + this.warmConcurrency = warmConcurrency; + return this; + } + + public Builder warmConcurrency(Integer warmConcurrency) { + this.warmConcurrency = Optional.ofNullable(warmConcurrency); + return this; + } + public ProxyTransformOptions build() { return new ProxyTransformOptions( - token, identifier, value, location, runtime, dependencies, additionalProperties); + token, identifier, value, location, runtime, dependencies, warmConcurrency, additionalProperties); } } } diff --git a/src/main/java/com/basistheory/types/RuntimeOptions.java b/src/main/java/com/basistheory/types/RuntimeOptions.java index dcbfa60..eb78294 100644 --- a/src/main/java/com/basistheory/types/RuntimeOptions.java +++ b/src/main/java/com/basistheory/types/RuntimeOptions.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,11 +23,20 @@ public final class RuntimeOptions { private final Optional>> dependencies; + private final Optional warmConcurrency; + + private final Optional> permissions; + private final Map additionalProperties; private RuntimeOptions( - Optional>> dependencies, Map additionalProperties) { + Optional>> dependencies, + Optional warmConcurrency, + Optional> permissions, + Map additionalProperties) { this.dependencies = dependencies; + this.warmConcurrency = warmConcurrency; + this.permissions = permissions; this.additionalProperties = additionalProperties; } @@ -35,6 +45,16 @@ public Optional>> getDependencies() { return dependencies; } + @JsonProperty("warm_concurrency") + public Optional getWarmConcurrency() { + return warmConcurrency; + } + + @JsonProperty("permissions") + public Optional> getPermissions() { + return permissions; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -47,12 +67,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(RuntimeOptions other) { - return dependencies.equals(other.dependencies); + return dependencies.equals(other.dependencies) + && warmConcurrency.equals(other.warmConcurrency) + && permissions.equals(other.permissions); } @java.lang.Override public int hashCode() { - return Objects.hash(this.dependencies); + return Objects.hash(this.dependencies, this.warmConcurrency, this.permissions); } @java.lang.Override @@ -68,6 +90,10 @@ public static Builder builder() { public static final class Builder { private Optional>> dependencies = Optional.empty(); + private Optional warmConcurrency = Optional.empty(); + + private Optional> permissions = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -75,6 +101,8 @@ private Builder() {} public Builder from(RuntimeOptions other) { dependencies(other.getDependencies()); + warmConcurrency(other.getWarmConcurrency()); + permissions(other.getPermissions()); return this; } @@ -89,8 +117,30 @@ public Builder dependencies(Map> dependencies) { return this; } + @JsonSetter(value = "warm_concurrency", nulls = Nulls.SKIP) + public Builder warmConcurrency(Optional warmConcurrency) { + this.warmConcurrency = warmConcurrency; + return this; + } + + public Builder warmConcurrency(Integer warmConcurrency) { + this.warmConcurrency = Optional.ofNullable(warmConcurrency); + return this; + } + + @JsonSetter(value = "permissions", nulls = Nulls.SKIP) + public Builder permissions(Optional> permissions) { + this.permissions = permissions; + return this; + } + + public Builder permissions(List permissions) { + this.permissions = Optional.ofNullable(permissions); + return this; + } + public RuntimeOptions build() { - return new RuntimeOptions(dependencies, additionalProperties); + return new RuntimeOptions(dependencies, warmConcurrency, permissions, additionalProperties); } } } diff --git a/src/main/java/com/basistheory/types/ThreeDsBrandingOptions.java b/src/main/java/com/basistheory/types/ThreeDsBrandingOptions.java new file mode 100644 index 0000000..069915d --- /dev/null +++ b/src/main/java/com/basistheory/types/ThreeDsBrandingOptions.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basistheory.types; + +import com.basistheory.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ThreeDsBrandingOptions.Builder.class) +public final class ThreeDsBrandingOptions { + private final Optional hideBasisTheoryBranding; + + private final Map additionalProperties; + + private ThreeDsBrandingOptions( + Optional hideBasisTheoryBranding, Map additionalProperties) { + this.hideBasisTheoryBranding = hideBasisTheoryBranding; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("hide_basis_theory_branding") + public Optional getHideBasisTheoryBranding() { + return hideBasisTheoryBranding; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ThreeDsBrandingOptions && equalTo((ThreeDsBrandingOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ThreeDsBrandingOptions other) { + return hideBasisTheoryBranding.equals(other.hideBasisTheoryBranding); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.hideBasisTheoryBranding); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional hideBasisTheoryBranding = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ThreeDsBrandingOptions other) { + hideBasisTheoryBranding(other.getHideBasisTheoryBranding()); + return this; + } + + @JsonSetter(value = "hide_basis_theory_branding", nulls = Nulls.SKIP) + public Builder hideBasisTheoryBranding(Optional hideBasisTheoryBranding) { + this.hideBasisTheoryBranding = hideBasisTheoryBranding; + return this; + } + + public Builder hideBasisTheoryBranding(Boolean hideBasisTheoryBranding) { + this.hideBasisTheoryBranding = Optional.ofNullable(hideBasisTheoryBranding); + return this; + } + + public ThreeDsBrandingOptions build() { + return new ThreeDsBrandingOptions(hideBasisTheoryBranding, additionalProperties); + } + } +} diff --git a/src/main/java/com/basistheory/types/ThreeDsCallbackUrls.java b/src/main/java/com/basistheory/types/ThreeDsCallbackUrls.java index 655c709..914ee75 100644 --- a/src/main/java/com/basistheory/types/ThreeDsCallbackUrls.java +++ b/src/main/java/com/basistheory/types/ThreeDsCallbackUrls.java @@ -24,12 +24,18 @@ public final class ThreeDsCallbackUrls { private final Optional failure; + private final Optional branding; + private final Map additionalProperties; private ThreeDsCallbackUrls( - Optional success, Optional failure, Map additionalProperties) { + Optional success, + Optional failure, + Optional branding, + Map additionalProperties) { this.success = success; this.failure = failure; + this.branding = branding; this.additionalProperties = additionalProperties; } @@ -43,6 +49,11 @@ public Optional getFailure() { return failure; } + @JsonProperty("branding") + public Optional getBranding() { + return branding; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -55,12 +66,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ThreeDsCallbackUrls other) { - return success.equals(other.success) && failure.equals(other.failure); + return success.equals(other.success) && failure.equals(other.failure) && branding.equals(other.branding); } @java.lang.Override public int hashCode() { - return Objects.hash(this.success, this.failure); + return Objects.hash(this.success, this.failure, this.branding); } @java.lang.Override @@ -78,6 +89,8 @@ public static final class Builder { private Optional failure = Optional.empty(); + private Optional branding = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -86,6 +99,7 @@ private Builder() {} public Builder from(ThreeDsCallbackUrls other) { success(other.getSuccess()); failure(other.getFailure()); + branding(other.getBranding()); return this; } @@ -111,8 +125,19 @@ public Builder failure(String failure) { return this; } + @JsonSetter(value = "branding", nulls = Nulls.SKIP) + public Builder branding(Optional branding) { + this.branding = branding; + return this; + } + + public Builder branding(ThreeDsBrandingOptions branding) { + this.branding = Optional.ofNullable(branding); + return this; + } + public ThreeDsCallbackUrls build() { - return new ThreeDsCallbackUrls(success, failure, additionalProperties); + return new ThreeDsCallbackUrls(success, failure, branding, additionalProperties); } } }