nextBackoff() {
+ retryNumber += 1;
+ if (retryNumber > maxNumRetries) {
+ return Optional.empty();
+ }
+
+ int upperBound = (int) Math.pow(2, retryNumber);
+ return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound)));
+ }
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/Stream.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/Stream.java
new file mode 100644
index 0000000..3781dcc
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/Stream.java
@@ -0,0 +1,272 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Scanner;
+
+/**
+ * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing
+ * objects of a given type from data streamed via a {@link Reader} using a specified delimiter.
+ *
+ * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a
+ * {@code Scanner} to block during iteration if the next object is not available.
+ * Iterable stream for parsing JSON and Server-Sent Events (SSE) data.
+ * Supports both newline-delimited JSON and SSE with optional stream termination.
+ *
+ * @param The type of objects in the stream.
+ */
+public final class Stream implements Iterable, Closeable {
+
+ private static final String NEWLINE = "\n";
+ private static final String DATA_PREFIX = "data:";
+
+ public enum StreamType {
+ JSON,
+ SSE
+ }
+
+ private final Class valueType;
+ private final Scanner scanner;
+ private final StreamType streamType;
+ private final String messageTerminator;
+ private final String streamTerminator;
+ private final Reader sseReader;
+ private boolean isClosed = false;
+
+ /**
+ * Constructs a new {@code Stream} with the specified value type, reader, and delimiter.
+ *
+ * @param valueType The class of the objects in the stream.
+ * @param reader The reader that provides the streamed data.
+ * @param delimiter The delimiter used to separate elements in the stream.
+ */
+ public Stream(Class valueType, Reader reader, String delimiter) {
+ this.valueType = valueType;
+ this.scanner = new Scanner(reader).useDelimiter(delimiter);
+ this.streamType = StreamType.JSON;
+ this.messageTerminator = delimiter;
+ this.streamTerminator = null;
+ this.sseReader = null;
+ }
+
+ private Stream(Class valueType, StreamType type, Reader reader, String terminator) {
+ this.valueType = valueType;
+ this.streamType = type;
+ if (type == StreamType.JSON) {
+ this.scanner = new Scanner(reader).useDelimiter(terminator);
+ this.messageTerminator = terminator;
+ this.streamTerminator = null;
+ this.sseReader = null;
+ } else {
+ this.scanner = null;
+ this.messageTerminator = NEWLINE;
+ this.streamTerminator = terminator;
+ this.sseReader = reader;
+ }
+ }
+
+ public static Stream fromJson(Class valueType, Reader reader, String delimiter) {
+ return new Stream<>(valueType, reader, delimiter);
+ }
+
+ public static Stream fromJson(Class valueType, Reader reader) {
+ return new Stream<>(valueType, reader, NEWLINE);
+ }
+
+ public static Stream fromSse(Class valueType, Reader sseReader) {
+ return new Stream<>(valueType, StreamType.SSE, sseReader, null);
+ }
+
+ public static Stream fromSse(Class valueType, Reader sseReader, String streamTerminator) {
+ return new Stream<>(valueType, StreamType.SSE, sseReader, streamTerminator);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (!isClosed) {
+ isClosed = true;
+ if (scanner != null) {
+ scanner.close();
+ }
+ if (sseReader != null) {
+ sseReader.close();
+ }
+ }
+ }
+
+ private boolean isStreamClosed() {
+ return isClosed;
+ }
+
+ /**
+ * Returns an iterator over the elements in this stream that blocks during iteration when the next object is
+ * not yet available.
+ *
+ * @return An iterator that can be used to traverse the elements in the stream.
+ */
+ @Override
+ public Iterator iterator() {
+ if (streamType == StreamType.SSE) {
+ return new SSEIterator();
+ } else {
+ return new JsonIterator();
+ }
+ }
+
+ private final class JsonIterator implements Iterator {
+
+ /**
+ * Returns {@code true} if there are more elements in the stream.
+ *
+ * Will block and wait for input if the stream has not ended and the next object is not yet available.
+ *
+ * @return {@code true} if there are more elements, {@code false} otherwise.
+ */
+ @Override
+ public boolean hasNext() {
+ if (isStreamClosed()) {
+ return false;
+ }
+ return scanner.hasNext();
+ }
+
+ /**
+ * Returns the next element in the stream.
+ *
+ * Will block and wait for input if the stream has not ended and the next object is not yet available.
+ *
+ * @return The next element in the stream.
+ * @throws NoSuchElementException If there are no more elements in the stream.
+ */
+ @Override
+ public T next() {
+ if (isStreamClosed()) {
+ throw new NoSuchElementException("Stream is closed");
+ }
+
+ if (!scanner.hasNext()) {
+ throw new NoSuchElementException();
+ } else {
+ try {
+ T parsedResponse =
+ ObjectMappers.JSON_MAPPER.readValue(scanner.next().trim(), valueType);
+ return parsedResponse;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private final class SSEIterator implements Iterator {
+ private Scanner sseScanner;
+ private T nextItem;
+ private boolean hasNextItem = false;
+ private boolean endOfStream = false;
+ private StringBuilder buffer = new StringBuilder();
+ private boolean prefixSeen = false;
+
+ private SSEIterator() {
+ if (sseReader != null && !isStreamClosed()) {
+ this.sseScanner = new Scanner(sseReader);
+ } else {
+ this.endOfStream = true;
+ }
+ }
+
+ @Override
+ public boolean hasNext() {
+ if (isStreamClosed() || endOfStream) {
+ return false;
+ }
+
+ if (hasNextItem) {
+ return true;
+ }
+
+ return readNextMessage();
+ }
+
+ @Override
+ public T next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException("No more elements in stream");
+ }
+
+ T result = nextItem;
+ nextItem = null;
+ hasNextItem = false;
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private boolean readNextMessage() {
+ if (sseScanner == null || isStreamClosed()) {
+ endOfStream = true;
+ return false;
+ }
+
+ try {
+ while (sseScanner.hasNextLine()) {
+ String chunk = sseScanner.nextLine();
+ buffer.append(chunk).append(NEWLINE);
+
+ int terminatorIndex;
+ while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) {
+ String line = buffer.substring(0, terminatorIndex + messageTerminator.length());
+ buffer.delete(0, terminatorIndex + messageTerminator.length());
+
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue;
+ }
+
+ if (!prefixSeen && line.startsWith(DATA_PREFIX)) {
+ prefixSeen = true;
+ line = line.substring(DATA_PREFIX.length()).trim();
+ } else if (!prefixSeen) {
+ continue;
+ }
+
+ if (streamTerminator != null && line.contains(streamTerminator)) {
+ endOfStream = true;
+ return false;
+ }
+
+ try {
+ nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType);
+ hasNextItem = true;
+ prefixSeen = false;
+ return true;
+ } catch (Exception parseEx) {
+ continue;
+ }
+ }
+ }
+
+ endOfStream = true;
+ return false;
+
+ } catch (Exception e) {
+ System.err.println("Failed to parse SSE stream: " + e.getMessage());
+ endOfStream = true;
+ return false;
+ }
+ }
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/Suppliers.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/Suppliers.java
new file mode 100644
index 0000000..b907552
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/Suppliers.java
@@ -0,0 +1,23 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core;
+
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Supplier;
+
+public final class Suppliers {
+ private Suppliers() {}
+
+ public static Supplier memoize(Supplier delegate) {
+ AtomicReference value = new AtomicReference<>();
+ return () -> {
+ T val = value.get();
+ if (val == null) {
+ val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur);
+ }
+ return val;
+ };
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/BasePage.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/BasePage.java
new file mode 100644
index 0000000..ca83fe4
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/BasePage.java
@@ -0,0 +1,24 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core.pagination;
+
+import java.util.List;
+
+public abstract class BasePage {
+ private final boolean hasNext;
+ private final List items;
+
+ public BasePage(boolean hasNext, List items) {
+ this.hasNext = hasNext;
+ this.items = items;
+ }
+
+ public boolean hasNext() {
+ return !items.isEmpty() && hasNext;
+ }
+
+ public List getItems() {
+ return items;
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/SyncPage.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/SyncPage.java
new file mode 100644
index 0000000..86fc5b7
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/SyncPage.java
@@ -0,0 +1,24 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core.pagination;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.function.Supplier;
+
+public class SyncPage extends BasePage {
+ protected final Supplier extends SyncPage> nextSupplier;
+
+ public SyncPage(boolean hasNext, List items, Supplier extends SyncPage> nextSupplier) {
+ super(hasNext, items);
+ this.nextSupplier = nextSupplier;
+ }
+
+ public SyncPage nextPage() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return nextSupplier.get();
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java
new file mode 100644
index 0000000..fd5fca3
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java
@@ -0,0 +1,61 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core.pagination;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+public class SyncPagingIterable extends SyncPage implements Iterable {
+
+ public SyncPagingIterable(boolean hasNext, List items, Supplier extends SyncPage> getNext) {
+ super(hasNext, items, getNext);
+ }
+
+ public SyncPagingIterable(boolean hasNext, Optional> items, Supplier extends SyncPage> getNext) {
+ super(hasNext, items.orElse(new ArrayList<>()), getNext);
+ }
+
+ public Stream streamItems() {
+ return StreamSupport.stream(this.spliterator(), false);
+ }
+
+ @Override
+ public Iterator iterator() {
+ return new Iterator() {
+ private Iterator itemsIterator = getItems().iterator();
+ private SyncPage currentPage = SyncPagingIterable.this;
+
+ @Override
+ public boolean hasNext() {
+ if (itemsIterator.hasNext()) {
+ return true;
+ }
+ if (currentPage.hasNext()) {
+ advancePage();
+ return itemsIterator.hasNext();
+ }
+ return false;
+ }
+
+ @Override
+ public T next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return itemsIterator.next();
+ }
+
+ private void advancePage() {
+ currentPage = currentPage.nextPage();
+ itemsIterator = currentPage.getItems().iterator();
+ }
+ };
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java
new file mode 100644
index 0000000..81f9441
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java
@@ -0,0 +1,78 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts;
+
+import com.pipedream.api.core.ClientOptions;
+import com.pipedream.api.core.RequestOptions;
+import com.pipedream.api.core.pagination.SyncPagingIterable;
+import com.pipedream.api.resources.accounts.requests.AccountsListRequest;
+import com.pipedream.api.resources.accounts.requests.AccountsRetrieveRequest;
+import com.pipedream.api.resources.accounts.requests.CreateAccountRequest;
+import com.pipedream.api.types.Account;
+
+public class AccountsClient {
+ protected final ClientOptions clientOptions;
+
+ private final RawAccountsClient rawClient;
+
+ public AccountsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ this.rawClient = new RawAccountsClient(clientOptions);
+ }
+
+ /**
+ * Get responses with HTTP metadata like headers
+ */
+ public RawAccountsClient withRawResponse() {
+ return this.rawClient;
+ }
+
+ public SyncPagingIterable list() {
+ return this.rawClient.list().body();
+ }
+
+ public SyncPagingIterable list(AccountsListRequest request) {
+ return this.rawClient.list(request).body();
+ }
+
+ public SyncPagingIterable list(AccountsListRequest request, RequestOptions requestOptions) {
+ return this.rawClient.list(request, requestOptions).body();
+ }
+
+ public Account create(CreateAccountRequest request) {
+ return this.rawClient.create(request).body();
+ }
+
+ public Account create(CreateAccountRequest request, RequestOptions requestOptions) {
+ return this.rawClient.create(request, requestOptions).body();
+ }
+
+ public Account retrieve(String accountId) {
+ return this.rawClient.retrieve(accountId).body();
+ }
+
+ public Account retrieve(String accountId, AccountsRetrieveRequest request) {
+ return this.rawClient.retrieve(accountId, request).body();
+ }
+
+ public Account retrieve(String accountId, AccountsRetrieveRequest request, RequestOptions requestOptions) {
+ return this.rawClient.retrieve(accountId, request, requestOptions).body();
+ }
+
+ public void delete(String accountId) {
+ this.rawClient.delete(accountId).body();
+ }
+
+ public void delete(String accountId, RequestOptions requestOptions) {
+ this.rawClient.delete(accountId, requestOptions).body();
+ }
+
+ public void deleteByApp(String appId) {
+ this.rawClient.deleteByApp(appId).body();
+ }
+
+ public void deleteByApp(String appId, RequestOptions requestOptions) {
+ this.rawClient.deleteByApp(appId, requestOptions).body();
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java
new file mode 100644
index 0000000..761a206
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java
@@ -0,0 +1,81 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts;
+
+import com.pipedream.api.core.ClientOptions;
+import com.pipedream.api.core.RequestOptions;
+import com.pipedream.api.core.pagination.SyncPagingIterable;
+import com.pipedream.api.resources.accounts.requests.AccountsListRequest;
+import com.pipedream.api.resources.accounts.requests.AccountsRetrieveRequest;
+import com.pipedream.api.resources.accounts.requests.CreateAccountRequest;
+import com.pipedream.api.types.Account;
+import java.util.concurrent.CompletableFuture;
+
+public class AsyncAccountsClient {
+ protected final ClientOptions clientOptions;
+
+ private final AsyncRawAccountsClient rawClient;
+
+ public AsyncAccountsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ this.rawClient = new AsyncRawAccountsClient(clientOptions);
+ }
+
+ /**
+ * Get responses with HTTP metadata like headers
+ */
+ public AsyncRawAccountsClient withRawResponse() {
+ return this.rawClient;
+ }
+
+ public CompletableFuture> list() {
+ return this.rawClient.list().thenApply(response -> response.body());
+ }
+
+ public CompletableFuture> list(AccountsListRequest request) {
+ return this.rawClient.list(request).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture> list(
+ AccountsListRequest request, RequestOptions requestOptions) {
+ return this.rawClient.list(request, requestOptions).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture create(CreateAccountRequest request) {
+ return this.rawClient.create(request).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture create(CreateAccountRequest request, RequestOptions requestOptions) {
+ return this.rawClient.create(request, requestOptions).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture retrieve(String accountId) {
+ return this.rawClient.retrieve(accountId).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture retrieve(String accountId, AccountsRetrieveRequest request) {
+ return this.rawClient.retrieve(accountId, request).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture retrieve(
+ String accountId, AccountsRetrieveRequest request, RequestOptions requestOptions) {
+ return this.rawClient.retrieve(accountId, request, requestOptions).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture delete(String accountId) {
+ return this.rawClient.delete(accountId).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture delete(String accountId, RequestOptions requestOptions) {
+ return this.rawClient.delete(accountId, requestOptions).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture deleteByApp(String appId) {
+ return this.rawClient.deleteByApp(appId).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture deleteByApp(String appId, RequestOptions requestOptions) {
+ return this.rawClient.deleteByApp(appId, requestOptions).thenApply(response -> response.body());
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
new file mode 100644
index 0000000..1c4a9bb
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
@@ -0,0 +1,391 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts;
+
+import com.pipedream.api.core.ClientOptions;
+import com.pipedream.api.core.MediaTypes;
+import com.pipedream.api.core.ObjectMappers;
+import com.pipedream.api.core.PipedreamApiApiException;
+import com.pipedream.api.core.PipedreamApiException;
+import com.pipedream.api.core.PipedreamApiHttpResponse;
+import com.pipedream.api.core.QueryStringMapper;
+import com.pipedream.api.core.RequestOptions;
+import com.pipedream.api.core.pagination.SyncPagingIterable;
+import com.pipedream.api.resources.accounts.requests.AccountsListRequest;
+import com.pipedream.api.resources.accounts.requests.AccountsRetrieveRequest;
+import com.pipedream.api.resources.accounts.requests.CreateAccountRequest;
+import com.pipedream.api.types.Account;
+import com.pipedream.api.types.ListAccountsResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Headers;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+import org.jetbrains.annotations.NotNull;
+
+public class AsyncRawAccountsClient {
+ protected final ClientOptions clientOptions;
+
+ public AsyncRawAccountsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ }
+
+ public CompletableFuture>> list() {
+ return list(AccountsListRequest.builder().build());
+ }
+
+ public CompletableFuture>> list(AccountsListRequest request) {
+ return list(request, null);
+ }
+
+ public CompletableFuture>> list(
+ AccountsListRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts");
+ if (request.getAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "app_id", request.getAppId().get(), false);
+ }
+ if (request.getExternalUserId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "external_user_id", request.getExternalUserId().get(), false);
+ }
+ if (request.getOauthAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "oauth_app_id", request.getOauthAppId().get(), false);
+ }
+ if (request.getAfter().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "after", request.getAfter().get(), false);
+ }
+ if (request.getBefore().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "before", request.getBefore().get(), false);
+ }
+ if (request.getLimit().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "limit", request.getLimit().get(), false);
+ }
+ if (request.getIncludeCredentials().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl,
+ "include_credentials",
+ request.getIncludeCredentials().get(),
+ false);
+ }
+ Request.Builder _requestBuilder = new Request.Builder()
+ .url(httpUrl.build())
+ .method("GET", null)
+ .headers(Headers.of(clientOptions.headers(requestOptions)))
+ .addHeader("Accept", "application/json");
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ CompletableFuture>> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ if (response.isSuccessful()) {
+ ListAccountsResponse parsedResponse =
+ ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAccountsResponse.class);
+ Optional startingAfter =
+ parsedResponse.getPageInfo().getEndCursor();
+ AccountsListRequest nextRequest = AccountsListRequest.builder()
+ .from(request)
+ .after(startingAfter)
+ .build();
+ List result = parsedResponse.getData();
+ future.complete(new PipedreamApiHttpResponse<>(
+ new SyncPagingIterable(startingAfter.isPresent(), result, () -> {
+ try {
+ return list(nextRequest, requestOptions)
+ .get()
+ .body();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ }),
+ response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ future.completeExceptionally(new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ } catch (IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+
+ public CompletableFuture> create(CreateAccountRequest request) {
+ return create(request, null);
+ }
+
+ public CompletableFuture> create(
+ CreateAccountRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts");
+ if (request.getAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "app_id", request.getAppId().get(), false);
+ }
+ if (request.getExternalUserId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "external_user_id", request.getExternalUserId().get(), false);
+ }
+ if (request.getOauthAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "oauth_app_id", request.getOauthAppId().get(), false);
+ }
+ Map properties = new HashMap<>();
+ properties.put("app_slug", request.getAppSlug());
+ properties.put("cfmap_json", request.getCfmapJson());
+ properties.put("connect_token", request.getConnectToken());
+ if (request.getName().isPresent()) {
+ properties.put("name", request.getName());
+ }
+ RequestBody body;
+ try {
+ body = RequestBody.create(
+ ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ Request.Builder _requestBuilder = new Request.Builder()
+ .url(httpUrl.build())
+ .method("POST", body)
+ .headers(Headers.of(clientOptions.headers(requestOptions)))
+ .addHeader("Content-Type", "application/json")
+ .addHeader("Accept", "application/json");
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ if (response.isSuccessful()) {
+ future.complete(new PipedreamApiHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ future.completeExceptionally(new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ } catch (IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+
+ public CompletableFuture> retrieve(String accountId) {
+ return retrieve(accountId, AccountsRetrieveRequest.builder().build());
+ }
+
+ public CompletableFuture> retrieve(
+ String accountId, AccountsRetrieveRequest request) {
+ return retrieve(accountId, request, null);
+ }
+
+ public CompletableFuture> retrieve(
+ String accountId, AccountsRetrieveRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts")
+ .addPathSegment(accountId);
+ if (request.getIncludeCredentials().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl,
+ "include_credentials",
+ request.getIncludeCredentials().get(),
+ false);
+ }
+ Request.Builder _requestBuilder = new Request.Builder()
+ .url(httpUrl.build())
+ .method("GET", null)
+ .headers(Headers.of(clientOptions.headers(requestOptions)))
+ .addHeader("Accept", "application/json");
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ if (response.isSuccessful()) {
+ future.complete(new PipedreamApiHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ future.completeExceptionally(new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ } catch (IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+
+ public CompletableFuture> delete(String accountId) {
+ return delete(accountId, null);
+ }
+
+ public CompletableFuture> delete(String accountId, RequestOptions requestOptions) {
+ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts")
+ .addPathSegment(accountId)
+ .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);
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ if (response.isSuccessful()) {
+ future.complete(new PipedreamApiHttpResponse<>(null, response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ future.completeExceptionally(new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ } catch (IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+
+ public CompletableFuture> deleteByApp(String appId) {
+ return deleteByApp(appId, null);
+ }
+
+ public CompletableFuture> deleteByApp(String appId, RequestOptions requestOptions) {
+ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("apps")
+ .addPathSegment(appId)
+ .addPathSegments("accounts")
+ .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);
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ if (response.isSuccessful()) {
+ future.complete(new PipedreamApiHttpResponse<>(null, response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ future.completeExceptionally(new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ } catch (IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new PipedreamApiException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
new file mode 100644
index 0000000..114533c
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
@@ -0,0 +1,312 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts;
+
+import com.pipedream.api.core.ClientOptions;
+import com.pipedream.api.core.MediaTypes;
+import com.pipedream.api.core.ObjectMappers;
+import com.pipedream.api.core.PipedreamApiApiException;
+import com.pipedream.api.core.PipedreamApiException;
+import com.pipedream.api.core.PipedreamApiHttpResponse;
+import com.pipedream.api.core.QueryStringMapper;
+import com.pipedream.api.core.RequestOptions;
+import com.pipedream.api.core.pagination.SyncPagingIterable;
+import com.pipedream.api.resources.accounts.requests.AccountsListRequest;
+import com.pipedream.api.resources.accounts.requests.AccountsRetrieveRequest;
+import com.pipedream.api.resources.accounts.requests.CreateAccountRequest;
+import com.pipedream.api.types.Account;
+import com.pipedream.api.types.ListAccountsResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import okhttp3.Headers;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+
+public class RawAccountsClient {
+ protected final ClientOptions clientOptions;
+
+ public RawAccountsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ }
+
+ public PipedreamApiHttpResponse> list() {
+ return list(AccountsListRequest.builder().build());
+ }
+
+ public PipedreamApiHttpResponse> list(AccountsListRequest request) {
+ return list(request, null);
+ }
+
+ public PipedreamApiHttpResponse> list(
+ AccountsListRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts");
+ if (request.getAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "app_id", request.getAppId().get(), false);
+ }
+ if (request.getExternalUserId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "external_user_id", request.getExternalUserId().get(), false);
+ }
+ if (request.getOauthAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "oauth_app_id", request.getOauthAppId().get(), false);
+ }
+ if (request.getAfter().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "after", request.getAfter().get(), false);
+ }
+ if (request.getBefore().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "before", request.getBefore().get(), false);
+ }
+ if (request.getLimit().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "limit", request.getLimit().get(), false);
+ }
+ if (request.getIncludeCredentials().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl,
+ "include_credentials",
+ request.getIncludeCredentials().get(),
+ false);
+ }
+ Request.Builder _requestBuilder = new Request.Builder()
+ .url(httpUrl.build())
+ .method("GET", null)
+ .headers(Headers.of(clientOptions.headers(requestOptions)))
+ .addHeader("Accept", "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()) {
+ ListAccountsResponse parsedResponse =
+ ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAccountsResponse.class);
+ Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
+ AccountsListRequest nextRequest = AccountsListRequest.builder()
+ .from(request)
+ .after(startingAfter)
+ .build();
+ List result = parsedResponse.getData();
+ return new PipedreamApiHttpResponse<>(
+ new SyncPagingIterable(
+ startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions)
+ .body()),
+ response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ throw new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response);
+ } catch (IOException e) {
+ throw new PipedreamApiException("Network error executing HTTP request", e);
+ }
+ }
+
+ public PipedreamApiHttpResponse create(CreateAccountRequest request) {
+ return create(request, null);
+ }
+
+ public PipedreamApiHttpResponse create(CreateAccountRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts");
+ if (request.getAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "app_id", request.getAppId().get(), false);
+ }
+ if (request.getExternalUserId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "external_user_id", request.getExternalUserId().get(), false);
+ }
+ if (request.getOauthAppId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "oauth_app_id", request.getOauthAppId().get(), false);
+ }
+ Map properties = new HashMap<>();
+ properties.put("app_slug", request.getAppSlug());
+ properties.put("cfmap_json", request.getCfmapJson());
+ properties.put("connect_token", request.getConnectToken());
+ if (request.getName().isPresent()) {
+ properties.put("name", request.getName());
+ }
+ RequestBody body;
+ try {
+ body = RequestBody.create(
+ ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ Request.Builder _requestBuilder = new Request.Builder()
+ .url(httpUrl.build())
+ .method("POST", body)
+ .headers(Headers.of(clientOptions.headers(requestOptions)))
+ .addHeader("Content-Type", "application/json")
+ .addHeader("Accept", "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()) {
+ return new PipedreamApiHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ throw new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response);
+ } catch (IOException e) {
+ throw new PipedreamApiException("Network error executing HTTP request", e);
+ }
+ }
+
+ public PipedreamApiHttpResponse retrieve(String accountId) {
+ return retrieve(accountId, AccountsRetrieveRequest.builder().build());
+ }
+
+ public PipedreamApiHttpResponse retrieve(String accountId, AccountsRetrieveRequest request) {
+ return retrieve(accountId, request, null);
+ }
+
+ public PipedreamApiHttpResponse retrieve(
+ String accountId, AccountsRetrieveRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts")
+ .addPathSegment(accountId);
+ if (request.getIncludeCredentials().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl,
+ "include_credentials",
+ request.getIncludeCredentials().get(),
+ false);
+ }
+ Request.Builder _requestBuilder = new Request.Builder()
+ .url(httpUrl.build())
+ .method("GET", null)
+ .headers(Headers.of(clientOptions.headers(requestOptions)))
+ .addHeader("Accept", "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()) {
+ return new PipedreamApiHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ throw new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response);
+ } catch (IOException e) {
+ throw new PipedreamApiException("Network error executing HTTP request", e);
+ }
+ }
+
+ public PipedreamApiHttpResponse delete(String accountId) {
+ return delete(accountId, null);
+ }
+
+ public PipedreamApiHttpResponse delete(String accountId, RequestOptions requestOptions) {
+ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("accounts")
+ .addPathSegment(accountId)
+ .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 new PipedreamApiHttpResponse<>(null, response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ throw new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response);
+ } catch (IOException e) {
+ throw new PipedreamApiException("Network error executing HTTP request", e);
+ }
+ }
+
+ public PipedreamApiHttpResponse deleteByApp(String appId) {
+ return deleteByApp(appId, null);
+ }
+
+ public PipedreamApiHttpResponse deleteByApp(String appId, RequestOptions requestOptions) {
+ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/connect")
+ .addPathSegment(clientOptions.projectId())
+ .addPathSegments("apps")
+ .addPathSegment(appId)
+ .addPathSegments("accounts")
+ .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 new PipedreamApiHttpResponse<>(null, response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ throw new PipedreamApiApiException(
+ "Error with status code " + response.code(),
+ response.code(),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response);
+ } catch (IOException e) {
+ throw new PipedreamApiException("Network error executing HTTP request", e);
+ }
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java
new file mode 100644
index 0000000..2d67f6d
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java
@@ -0,0 +1,285 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts.requests;
+
+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 com.pipedream.api.core.ObjectMappers;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+@JsonInclude(JsonInclude.Include.NON_ABSENT)
+@JsonDeserialize(builder = AccountsListRequest.Builder.class)
+public final class AccountsListRequest {
+ private final Optional appId;
+
+ private final Optional externalUserId;
+
+ private final Optional oauthAppId;
+
+ private final Optional after;
+
+ private final Optional before;
+
+ private final Optional limit;
+
+ private final Optional includeCredentials;
+
+ private final Map additionalProperties;
+
+ private AccountsListRequest(
+ Optional appId,
+ Optional externalUserId,
+ Optional oauthAppId,
+ Optional after,
+ Optional before,
+ Optional limit,
+ Optional includeCredentials,
+ Map additionalProperties) {
+ this.appId = appId;
+ this.externalUserId = externalUserId;
+ this.oauthAppId = oauthAppId;
+ this.after = after;
+ this.before = before;
+ this.limit = limit;
+ this.includeCredentials = includeCredentials;
+ this.additionalProperties = additionalProperties;
+ }
+
+ /**
+ * @return The app slug or ID to filter accounts by.
+ */
+ @JsonProperty("app_id")
+ public Optional getAppId() {
+ return appId;
+ }
+
+ @JsonProperty("external_user_id")
+ public Optional getExternalUserId() {
+ return externalUserId;
+ }
+
+ /**
+ * @return The OAuth app ID to filter by, if applicable
+ */
+ @JsonProperty("oauth_app_id")
+ public Optional getOauthAppId() {
+ return oauthAppId;
+ }
+
+ /**
+ * @return The cursor to start from for pagination
+ */
+ @JsonProperty("after")
+ public Optional getAfter() {
+ return after;
+ }
+
+ /**
+ * @return The cursor to end before for pagination
+ */
+ @JsonProperty("before")
+ public Optional getBefore() {
+ return before;
+ }
+
+ /**
+ * @return The maximum number of results to return
+ */
+ @JsonProperty("limit")
+ public Optional getLimit() {
+ return limit;
+ }
+
+ /**
+ * @return Whether to retrieve the account's credentials or not
+ */
+ @JsonProperty("include_credentials")
+ public Optional getIncludeCredentials() {
+ return includeCredentials;
+ }
+
+ @java.lang.Override
+ public boolean equals(Object other) {
+ if (this == other) return true;
+ return other instanceof AccountsListRequest && equalTo((AccountsListRequest) other);
+ }
+
+ @JsonAnyGetter
+ public Map getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ private boolean equalTo(AccountsListRequest other) {
+ return appId.equals(other.appId)
+ && externalUserId.equals(other.externalUserId)
+ && oauthAppId.equals(other.oauthAppId)
+ && after.equals(other.after)
+ && before.equals(other.before)
+ && limit.equals(other.limit)
+ && includeCredentials.equals(other.includeCredentials);
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ return Objects.hash(
+ this.appId,
+ this.externalUserId,
+ this.oauthAppId,
+ this.after,
+ this.before,
+ this.limit,
+ this.includeCredentials);
+ }
+
+ @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 appId = Optional.empty();
+
+ private Optional externalUserId = Optional.empty();
+
+ private Optional oauthAppId = Optional.empty();
+
+ private Optional after = Optional.empty();
+
+ private Optional before = Optional.empty();
+
+ private Optional limit = Optional.empty();
+
+ private Optional includeCredentials = Optional.empty();
+
+ @JsonAnySetter
+ private Map additionalProperties = new HashMap<>();
+
+ private Builder() {}
+
+ public Builder from(AccountsListRequest other) {
+ appId(other.getAppId());
+ externalUserId(other.getExternalUserId());
+ oauthAppId(other.getOauthAppId());
+ after(other.getAfter());
+ before(other.getBefore());
+ limit(other.getLimit());
+ includeCredentials(other.getIncludeCredentials());
+ return this;
+ }
+
+ /**
+ * The app slug or ID to filter accounts by.
+ */
+ @JsonSetter(value = "app_id", nulls = Nulls.SKIP)
+ public Builder appId(Optional appId) {
+ this.appId = appId;
+ return this;
+ }
+
+ public Builder appId(String appId) {
+ this.appId = Optional.ofNullable(appId);
+ return this;
+ }
+
+ @JsonSetter(value = "external_user_id", nulls = Nulls.SKIP)
+ public Builder externalUserId(Optional externalUserId) {
+ this.externalUserId = externalUserId;
+ return this;
+ }
+
+ public Builder externalUserId(String externalUserId) {
+ this.externalUserId = Optional.ofNullable(externalUserId);
+ return this;
+ }
+
+ /**
+ * The OAuth app ID to filter by, if applicable
+ */
+ @JsonSetter(value = "oauth_app_id", nulls = Nulls.SKIP)
+ public Builder oauthAppId(Optional oauthAppId) {
+ this.oauthAppId = oauthAppId;
+ return this;
+ }
+
+ public Builder oauthAppId(String oauthAppId) {
+ this.oauthAppId = Optional.ofNullable(oauthAppId);
+ return this;
+ }
+
+ /**
+ * The cursor to start from for pagination
+ */
+ @JsonSetter(value = "after", nulls = Nulls.SKIP)
+ public Builder after(Optional after) {
+ this.after = after;
+ return this;
+ }
+
+ public Builder after(String after) {
+ this.after = Optional.ofNullable(after);
+ return this;
+ }
+
+ /**
+ * The cursor to end before for pagination
+ */
+ @JsonSetter(value = "before", nulls = Nulls.SKIP)
+ public Builder before(Optional before) {
+ this.before = before;
+ return this;
+ }
+
+ public Builder before(String before) {
+ this.before = Optional.ofNullable(before);
+ return this;
+ }
+
+ /**
+ * The maximum number of results to return
+ */
+ @JsonSetter(value = "limit", nulls = Nulls.SKIP)
+ public Builder limit(Optional limit) {
+ this.limit = limit;
+ return this;
+ }
+
+ public Builder limit(Integer limit) {
+ this.limit = Optional.ofNullable(limit);
+ return this;
+ }
+
+ /**
+ * Whether to retrieve the account's credentials or not
+ */
+ @JsonSetter(value = "include_credentials", nulls = Nulls.SKIP)
+ public Builder includeCredentials(Optional includeCredentials) {
+ this.includeCredentials = includeCredentials;
+ return this;
+ }
+
+ public Builder includeCredentials(Boolean includeCredentials) {
+ this.includeCredentials = Optional.ofNullable(includeCredentials);
+ return this;
+ }
+
+ public AccountsListRequest build() {
+ return new AccountsListRequest(
+ appId, externalUserId, oauthAppId, after, before, limit, includeCredentials, additionalProperties);
+ }
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsRetrieveRequest.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsRetrieveRequest.java
new file mode 100644
index 0000000..3844f9d
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsRetrieveRequest.java
@@ -0,0 +1,101 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts.requests;
+
+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 com.pipedream.api.core.ObjectMappers;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+@JsonInclude(JsonInclude.Include.NON_ABSENT)
+@JsonDeserialize(builder = AccountsRetrieveRequest.Builder.class)
+public final class AccountsRetrieveRequest {
+ private final Optional includeCredentials;
+
+ private final Map additionalProperties;
+
+ private AccountsRetrieveRequest(Optional includeCredentials, Map additionalProperties) {
+ this.includeCredentials = includeCredentials;
+ this.additionalProperties = additionalProperties;
+ }
+
+ /**
+ * @return Whether to retrieve the account's credentials or not
+ */
+ @JsonProperty("include_credentials")
+ public Optional getIncludeCredentials() {
+ return includeCredentials;
+ }
+
+ @java.lang.Override
+ public boolean equals(Object other) {
+ if (this == other) return true;
+ return other instanceof AccountsRetrieveRequest && equalTo((AccountsRetrieveRequest) other);
+ }
+
+ @JsonAnyGetter
+ public Map getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ private boolean equalTo(AccountsRetrieveRequest other) {
+ return includeCredentials.equals(other.includeCredentials);
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ return Objects.hash(this.includeCredentials);
+ }
+
+ @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 includeCredentials = Optional.empty();
+
+ @JsonAnySetter
+ private Map additionalProperties = new HashMap<>();
+
+ private Builder() {}
+
+ public Builder from(AccountsRetrieveRequest other) {
+ includeCredentials(other.getIncludeCredentials());
+ return this;
+ }
+
+ /**
+ * Whether to retrieve the account's credentials or not
+ */
+ @JsonSetter(value = "include_credentials", nulls = Nulls.SKIP)
+ public Builder includeCredentials(Optional includeCredentials) {
+ this.includeCredentials = includeCredentials;
+ return this;
+ }
+
+ public Builder includeCredentials(Boolean includeCredentials) {
+ this.includeCredentials = Optional.ofNullable(includeCredentials);
+ return this;
+ }
+
+ public AccountsRetrieveRequest build() {
+ return new AccountsRetrieveRequest(includeCredentials, additionalProperties);
+ }
+ }
+}
diff --git a/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountRequest.java b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountRequest.java
new file mode 100644
index 0000000..aeec52a
--- /dev/null
+++ b/build/spotless/spotlessJava/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountRequest.java
@@ -0,0 +1,354 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.resources.accounts.requests;
+
+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 com.pipedream.api.core.ObjectMappers;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import org.jetbrains.annotations.NotNull;
+
+@JsonInclude(JsonInclude.Include.NON_ABSENT)
+@JsonDeserialize(builder = CreateAccountRequest.Builder.class)
+public final class CreateAccountRequest {
+ private final Optional appId;
+
+ private final Optional externalUserId;
+
+ private final Optional oauthAppId;
+
+ private final String appSlug;
+
+ private final String cfmapJson;
+
+ private final String connectToken;
+
+ private final Optional name;
+
+ private final Map additionalProperties;
+
+ private CreateAccountRequest(
+ Optional appId,
+ Optional externalUserId,
+ Optional