From a85aea345c3b181365581977e1963b8c226ee28f Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:50:40 -0600 Subject: [PATCH] fix: Update to latest specs (#24) --- .../theory/api/BasisTheoryApiClient.java | 22 +- .../applications/ApplicationsClient.java | 54 --- .../enrichments/EnrichmentsClient.java | 9 +- .../permissions/PermissionsClient.java | 12 +- ...quest.java => PermissionsListRequest.java} | 16 +- .../ReactorformulasClient.java | 328 ------------------ .../requests/ReactorformulasListRequest.java | 169 --------- .../resources/reactors/ReactorsClient.java | 9 +- .../invitations/InvitationsClient.java | 49 +++ .../tenants/members/MembersClient.java | 12 +- ...etRequest.java => MembersListRequest.java} | 16 +- .../api/resources/threeds/ThreedsClient.java | 82 ----- .../threeds/sessions/SessionsClient.java | 64 ++++ .../AuthenticateThreeDsSessionRequest.java | 64 ++++ .../requests/CreateThreeDsSessionRequest.java | 2 +- .../api/resources/tokens/TokensClient.java | 8 +- .../resources/webhooks/WebhooksClient.java | 8 - .../webhooks/signingkey/SigningKeyClient.java | 65 ---- .../theory/api/types/AsyncReactResponse.java | 95 +++++ .../api/types/BankVerificationResponse.java | 95 +++++ .../CreateReactorFormulaRequest.java | 4 +- .../UpdateReactorFormulaRequest.java | 4 +- 22 files changed, 419 insertions(+), 768 deletions(-) rename src/main/java/com/basis/theory/api/resources/permissions/requests/{PermissionsGetRequest.java => PermissionsListRequest.java} (81%) delete mode 100644 src/main/java/com/basis/theory/api/resources/reactorformulas/ReactorformulasClient.java delete mode 100644 src/main/java/com/basis/theory/api/resources/reactorformulas/requests/ReactorformulasListRequest.java rename src/main/java/com/basis/theory/api/resources/tenants/members/requests/{MembersGetRequest.java => MembersListRequest.java} (90%) rename src/main/java/com/basis/theory/api/resources/threeds/{ => sessions}/requests/CreateThreeDsSessionRequest.java (99%) delete mode 100644 src/main/java/com/basis/theory/api/resources/webhooks/signingkey/SigningKeyClient.java create mode 100644 src/main/java/com/basis/theory/api/types/AsyncReactResponse.java create mode 100644 src/main/java/com/basis/theory/api/types/BankVerificationResponse.java rename src/main/java/com/basis/theory/api/{resources/reactorformulas/requests => types}/CreateReactorFormulaRequest.java (98%) rename src/main/java/com/basis/theory/api/{resources/reactorformulas/requests => types}/UpdateReactorFormulaRequest.java (97%) diff --git a/src/main/java/com/basis/theory/api/BasisTheoryApiClient.java b/src/main/java/com/basis/theory/api/BasisTheoryApiClient.java index b252f33..0087a36 100644 --- a/src/main/java/com/basis/theory/api/BasisTheoryApiClient.java +++ b/src/main/java/com/basis/theory/api/BasisTheoryApiClient.java @@ -12,7 +12,6 @@ import com.basis.theory.api.resources.logs.LogsClient; import com.basis.theory.api.resources.permissions.PermissionsClient; import com.basis.theory.api.resources.proxies.ProxiesClient; -import com.basis.theory.api.resources.reactorformulas.ReactorformulasClient; import com.basis.theory.api.resources.reactors.ReactorsClient; import com.basis.theory.api.resources.roles.RolesClient; import com.basis.theory.api.resources.sessions.SessionsClient; @@ -41,20 +40,18 @@ public class BasisTheoryApiClient { protected final Supplier proxiesClient; - protected final Supplier reactorformulasClient; - protected final Supplier reactorsClient; protected final Supplier rolesClient; protected final Supplier sessionsClient; - protected final Supplier threedsClient; - protected final Supplier webhooksClient; protected final Supplier tenantsClient; + protected final Supplier threedsClient; + public BasisTheoryApiClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.applicationsClient = Suppliers.memoize(() -> new ApplicationsClient(clientOptions)); @@ -65,13 +62,12 @@ public BasisTheoryApiClient(ClientOptions clientOptions) { this.logsClient = Suppliers.memoize(() -> new LogsClient(clientOptions)); this.permissionsClient = Suppliers.memoize(() -> new PermissionsClient(clientOptions)); this.proxiesClient = Suppliers.memoize(() -> new ProxiesClient(clientOptions)); - this.reactorformulasClient = Suppliers.memoize(() -> new ReactorformulasClient(clientOptions)); this.reactorsClient = Suppliers.memoize(() -> new ReactorsClient(clientOptions)); this.rolesClient = Suppliers.memoize(() -> new RolesClient(clientOptions)); this.sessionsClient = Suppliers.memoize(() -> new SessionsClient(clientOptions)); - this.threedsClient = Suppliers.memoize(() -> new ThreedsClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new WebhooksClient(clientOptions)); this.tenantsClient = Suppliers.memoize(() -> new TenantsClient(clientOptions)); + this.threedsClient = Suppliers.memoize(() -> new ThreedsClient(clientOptions)); } public ApplicationsClient applications() { @@ -106,10 +102,6 @@ public ProxiesClient proxies() { return this.proxiesClient.get(); } - public ReactorformulasClient reactorformulas() { - return this.reactorformulasClient.get(); - } - public ReactorsClient reactors() { return this.reactorsClient.get(); } @@ -122,10 +114,6 @@ public SessionsClient sessions() { return this.sessionsClient.get(); } - public ThreedsClient threeds() { - return this.threedsClient.get(); - } - public WebhooksClient webhooks() { return this.webhooksClient.get(); } @@ -134,6 +122,10 @@ public TenantsClient tenants() { return this.tenantsClient.get(); } + public ThreedsClient threeds() { + return this.threedsClient.get(); + } + public static BasisTheoryApiClientBuilder builder() { return new BasisTheoryApiClientBuilder(); } diff --git a/src/main/java/com/basis/theory/api/resources/applications/ApplicationsClient.java b/src/main/java/com/basis/theory/api/resources/applications/ApplicationsClient.java index 13ab235..3bd9d5f 100644 --- a/src/main/java/com/basis/theory/api/resources/applications/ApplicationsClient.java +++ b/src/main/java/com/basis/theory/api/resources/applications/ApplicationsClient.java @@ -15,7 +15,6 @@ import com.basis.theory.api.errors.ForbiddenError; import com.basis.theory.api.errors.NotFoundError; import com.basis.theory.api.errors.UnauthorizedError; -import com.basis.theory.api.errors.UnprocessableEntityError; import com.basis.theory.api.resources.applications.requests.ApplicationsListRequest; import com.basis.theory.api.resources.applications.requests.CreateApplicationRequest; import com.basis.theory.api.resources.applications.requests.UpdateApplicationRequest; @@ -372,57 +371,4 @@ public Application getByKey(RequestOptions requestOptions) { throw new BasisTheoryException("Network error executing HTTP request", e); } } - - public Application regenerateKey(String id) { - return regenerateKey(id, null); - } - - public Application regenerateKey(String id, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("applications") - .addPathSegment(id) - .addPathSegments("regenerate") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Application.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 404: - throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 422: - throw new UnprocessableEntityError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } } diff --git a/src/main/java/com/basis/theory/api/resources/enrichments/EnrichmentsClient.java b/src/main/java/com/basis/theory/api/resources/enrichments/EnrichmentsClient.java index 9594f29..6fa514f 100644 --- a/src/main/java/com/basis/theory/api/resources/enrichments/EnrichmentsClient.java +++ b/src/main/java/com/basis/theory/api/resources/enrichments/EnrichmentsClient.java @@ -13,6 +13,7 @@ import com.basis.theory.api.errors.ForbiddenError; import com.basis.theory.api.errors.UnauthorizedError; import com.basis.theory.api.resources.enrichments.requests.BankVerificationRequest; +import com.basis.theory.api.types.BankVerificationResponse; import com.basis.theory.api.types.ProblemDetails; import com.basis.theory.api.types.ValidationProblemDetails; import com.fasterxml.jackson.core.JsonProcessingException; @@ -32,11 +33,11 @@ public EnrichmentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public void bankaccountverify(BankVerificationRequest request) { - bankaccountverify(request, null); + public BankVerificationResponse bankAccountVerify(BankVerificationRequest request) { + return bankAccountVerify(request, null); } - public void bankaccountverify(BankVerificationRequest request, RequestOptions requestOptions) { + public BankVerificationResponse bankAccountVerify(BankVerificationRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("enrichments/bank-account-verify") @@ -61,7 +62,7 @@ public void bankaccountverify(BankVerificationRequest request, RequestOptions re try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - return; + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankVerificationResponse.class); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/basis/theory/api/resources/permissions/PermissionsClient.java b/src/main/java/com/basis/theory/api/resources/permissions/PermissionsClient.java index 451757f..afa686f 100644 --- a/src/main/java/com/basis/theory/api/resources/permissions/PermissionsClient.java +++ b/src/main/java/com/basis/theory/api/resources/permissions/PermissionsClient.java @@ -11,7 +11,7 @@ import com.basis.theory.api.errors.BadRequestError; import com.basis.theory.api.errors.ForbiddenError; import com.basis.theory.api.errors.UnauthorizedError; -import com.basis.theory.api.resources.permissions.requests.PermissionsGetRequest; +import com.basis.theory.api.resources.permissions.requests.PermissionsListRequest; import com.basis.theory.api.types.Permission; import com.basis.theory.api.types.ProblemDetails; import com.basis.theory.api.types.ValidationProblemDetails; @@ -33,15 +33,15 @@ public PermissionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public List get() { - return get(PermissionsGetRequest.builder().build()); + public List list() { + return list(PermissionsListRequest.builder().build()); } - public List get(PermissionsGetRequest request) { - return get(request, null); + public List list(PermissionsListRequest request) { + return list(request, null); } - public List get(PermissionsGetRequest request, RequestOptions requestOptions) { + public List list(PermissionsListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("permissions"); diff --git a/src/main/java/com/basis/theory/api/resources/permissions/requests/PermissionsGetRequest.java b/src/main/java/com/basis/theory/api/resources/permissions/requests/PermissionsListRequest.java similarity index 81% rename from src/main/java/com/basis/theory/api/resources/permissions/requests/PermissionsGetRequest.java rename to src/main/java/com/basis/theory/api/resources/permissions/requests/PermissionsListRequest.java index 1f4d111..88733ea 100644 --- a/src/main/java/com/basis/theory/api/resources/permissions/requests/PermissionsGetRequest.java +++ b/src/main/java/com/basis/theory/api/resources/permissions/requests/PermissionsListRequest.java @@ -18,13 +18,13 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = PermissionsGetRequest.Builder.class) -public final class PermissionsGetRequest { +@JsonDeserialize(builder = PermissionsListRequest.Builder.class) +public final class PermissionsListRequest { private final Optional applicationType; private final Map additionalProperties; - private PermissionsGetRequest(Optional applicationType, Map additionalProperties) { + private PermissionsListRequest(Optional applicationType, Map additionalProperties) { this.applicationType = applicationType; this.additionalProperties = additionalProperties; } @@ -37,7 +37,7 @@ public Optional getApplicationType() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof PermissionsGetRequest && equalTo((PermissionsGetRequest) other); + return other instanceof PermissionsListRequest && equalTo((PermissionsListRequest) other); } @JsonAnyGetter @@ -45,7 +45,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(PermissionsGetRequest other) { + private boolean equalTo(PermissionsListRequest other) { return applicationType.equals(other.applicationType); } @@ -72,7 +72,7 @@ public static final class Builder { private Builder() {} - public Builder from(PermissionsGetRequest other) { + public Builder from(PermissionsListRequest other) { applicationType(other.getApplicationType()); return this; } @@ -88,8 +88,8 @@ public Builder applicationType(String applicationType) { return this; } - public PermissionsGetRequest build() { - return new PermissionsGetRequest(applicationType, additionalProperties); + public PermissionsListRequest build() { + return new PermissionsListRequest(applicationType, additionalProperties); } } } diff --git a/src/main/java/com/basis/theory/api/resources/reactorformulas/ReactorformulasClient.java b/src/main/java/com/basis/theory/api/resources/reactorformulas/ReactorformulasClient.java deleted file mode 100644 index 973fea7..0000000 --- a/src/main/java/com/basis/theory/api/resources/reactorformulas/ReactorformulasClient.java +++ /dev/null @@ -1,328 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.basis.theory.api.resources.reactorformulas; - -import com.basis.theory.api.core.BasisTheoryApiApiException; -import com.basis.theory.api.core.BasisTheoryException; -import com.basis.theory.api.core.ClientOptions; -import com.basis.theory.api.core.IdempotentRequestOptions; -import com.basis.theory.api.core.MediaTypes; -import com.basis.theory.api.core.ObjectMappers; -import com.basis.theory.api.core.RequestOptions; -import com.basis.theory.api.core.pagination.SyncPagingIterable; -import com.basis.theory.api.errors.BadRequestError; -import com.basis.theory.api.errors.ForbiddenError; -import com.basis.theory.api.errors.NotFoundError; -import com.basis.theory.api.errors.UnauthorizedError; -import com.basis.theory.api.resources.reactorformulas.requests.CreateReactorFormulaRequest; -import com.basis.theory.api.resources.reactorformulas.requests.ReactorformulasListRequest; -import com.basis.theory.api.resources.reactorformulas.requests.UpdateReactorFormulaRequest; -import com.basis.theory.api.types.ProblemDetails; -import com.basis.theory.api.types.ReactorFormula; -import com.basis.theory.api.types.ReactorFormulaPaginatedList; -import com.basis.theory.api.types.ValidationProblemDetails; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class ReactorformulasClient { - protected final ClientOptions clientOptions; - - public ReactorformulasClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public SyncPagingIterable list() { - return list(ReactorformulasListRequest.builder().build()); - } - - public SyncPagingIterable list(ReactorformulasListRequest request) { - return list(request, null); - } - - public SyncPagingIterable list(ReactorformulasListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("reactor-formulas"); - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getPage().isPresent()) { - httpUrl.addQueryParameter("page", request.getPage().get().toString()); - } - if (request.getStart().isPresent()) { - httpUrl.addQueryParameter("start", request.getStart().get()); - } - if (request.getSize().isPresent()) { - httpUrl.addQueryParameter("size", request.getSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.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()) { - ReactorFormulaPaginatedList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReactorFormulaPaginatedList.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); - ReactorformulasListRequest nextRequest = ReactorformulasListRequest.builder() - .from(request) - .page(newPageNumber) - .build(); - List result = parsedResponse.getData().orElse(Collections.emptyList()); - return new SyncPagingIterable<>(true, result, () -> list(nextRequest, requestOptions)); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, ValidationProblemDetails.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } - - public ReactorFormula create(CreateReactorFormulaRequest request) { - return create(request, null); - } - - public ReactorFormula create(CreateReactorFormulaRequest request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("reactor-formulas") - .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") - .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReactorFormula.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, ValidationProblemDetails.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } - - public ReactorFormula get(String id) { - return get(id, null); - } - - public ReactorFormula get(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("reactor-formulas") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReactorFormula.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 404: - throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } - - public ReactorFormula update(String id, UpdateReactorFormulaRequest request) { - return update(id, request, null); - } - - public ReactorFormula update( - String id, UpdateReactorFormulaRequest request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("reactor-formulas") - .addPathSegment(id) - .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("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReactorFormula.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, ValidationProblemDetails.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 404: - throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } - - public void delete(String id) { - delete(id, null); - } - - public void delete(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("reactor-formulas") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 404: - throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/ReactorformulasListRequest.java b/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/ReactorformulasListRequest.java deleted file mode 100644 index 30f70ff..0000000 --- a/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/ReactorformulasListRequest.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.basis.theory.api.resources.reactorformulas.requests; - -import com.basis.theory.api.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 = ReactorformulasListRequest.Builder.class) -public final class ReactorformulasListRequest { - private final Optional name; - - private final Optional page; - - private final Optional start; - - private final Optional size; - - private final Map additionalProperties; - - private ReactorformulasListRequest( - Optional name, - Optional page, - Optional start, - Optional size, - Map additionalProperties) { - this.name = name; - this.page = page; - this.start = start; - this.size = size; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("name") - public Optional getName() { - return name; - } - - @JsonProperty("page") - public Optional getPage() { - return page; - } - - @JsonProperty("start") - public Optional getStart() { - return start; - } - - @JsonProperty("size") - public Optional getSize() { - return size; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ReactorformulasListRequest && equalTo((ReactorformulasListRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ReactorformulasListRequest other) { - return name.equals(other.name) - && page.equals(other.page) - && start.equals(other.start) - && size.equals(other.size); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.name, this.page, this.start, this.size); - } - - @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 name = Optional.empty(); - - private Optional page = Optional.empty(); - - private Optional start = Optional.empty(); - - private Optional size = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ReactorformulasListRequest other) { - name(other.getName()); - page(other.getPage()); - start(other.getStart()); - size(other.getSize()); - return this; - } - - @JsonSetter(value = "name", nulls = Nulls.SKIP) - public Builder name(Optional name) { - this.name = name; - return this; - } - - public Builder name(String name) { - this.name = Optional.ofNullable(name); - return this; - } - - @JsonSetter(value = "page", nulls = Nulls.SKIP) - public Builder page(Optional page) { - this.page = page; - return this; - } - - public Builder page(Integer page) { - this.page = Optional.ofNullable(page); - return this; - } - - @JsonSetter(value = "start", nulls = Nulls.SKIP) - public Builder start(Optional start) { - this.start = start; - return this; - } - - public Builder start(String start) { - this.start = Optional.ofNullable(start); - return this; - } - - @JsonSetter(value = "size", nulls = Nulls.SKIP) - public Builder size(Optional size) { - this.size = size; - return this; - } - - public Builder size(Integer size) { - this.size = Optional.ofNullable(size); - return this; - } - - public ReactorformulasListRequest build() { - return new ReactorformulasListRequest(name, page, start, size, additionalProperties); - } - } -} diff --git a/src/main/java/com/basis/theory/api/resources/reactors/ReactorsClient.java b/src/main/java/com/basis/theory/api/resources/reactors/ReactorsClient.java index 5ddde20..a3fbdcc 100644 --- a/src/main/java/com/basis/theory/api/resources/reactors/ReactorsClient.java +++ b/src/main/java/com/basis/theory/api/resources/reactors/ReactorsClient.java @@ -24,6 +24,7 @@ import com.basis.theory.api.resources.reactors.requests.ReactorsListRequest; import com.basis.theory.api.resources.reactors.requests.UpdateReactorRequest; import com.basis.theory.api.resources.reactors.results.ResultsClient; +import com.basis.theory.api.types.AsyncReactResponse; import com.basis.theory.api.types.ProblemDetails; import com.basis.theory.api.types.ReactResponse; import com.basis.theory.api.types.Reactor; @@ -468,15 +469,15 @@ public ReactResponse react(String id, ReactRequest request, RequestOptions reque } } - public ReactResponse reactAsync(String id) { + public AsyncReactResponse reactAsync(String id) { return reactAsync(id, ReactRequestAsync.builder().build()); } - public ReactResponse reactAsync(String id, ReactRequestAsync request) { + public AsyncReactResponse reactAsync(String id, ReactRequestAsync request) { return reactAsync(id, request, null); } - public ReactResponse reactAsync(String id, ReactRequestAsync request, RequestOptions requestOptions) { + public AsyncReactResponse reactAsync(String id, ReactRequestAsync request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("reactors") @@ -503,7 +504,7 @@ public ReactResponse reactAsync(String id, ReactRequestAsync request, RequestOpt try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReactResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncReactResponse.class); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/basis/theory/api/resources/tenants/invitations/InvitationsClient.java b/src/main/java/com/basis/theory/api/resources/tenants/invitations/InvitationsClient.java index 4bf3ce5..3ded149 100644 --- a/src/main/java/com/basis/theory/api/resources/tenants/invitations/InvitationsClient.java +++ b/src/main/java/com/basis/theory/api/resources/tenants/invitations/InvitationsClient.java @@ -218,6 +218,55 @@ public TenantInvitationResponse resend(String invitationId, IdempotentRequestOpt } } + public TenantInvitationResponse get(String invitationId) { + return get(invitationId, null); + } + + public TenantInvitationResponse get(String invitationId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tenants/self/invitations") + .addPathSegment(invitationId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TenantInvitationResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + public void delete(String invitationId) { delete(invitationId, null); } diff --git a/src/main/java/com/basis/theory/api/resources/tenants/members/MembersClient.java b/src/main/java/com/basis/theory/api/resources/tenants/members/MembersClient.java index 9452a6c..c18bf00 100644 --- a/src/main/java/com/basis/theory/api/resources/tenants/members/MembersClient.java +++ b/src/main/java/com/basis/theory/api/resources/tenants/members/MembersClient.java @@ -14,7 +14,7 @@ import com.basis.theory.api.errors.NotFoundError; import com.basis.theory.api.errors.UnauthorizedError; import com.basis.theory.api.errors.UnprocessableEntityError; -import com.basis.theory.api.resources.tenants.members.requests.MembersGetRequest; +import com.basis.theory.api.resources.tenants.members.requests.MembersListRequest; import com.basis.theory.api.resources.tenants.members.requests.UpdateTenantMemberRequest; import com.basis.theory.api.types.ProblemDetails; import com.basis.theory.api.types.TenantMemberResponse; @@ -36,15 +36,15 @@ public MembersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public TenantMemberResponsePaginatedList get() { - return get(MembersGetRequest.builder().build()); + public TenantMemberResponsePaginatedList list() { + return list(MembersListRequest.builder().build()); } - public TenantMemberResponsePaginatedList get(MembersGetRequest request) { - return get(request, null); + public TenantMemberResponsePaginatedList list(MembersListRequest request) { + return list(request, null); } - public TenantMemberResponsePaginatedList get(MembersGetRequest request, RequestOptions requestOptions) { + public TenantMemberResponsePaginatedList list(MembersListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tenants/self/members"); diff --git a/src/main/java/com/basis/theory/api/resources/tenants/members/requests/MembersGetRequest.java b/src/main/java/com/basis/theory/api/resources/tenants/members/requests/MembersListRequest.java similarity index 90% rename from src/main/java/com/basis/theory/api/resources/tenants/members/requests/MembersGetRequest.java rename to src/main/java/com/basis/theory/api/resources/tenants/members/requests/MembersListRequest.java index b3c578e..0cddc32 100644 --- a/src/main/java/com/basis/theory/api/resources/tenants/members/requests/MembersGetRequest.java +++ b/src/main/java/com/basis/theory/api/resources/tenants/members/requests/MembersListRequest.java @@ -18,8 +18,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = MembersGetRequest.Builder.class) -public final class MembersGetRequest { +@JsonDeserialize(builder = MembersListRequest.Builder.class) +public final class MembersListRequest { private final Optional userId; private final Optional page; @@ -30,7 +30,7 @@ public final class MembersGetRequest { private final Map additionalProperties; - private MembersGetRequest( + private MembersListRequest( Optional userId, Optional page, Optional start, @@ -66,7 +66,7 @@ public Optional getSize() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof MembersGetRequest && equalTo((MembersGetRequest) other); + return other instanceof MembersListRequest && equalTo((MembersListRequest) other); } @JsonAnyGetter @@ -74,7 +74,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(MembersGetRequest other) { + private boolean equalTo(MembersListRequest other) { return userId.equals(other.userId) && page.equals(other.page) && start.equals(other.start) @@ -110,7 +110,7 @@ public static final class Builder { private Builder() {} - public Builder from(MembersGetRequest other) { + public Builder from(MembersListRequest other) { userId(other.getUserId()); page(other.getPage()); start(other.getStart()); @@ -162,8 +162,8 @@ public Builder size(Integer size) { return this; } - public MembersGetRequest build() { - return new MembersGetRequest(userId, page, start, size, additionalProperties); + public MembersListRequest build() { + return new MembersListRequest(userId, page, start, size, additionalProperties); } } } diff --git a/src/main/java/com/basis/theory/api/resources/threeds/ThreedsClient.java b/src/main/java/com/basis/theory/api/resources/threeds/ThreedsClient.java index 63e08f6..77bc050 100644 --- a/src/main/java/com/basis/theory/api/resources/threeds/ThreedsClient.java +++ b/src/main/java/com/basis/theory/api/resources/threeds/ThreedsClient.java @@ -3,31 +3,10 @@ */ package com.basis.theory.api.resources.threeds; -import com.basis.theory.api.core.BasisTheoryApiApiException; -import com.basis.theory.api.core.BasisTheoryException; import com.basis.theory.api.core.ClientOptions; -import com.basis.theory.api.core.MediaTypes; -import com.basis.theory.api.core.ObjectMappers; -import com.basis.theory.api.core.RequestOptions; import com.basis.theory.api.core.Suppliers; -import com.basis.theory.api.errors.BadRequestError; -import com.basis.theory.api.errors.ForbiddenError; -import com.basis.theory.api.errors.UnauthorizedError; -import com.basis.theory.api.resources.threeds.requests.CreateThreeDsSessionRequest; import com.basis.theory.api.resources.threeds.sessions.SessionsClient; -import com.basis.theory.api.types.CreateThreeDsSessionResponse; -import com.basis.theory.api.types.ProblemDetails; -import com.basis.theory.api.types.ValidationProblemDetails; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; import java.util.function.Supplier; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ThreedsClient { protected final ClientOptions clientOptions; @@ -39,67 +18,6 @@ public ThreedsClient(ClientOptions clientOptions) { this.sessionsClient = Suppliers.memoize(() -> new SessionsClient(clientOptions)); } - public CreateThreeDsSessionResponse createsession() { - return createsession(CreateThreeDsSessionRequest.builder().build()); - } - - public CreateThreeDsSessionResponse createsession(CreateThreeDsSessionRequest request) { - return createsession(request, null); - } - - public CreateThreeDsSessionResponse createsession( - CreateThreeDsSessionRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("3ds/sessions") - .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") - .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateThreeDsSessionResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, ValidationProblemDetails.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); - } - } 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)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } - public SessionsClient sessions() { return this.sessionsClient.get(); } diff --git a/src/main/java/com/basis/theory/api/resources/threeds/sessions/SessionsClient.java b/src/main/java/com/basis/theory/api/resources/threeds/sessions/SessionsClient.java index ed088f2..bea1649 100644 --- a/src/main/java/com/basis/theory/api/resources/threeds/sessions/SessionsClient.java +++ b/src/main/java/com/basis/theory/api/resources/threeds/sessions/SessionsClient.java @@ -10,13 +10,17 @@ import com.basis.theory.api.core.MediaTypes; import com.basis.theory.api.core.ObjectMappers; import com.basis.theory.api.core.RequestOptions; +import com.basis.theory.api.errors.BadRequestError; import com.basis.theory.api.errors.ForbiddenError; import com.basis.theory.api.errors.NotFoundError; import com.basis.theory.api.errors.UnauthorizedError; import com.basis.theory.api.resources.threeds.sessions.requests.AuthenticateThreeDsSessionRequest; +import com.basis.theory.api.resources.threeds.sessions.requests.CreateThreeDsSessionRequest; +import com.basis.theory.api.types.CreateThreeDsSessionResponse; import com.basis.theory.api.types.ProblemDetails; import com.basis.theory.api.types.ThreeDsAuthentication; import com.basis.theory.api.types.ThreeDsSession; +import com.basis.theory.api.types.ValidationProblemDetails; import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import okhttp3.Headers; @@ -34,6 +38,66 @@ public SessionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } + public CreateThreeDsSessionResponse create() { + return create(CreateThreeDsSessionRequest.builder().build()); + } + + public CreateThreeDsSessionResponse create(CreateThreeDsSessionRequest request) { + return create(request, null); + } + + public CreateThreeDsSessionResponse create(CreateThreeDsSessionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("3ds/sessions") + .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") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateThreeDsSessionResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, ValidationProblemDetails.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProblemDetails.class)); + } + } 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)); + } catch (IOException e) { + throw new BasisTheoryException("Network error executing HTTP request", e); + } + } + public ThreeDsAuthentication authenticate(String sessionId, AuthenticateThreeDsSessionRequest request) { return authenticate(sessionId, request, null); } diff --git a/src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/AuthenticateThreeDsSessionRequest.java b/src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/AuthenticateThreeDsSessionRequest.java index 16acf27..b5d40b2 100644 --- a/src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/AuthenticateThreeDsSessionRequest.java +++ b/src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/AuthenticateThreeDsSessionRequest.java @@ -33,6 +33,10 @@ public final class AuthenticateThreeDsSessionRequest { private final Optional challengePreference; + private final Optional requestDecoupledChallenge; + + private final Optional decoupledChallengeMaxTime; + private final Optional purchaseInfo; private final Optional merchantInfo; @@ -51,6 +55,8 @@ private AuthenticateThreeDsSessionRequest( String authenticationCategory, String authenticationType, Optional challengePreference, + Optional requestDecoupledChallenge, + Optional decoupledChallengeMaxTime, Optional purchaseInfo, Optional merchantInfo, ThreeDsRequestorInfo requestorInfo, @@ -61,6 +67,8 @@ private AuthenticateThreeDsSessionRequest( this.authenticationCategory = authenticationCategory; this.authenticationType = authenticationType; this.challengePreference = challengePreference; + this.requestDecoupledChallenge = requestDecoupledChallenge; + this.decoupledChallengeMaxTime = decoupledChallengeMaxTime; this.purchaseInfo = purchaseInfo; this.merchantInfo = merchantInfo; this.requestorInfo = requestorInfo; @@ -85,6 +93,16 @@ public Optional getChallengePreference() { return challengePreference; } + @JsonProperty("request_decoupled_challenge") + public Optional getRequestDecoupledChallenge() { + return requestDecoupledChallenge; + } + + @JsonProperty("decoupled_challenge_max_time") + public Optional getDecoupledChallengeMaxTime() { + return decoupledChallengeMaxTime; + } + @JsonProperty("purchase_info") public Optional getPurchaseInfo() { return purchaseInfo; @@ -130,6 +148,8 @@ private boolean equalTo(AuthenticateThreeDsSessionRequest other) { return authenticationCategory.equals(other.authenticationCategory) && authenticationType.equals(other.authenticationType) && challengePreference.equals(other.challengePreference) + && requestDecoupledChallenge.equals(other.requestDecoupledChallenge) + && decoupledChallengeMaxTime.equals(other.decoupledChallengeMaxTime) && purchaseInfo.equals(other.purchaseInfo) && merchantInfo.equals(other.merchantInfo) && requestorInfo.equals(other.requestorInfo) @@ -144,6 +164,8 @@ public int hashCode() { this.authenticationCategory, this.authenticationType, this.challengePreference, + this.requestDecoupledChallenge, + this.decoupledChallengeMaxTime, this.purchaseInfo, this.merchantInfo, this.requestorInfo, @@ -182,6 +204,14 @@ public interface _FinalStage { _FinalStage challengePreference(String challengePreference); + _FinalStage requestDecoupledChallenge(Optional requestDecoupledChallenge); + + _FinalStage requestDecoupledChallenge(Boolean requestDecoupledChallenge); + + _FinalStage decoupledChallengeMaxTime(Optional decoupledChallengeMaxTime); + + _FinalStage decoupledChallengeMaxTime(Integer decoupledChallengeMaxTime); + _FinalStage purchaseInfo(Optional purchaseInfo); _FinalStage purchaseInfo(ThreeDsPurchaseInfo purchaseInfo); @@ -222,6 +252,10 @@ public static final class Builder private Optional purchaseInfo = Optional.empty(); + private Optional decoupledChallengeMaxTime = Optional.empty(); + + private Optional requestDecoupledChallenge = Optional.empty(); + private Optional challengePreference = Optional.empty(); @JsonAnySetter @@ -234,6 +268,8 @@ public Builder from(AuthenticateThreeDsSessionRequest other) { authenticationCategory(other.getAuthenticationCategory()); authenticationType(other.getAuthenticationType()); challengePreference(other.getChallengePreference()); + requestDecoupledChallenge(other.getRequestDecoupledChallenge()); + decoupledChallengeMaxTime(other.getDecoupledChallengeMaxTime()); purchaseInfo(other.getPurchaseInfo()); merchantInfo(other.getMerchantInfo()); requestorInfo(other.getRequestorInfo()); @@ -330,6 +366,32 @@ public _FinalStage purchaseInfo(Optional purchaseInfo) { return this; } + @java.lang.Override + public _FinalStage decoupledChallengeMaxTime(Integer decoupledChallengeMaxTime) { + this.decoupledChallengeMaxTime = Optional.ofNullable(decoupledChallengeMaxTime); + return this; + } + + @java.lang.Override + @JsonSetter(value = "decoupled_challenge_max_time", nulls = Nulls.SKIP) + public _FinalStage decoupledChallengeMaxTime(Optional decoupledChallengeMaxTime) { + this.decoupledChallengeMaxTime = decoupledChallengeMaxTime; + return this; + } + + @java.lang.Override + public _FinalStage requestDecoupledChallenge(Boolean requestDecoupledChallenge) { + this.requestDecoupledChallenge = Optional.ofNullable(requestDecoupledChallenge); + return this; + } + + @java.lang.Override + @JsonSetter(value = "request_decoupled_challenge", nulls = Nulls.SKIP) + public _FinalStage requestDecoupledChallenge(Optional requestDecoupledChallenge) { + this.requestDecoupledChallenge = requestDecoupledChallenge; + return this; + } + @java.lang.Override public _FinalStage challengePreference(String challengePreference) { this.challengePreference = Optional.ofNullable(challengePreference); @@ -349,6 +411,8 @@ public AuthenticateThreeDsSessionRequest build() { authenticationCategory, authenticationType, challengePreference, + requestDecoupledChallenge, + decoupledChallengeMaxTime, purchaseInfo, merchantInfo, requestorInfo, diff --git a/src/main/java/com/basis/theory/api/resources/threeds/requests/CreateThreeDsSessionRequest.java b/src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/CreateThreeDsSessionRequest.java similarity index 99% rename from src/main/java/com/basis/theory/api/resources/threeds/requests/CreateThreeDsSessionRequest.java rename to src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/CreateThreeDsSessionRequest.java index 28a4098..492a237 100644 --- a/src/main/java/com/basis/theory/api/resources/threeds/requests/CreateThreeDsSessionRequest.java +++ b/src/main/java/com/basis/theory/api/resources/threeds/sessions/requests/CreateThreeDsSessionRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.basis.theory.api.resources.threeds.requests; +package com.basis.theory.api.resources.threeds.sessions.requests; import com.basis.theory.api.core.ObjectMappers; import com.basis.theory.api.types.ThreeDsDeviceInfo; diff --git a/src/main/java/com/basis/theory/api/resources/tokens/TokensClient.java b/src/main/java/com/basis/theory/api/resources/tokens/TokensClient.java index 8d3dca8..2a804e6 100644 --- a/src/main/java/com/basis/theory/api/resources/tokens/TokensClient.java +++ b/src/main/java/com/basis/theory/api/resources/tokens/TokensClient.java @@ -48,11 +48,11 @@ public TokensClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public void detokenize(Object request) { - detokenize(request, null); + public Object detokenize(Object request) { + return detokenize(request, null); } - public void detokenize(Object request, RequestOptions requestOptions) { + public Object detokenize(Object request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("detokenize") @@ -77,7 +77,7 @@ public void detokenize(Object request, RequestOptions requestOptions) { try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - return; + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/basis/theory/api/resources/webhooks/WebhooksClient.java b/src/main/java/com/basis/theory/api/resources/webhooks/WebhooksClient.java index 16ffecb..73868ba 100644 --- a/src/main/java/com/basis/theory/api/resources/webhooks/WebhooksClient.java +++ b/src/main/java/com/basis/theory/api/resources/webhooks/WebhooksClient.java @@ -19,7 +19,6 @@ import com.basis.theory.api.resources.webhooks.events.EventsClient; import com.basis.theory.api.resources.webhooks.requests.CreateWebhookRequest; import com.basis.theory.api.resources.webhooks.requests.UpdateWebhookRequest; -import com.basis.theory.api.resources.webhooks.signingkey.SigningKeyClient; import com.basis.theory.api.types.ProblemDetails; import com.basis.theory.api.types.ValidationProblemDetails; import com.basis.theory.api.types.Webhook; @@ -40,12 +39,9 @@ public class WebhooksClient { protected final Supplier eventsClient; - protected final Supplier signingKeyClient; - public WebhooksClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.eventsClient = Suppliers.memoize(() -> new EventsClient(clientOptions)); - this.signingKeyClient = Suppliers.memoize(() -> new SigningKeyClient(clientOptions)); } /** @@ -393,8 +389,4 @@ public Webhook create(CreateWebhookRequest request, RequestOptions requestOption public EventsClient events() { return this.eventsClient.get(); } - - public SigningKeyClient signingKey() { - return this.signingKeyClient.get(); - } } diff --git a/src/main/java/com/basis/theory/api/resources/webhooks/signingkey/SigningKeyClient.java b/src/main/java/com/basis/theory/api/resources/webhooks/signingkey/SigningKeyClient.java deleted file mode 100644 index 49df8be..0000000 --- a/src/main/java/com/basis/theory/api/resources/webhooks/signingkey/SigningKeyClient.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.basis.theory.api.resources.webhooks.signingkey; - -import com.basis.theory.api.core.BasisTheoryApiApiException; -import com.basis.theory.api.core.BasisTheoryException; -import com.basis.theory.api.core.ClientOptions; -import com.basis.theory.api.core.ObjectMappers; -import com.basis.theory.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class SigningKeyClient { - protected final ClientOptions clientOptions; - - public SigningKeyClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns the signing key - */ - public String get() { - return get(null); - } - - /** - * Returns the signing key - */ - public String get(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks/signing-key") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "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 responseBody.string(); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new BasisTheoryApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BasisTheoryException("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/basis/theory/api/types/AsyncReactResponse.java b/src/main/java/com/basis/theory/api/types/AsyncReactResponse.java new file mode 100644 index 0000000..9fc284b --- /dev/null +++ b/src/main/java/com/basis/theory/api/types/AsyncReactResponse.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basis.theory.api.types; + +import com.basis.theory.api.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 = AsyncReactResponse.Builder.class) +public final class AsyncReactResponse { + private final Optional asyncReactorRequestId; + + private final Map additionalProperties; + + private AsyncReactResponse(Optional asyncReactorRequestId, Map additionalProperties) { + this.asyncReactorRequestId = asyncReactorRequestId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("asyncReactorRequestId") + public Optional getAsyncReactorRequestId() { + return asyncReactorRequestId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AsyncReactResponse && equalTo((AsyncReactResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AsyncReactResponse other) { + return asyncReactorRequestId.equals(other.asyncReactorRequestId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.asyncReactorRequestId); + } + + @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 asyncReactorRequestId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AsyncReactResponse other) { + asyncReactorRequestId(other.getAsyncReactorRequestId()); + return this; + } + + @JsonSetter(value = "asyncReactorRequestId", nulls = Nulls.SKIP) + public Builder asyncReactorRequestId(Optional asyncReactorRequestId) { + this.asyncReactorRequestId = asyncReactorRequestId; + return this; + } + + public Builder asyncReactorRequestId(String asyncReactorRequestId) { + this.asyncReactorRequestId = Optional.ofNullable(asyncReactorRequestId); + return this; + } + + public AsyncReactResponse build() { + return new AsyncReactResponse(asyncReactorRequestId, additionalProperties); + } + } +} diff --git a/src/main/java/com/basis/theory/api/types/BankVerificationResponse.java b/src/main/java/com/basis/theory/api/types/BankVerificationResponse.java new file mode 100644 index 0000000..677abc2 --- /dev/null +++ b/src/main/java/com/basis/theory/api/types/BankVerificationResponse.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.basis.theory.api.types; + +import com.basis.theory.api.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 = BankVerificationResponse.Builder.class) +public final class BankVerificationResponse { + private final Optional status; + + private final Map additionalProperties; + + private BankVerificationResponse(Optional status, Map additionalProperties) { + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BankVerificationResponse && equalTo((BankVerificationResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BankVerificationResponse other) { + return status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status); + } + + @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 status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(BankVerificationResponse other) { + status(other.getStatus()); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + + public BankVerificationResponse build() { + return new BankVerificationResponse(status, additionalProperties); + } + } +} diff --git a/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/CreateReactorFormulaRequest.java b/src/main/java/com/basis/theory/api/types/CreateReactorFormulaRequest.java similarity index 98% rename from src/main/java/com/basis/theory/api/resources/reactorformulas/requests/CreateReactorFormulaRequest.java rename to src/main/java/com/basis/theory/api/types/CreateReactorFormulaRequest.java index 60f8b9a..5799197 100644 --- a/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/CreateReactorFormulaRequest.java +++ b/src/main/java/com/basis/theory/api/types/CreateReactorFormulaRequest.java @@ -1,11 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.basis.theory.api.resources.reactorformulas.requests; +package com.basis.theory.api.types; import com.basis.theory.api.core.ObjectMappers; -import com.basis.theory.api.types.ReactorFormulaConfiguration; -import com.basis.theory.api.types.ReactorFormulaRequestParameter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/UpdateReactorFormulaRequest.java b/src/main/java/com/basis/theory/api/types/UpdateReactorFormulaRequest.java similarity index 97% rename from src/main/java/com/basis/theory/api/resources/reactorformulas/requests/UpdateReactorFormulaRequest.java rename to src/main/java/com/basis/theory/api/types/UpdateReactorFormulaRequest.java index cedf369..fcf2366 100644 --- a/src/main/java/com/basis/theory/api/resources/reactorformulas/requests/UpdateReactorFormulaRequest.java +++ b/src/main/java/com/basis/theory/api/types/UpdateReactorFormulaRequest.java @@ -1,11 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.basis.theory.api.resources.reactorformulas.requests; +package com.basis.theory.api.types; import com.basis.theory.api.core.ObjectMappers; -import com.basis.theory.api.types.ReactorFormulaConfiguration; -import com.basis.theory.api.types.ReactorFormulaRequestParameter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;