Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Nov 20, 2024
1 parent e3650db commit 855b875
Show file tree
Hide file tree
Showing 7 changed files with 807 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/basis/theory/api/BasisTheoryApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.basis.theory.api.resources.sessions.SessionsClient;
import com.basis.theory.api.resources.tenants.TenantsClient;
import com.basis.theory.api.resources.threeds.ThreedsClient;
import com.basis.theory.api.resources.tokenintents.TokenIntentsClient;
import com.basis.theory.api.resources.tokens.TokensClient;
import com.basis.theory.api.resources.webhooks.WebhooksClient;
import java.util.function.Supplier;
Expand Down Expand Up @@ -46,6 +47,8 @@ public class BasisTheoryApiClient {

protected final Supplier<SessionsClient> sessionsClient;

protected final Supplier<TokenIntentsClient> tokenIntentsClient;

protected final Supplier<WebhooksClient> webhooksClient;

protected final Supplier<TenantsClient> tenantsClient;
Expand All @@ -65,6 +68,7 @@ public BasisTheoryApiClient(ClientOptions clientOptions) {
this.reactorsClient = Suppliers.memoize(() -> new ReactorsClient(clientOptions));
this.rolesClient = Suppliers.memoize(() -> new RolesClient(clientOptions));
this.sessionsClient = Suppliers.memoize(() -> new SessionsClient(clientOptions));
this.tokenIntentsClient = Suppliers.memoize(() -> new TokenIntentsClient(clientOptions));
this.webhooksClient = Suppliers.memoize(() -> new WebhooksClient(clientOptions));
this.tenantsClient = Suppliers.memoize(() -> new TenantsClient(clientOptions));
this.threedsClient = Suppliers.memoize(() -> new ThreedsClient(clientOptions));
Expand Down Expand Up @@ -114,6 +118,10 @@ public SessionsClient sessions() {
return this.sessionsClient.get();
}

public TokenIntentsClient tokenIntents() {
return this.tokenIntentsClient.get();
}

public WebhooksClient webhooks() {
return this.webhooksClient.get();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.basis.theory.api.resources.tokenintents;

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.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.tokenintents.requests.CreateTokenIntentRequest;
import com.basis.theory.api.types.CreateTokenIntentResponse;
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 okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

public class TokenIntentsClient {
protected final ClientOptions clientOptions;

public TokenIntentsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}

public CreateTokenIntentResponse create(CreateTokenIntentRequest request) {
return create(request, null);
}

public CreateTokenIntentResponse create(CreateTokenIntentRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("token-intents")
.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(), CreateTokenIntentResponse.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 void delete(String id) {
delete(id, null);
}

public void delete(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("token-intents")
.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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.basis.theory.api.resources.tokenintents.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.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;

@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = CreateTokenIntentRequest.Builder.class)
public final class CreateTokenIntentRequest {
private final String type;

private final Object data;

private final Map<String, Object> additionalProperties;

private CreateTokenIntentRequest(String type, Object data, Map<String, Object> additionalProperties) {
this.type = type;
this.data = data;
this.additionalProperties = additionalProperties;
}

@JsonProperty("type")
public String getType() {
return type;
}

@JsonProperty("data")
public Object getData() {
return data;
}

@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof CreateTokenIntentRequest && equalTo((CreateTokenIntentRequest) other);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(CreateTokenIntentRequest other) {
return type.equals(other.type) && data.equals(other.data);
}

@java.lang.Override
public int hashCode() {
return Objects.hash(this.type, this.data);
}

@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}

public static TypeStage builder() {
return new Builder();
}

public interface TypeStage {
DataStage type(@NotNull String type);

Builder from(CreateTokenIntentRequest other);
}

public interface DataStage {
_FinalStage data(Object data);
}

public interface _FinalStage {
CreateTokenIntentRequest build();
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements TypeStage, DataStage, _FinalStage {
private String type;

private Object data;

@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();

private Builder() {}

@java.lang.Override
public Builder from(CreateTokenIntentRequest other) {
type(other.getType());
data(other.getData());
return this;
}

@java.lang.Override
@JsonSetter("type")
public DataStage type(@NotNull String type) {
this.type = Objects.requireNonNull(type, "type must not be null");
return this;
}

@java.lang.Override
@JsonSetter("data")
public _FinalStage data(Object data) {
this.data = data;
return this;
}

@java.lang.Override
public CreateTokenIntentRequest build() {
return new CreateTokenIntentRequest(type, data, additionalProperties);
}
}
}
Loading

0 comments on commit 855b875

Please sign in to comment.