Skip to content

Commit

Permalink
fix: Update to latest specs (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] authored Nov 20, 2024
1 parent 733e12d commit a85aea3
Show file tree
Hide file tree
Showing 22 changed files with 419 additions and 768 deletions.
22 changes: 7 additions & 15 deletions src/main/java/com/basis/theory/api/BasisTheoryApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,20 +40,18 @@ public class BasisTheoryApiClient {

protected final Supplier<ProxiesClient> proxiesClient;

protected final Supplier<ReactorformulasClient> reactorformulasClient;

protected final Supplier<ReactorsClient> reactorsClient;

protected final Supplier<RolesClient> rolesClient;

protected final Supplier<SessionsClient> sessionsClient;

protected final Supplier<ThreedsClient> threedsClient;

protected final Supplier<WebhooksClient> webhooksClient;

protected final Supplier<TenantsClient> tenantsClient;

protected final Supplier<ThreedsClient> threedsClient;

public BasisTheoryApiClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.applicationsClient = Suppliers.memoize(() -> new ApplicationsClient(clientOptions));
Expand All @@ -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() {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,15 +33,15 @@ public PermissionsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}

public List<Permission> get() {
return get(PermissionsGetRequest.builder().build());
public List<Permission> list() {
return list(PermissionsListRequest.builder().build());
}

public List<Permission> get(PermissionsGetRequest request) {
return get(request, null);
public List<Permission> list(PermissionsListRequest request) {
return list(request, null);
}

public List<Permission> get(PermissionsGetRequest request, RequestOptions requestOptions) {
public List<Permission> list(PermissionsListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("permissions");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> applicationType;

private final Map<String, Object> additionalProperties;

private PermissionsGetRequest(Optional<String> applicationType, Map<String, Object> additionalProperties) {
private PermissionsListRequest(Optional<String> applicationType, Map<String, Object> additionalProperties) {
this.applicationType = applicationType;
this.additionalProperties = additionalProperties;
}
Expand All @@ -37,15 +37,15 @@ public Optional<String> 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
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(PermissionsGetRequest other) {
private boolean equalTo(PermissionsListRequest other) {
return applicationType.equals(other.applicationType);
}

Expand All @@ -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;
}
Expand All @@ -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);
}
}
}
Loading

0 comments on commit a85aea3

Please sign in to comment.