Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌿 Fern Regeneration -- December 11, 2024 #28

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public void patch(String id, PatchProxyRequest request, IdempotentRequestOptions
.url(httpUrl)
.method("PATCH", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Content-Type", "application/merge-patch+json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public void patch(String id, PatchReactorRequest request, IdempotentRequestOptio
.url(httpUrl)
.method("PATCH", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Content-Type", "application/merge-patch+json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public TenantMemberResponse update(
.url(httpUrl)
.method("PUT", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Content-Type", "application/json-patch+json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down
35 changes: 26 additions & 9 deletions src/main/java/com/basistheory/resources/tokens/TokensClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,15 @@ public Token create(CreateTokenRequest request, IdempotentRequestOptions request
}
}

public TokenPaginatedList search() {
public SyncPagingIterable<Token> search() {
return search(SearchTokensRequest.builder().build());
}

public TokenPaginatedList search(SearchTokensRequest request) {
public SyncPagingIterable<Token> search(SearchTokensRequest request) {
return search(request, null);
}

public TokenPaginatedList search(SearchTokensRequest request, IdempotentRequestOptions requestOptions) {
public SyncPagingIterable<Token> search(SearchTokensRequest request, IdempotentRequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("tokens/search")
Expand All @@ -334,7 +334,15 @@ public TokenPaginatedList search(SearchTokensRequest request, IdempotentRequestO
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TokenPaginatedList.class);
TokenPaginatedList parsedResponse =
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TokenPaginatedList.class);
int newPageNumber = request.getPage().map(page -> page + 1).orElse(1);
SearchTokensRequest nextRequest = SearchTokensRequest.builder()
.from(request)
.page(newPageNumber)
.build();
List<Token> result = parsedResponse.getData().orElse(Collections.emptyList());
return new SyncPagingIterable<>(true, result, () -> search(nextRequest, requestOptions));
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
Expand Down Expand Up @@ -486,7 +494,7 @@ public Token update(String id, UpdateTokenRequest request, IdempotentRequestOpti
.url(httpUrl)
.method("PATCH", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Content-Type", "application/merge-patch+json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down Expand Up @@ -591,15 +599,15 @@ public SyncPagingIterable<Token> listV2(TokensListV2Request request, RequestOpti
}
}

public TokenCursorPaginatedList searchV2() {
public SyncPagingIterable<Token> searchV2() {
return searchV2(SearchTokensRequestV2.builder().build());
}

public TokenCursorPaginatedList searchV2(SearchTokensRequestV2 request) {
public SyncPagingIterable<Token> searchV2(SearchTokensRequestV2 request) {
return searchV2(request, null);
}

public TokenCursorPaginatedList searchV2(SearchTokensRequestV2 request, IdempotentRequestOptions requestOptions) {
public SyncPagingIterable<Token> searchV2(SearchTokensRequestV2 request, IdempotentRequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("v2/tokens/search")
Expand All @@ -624,7 +632,16 @@ public TokenCursorPaginatedList searchV2(SearchTokensRequestV2 request, Idempote
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TokenCursorPaginatedList.class);
TokenCursorPaginatedList parsedResponse =
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TokenCursorPaginatedList.class);
Optional<String> startingAfter = parsedResponse.getPagination().flatMap(CursorPagination::getNext);
SearchTokensRequestV2 nextRequest = SearchTokensRequestV2.builder()
.from(request)
.start(startingAfter)
.build();
List<Token> result = parsedResponse.getData().orElse(Collections.emptyList());
return new SyncPagingIterable<>(
startingAfter.isPresent(), result, () -> searchV2(nextRequest, requestOptions));
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
Expand Down
Loading