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 15, 2024
1 parent c1c3fc9 commit 2358b6c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public final class BasisTheoryApiClientBuilder {

private String apiKey = System.getenv("BT-API-KEY");

private String correlationId = null;

private Environment environment = Environment.DEFAULT;

/**
Expand All @@ -22,6 +24,14 @@ public BasisTheoryApiClientBuilder apiKey(String apiKey) {
return this;
}

/**
* Sets correlationId
*/
public BasisTheoryApiClientBuilder correlationId(String correlationId) {
this.correlationId = correlationId;
return this;
}

public BasisTheoryApiClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
Expand All @@ -37,6 +47,9 @@ public BasisTheoryApiClient build() {
throw new RuntimeException("Please provide apiKey or set the BT-API-KEY environment variable.");
}
this.clientOptionsBuilder.addHeader("BT-API-KEY", this.apiKey);
if (correlationId != null) {
this.clientOptionsBuilder.addHeader("BT-TRACE-ID", this.correlationId);
}
clientOptionsBuilder.environment(this.environment);
return new BasisTheoryApiClient(clientOptionsBuilder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@
public final class IdempotentRequestOptions {
private final String apiKey;

private final String correlationId;

private final String idempotencyKey;

private final Optional<Integer> timeout;

private final TimeUnit timeoutTimeUnit;

private IdempotentRequestOptions(
String apiKey, String idempotencyKey, Optional<Integer> timeout, TimeUnit timeoutTimeUnit) {
String apiKey,
String correlationId,
String idempotencyKey,
Optional<Integer> timeout,
TimeUnit timeoutTimeUnit) {
this.apiKey = apiKey;
this.correlationId = correlationId;
this.idempotencyKey = idempotencyKey;
this.timeout = timeout;
this.timeoutTimeUnit = timeoutTimeUnit;
Expand All @@ -38,6 +45,9 @@ public Map<String, String> getHeaders() {
if (this.apiKey != null) {
headers.put("BT-API-KEY", this.apiKey);
}
if (this.correlationId != null) {
headers.put("BT-TRACE-ID", this.correlationId);
}
if (this.idempotencyKey != null) {
headers.put("BT-IDEMPOTENCY-KEY", this.idempotencyKey);
}
Expand All @@ -51,6 +61,8 @@ public static Builder builder() {
public static final class Builder {
private String apiKey = null;

private String correlationId = null;

private String idempotencyKey = null;

private Optional<Integer> timeout = Optional.empty();
Expand All @@ -62,6 +74,11 @@ public Builder apiKey(String apiKey) {
return this;
}

public Builder correlationId(String correlationId) {
this.correlationId = correlationId;
return this;
}

public Builder idempotencyKey(String idempotencyKey) {
this.idempotencyKey = idempotencyKey;
return this;
Expand All @@ -79,7 +96,7 @@ public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) {
}

public IdempotentRequestOptions build() {
return new IdempotentRequestOptions(apiKey, idempotencyKey, timeout, timeoutTimeUnit);
return new IdempotentRequestOptions(apiKey, correlationId, idempotencyKey, timeout, timeoutTimeUnit);
}
}
}
17 changes: 15 additions & 2 deletions src/main/java/com/basis/theory/api/core/RequestOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
public final class RequestOptions {
private final String apiKey;

private final String correlationId;

private final Optional<Integer> timeout;

private final TimeUnit timeoutTimeUnit;

private RequestOptions(String apiKey, Optional<Integer> timeout, TimeUnit timeoutTimeUnit) {
private RequestOptions(String apiKey, String correlationId, Optional<Integer> timeout, TimeUnit timeoutTimeUnit) {
this.apiKey = apiKey;
this.correlationId = correlationId;
this.timeout = timeout;
this.timeoutTimeUnit = timeoutTimeUnit;
}
Expand All @@ -34,6 +37,9 @@ public Map<String, String> getHeaders() {
if (this.apiKey != null) {
headers.put("BT-API-KEY", this.apiKey);
}
if (this.correlationId != null) {
headers.put("BT-TRACE-ID", this.correlationId);
}
return headers;
}

Expand All @@ -44,6 +50,8 @@ public static Builder builder() {
public static final class Builder {
private String apiKey = null;

private String correlationId = null;

private Optional<Integer> timeout = Optional.empty();

private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS;
Expand All @@ -53,6 +61,11 @@ public Builder apiKey(String apiKey) {
return this;
}

public Builder correlationId(String correlationId) {
this.correlationId = correlationId;
return this;
}

public Builder timeout(Integer timeout) {
this.timeout = Optional.of(timeout);
return this;
Expand All @@ -65,7 +78,7 @@ public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) {
}

public RequestOptions build() {
return new RequestOptions(apiKey, timeout, timeoutTimeUnit);
return new RequestOptions(apiKey, correlationId, timeout, timeoutTimeUnit);
}
}
}

0 comments on commit 2358b6c

Please sign in to comment.