nextBackoff(Response response) {
+ if (retryNumber >= maxNumRetries) {
return Optional.empty();
}
- int upperBound = (int) Math.pow(2, retryNumber);
- return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound)));
+ Duration delay = getRetryDelayFromHeaders(response, retryNumber);
+ retryNumber += 1;
+ return Optional.of(delay);
}
}
}
diff --git a/src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java b/src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java
new file mode 100644
index 0000000..40ba44c
--- /dev/null
+++ b/src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java
@@ -0,0 +1,165 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core.pagination;
+
+import com.pipedream.api.core.ClientOptions;
+import java.io.IOException;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+/**
+ * Skeleton implementation for custom asynchronous bidirectional pagination.
+ *
+ * THIS CLASS MUST BE IMPLEMENTED BY THE USER.
+ *
+ * This file is added to .fernignore and will not be regenerated.
+ * Replace this skeleton implementation with your custom async pagination logic
+ * that handles your API's specific pagination structure (e.g., HATEOAS links).
+ *
+ * Example implementation for HATEOAS-style async pagination:
+ * {@code
+ * public class AsyncCustomPager implements BiDirectionalPage {
+ * private final List items;
+ * private final String nextUrl;
+ * private final String previousUrl;
+ * private final AsyncHttpClient client;
+ *
+ * public AsyncCustomPager(Response response, AsyncHttpClient client, ...) {
+ * this.items = response.getData();
+ * this.nextUrl = response.getLinks().getNext();
+ * this.previousUrl = response.getLinks().getPrevious();
+ * // ... store other needed context
+ * }
+ *
+ * @Override
+ * public boolean hasNext() {
+ * return nextUrl != null;
+ * }
+ *
+ * @Override
+ * public CompletableFuture> nextPageAsync() {
+ * if (!hasNext()) {
+ * CompletableFuture> future = new CompletableFuture<>();
+ * future.completeExceptionally(new NoSuchElementException("No next page available"));
+ * return future;
+ * }
+ * // Make async HTTP request to nextUrl
+ * return client.getAsync(nextUrl)
+ * .thenApply(response -> new AsyncCustomPager<>(response, client, ...));
+ * }
+ *
+ * // ... implement other methods
+ * }
+ * }
+ *
+ * @param The type of items in the page
+ */
+public class AsyncCustomPager implements BiDirectionalPage {
+
+ /**
+ * Create an AsyncCustomPager from an initial response.
+ *
+ * @param initialResponse The first page response from the API
+ * @param clientOptions The client options containing HTTP client and other configuration
+ * @param requestOptions Request options for authentication, headers, etc.
+ * @return A CompletableFuture containing the new AsyncCustomPager instance
+ */
+ public static CompletableFuture> createAsync(
+ Object initialResponse, ClientOptions clientOptions, Object requestOptions) {
+ throw new UnsupportedOperationException("AsyncCustomPager must be implemented. "
+ + "Please implement this class in core/AsyncCustomPager.java to define your async pagination logic. "
+ + "This file has been added to .fernignore and will not be overwritten. "
+ + "See the class documentation for implementation examples.");
+ }
+
+ @Override
+ public boolean hasNext() {
+ throw new UnsupportedOperationException("AsyncCustomPager.hasNext() must be implemented. "
+ + "This method should return true if a next page is available.");
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ throw new UnsupportedOperationException("AsyncCustomPager.hasPrevious() must be implemented. "
+ + "This method should return true if a previous page is available.");
+ }
+
+ /**
+ * Asynchronously fetch the next page.
+ *
+ * @return A CompletableFuture that completes with the next page
+ * @throws java.util.NoSuchElementException if no next page exists (wrapped in CompletableFuture)
+ */
+ public CompletableFuture> nextPageAsync() {
+ CompletableFuture> future = new CompletableFuture<>();
+ future.completeExceptionally(
+ new UnsupportedOperationException("AsyncCustomPager.nextPageAsync() must be implemented. "
+ + "This method should asynchronously fetch and return the next page of results."));
+ return future;
+ }
+
+ /**
+ * Asynchronously fetch the previous page.
+ *
+ * @return A CompletableFuture that completes with the previous page
+ * @throws java.util.NoSuchElementException if no previous page exists (wrapped in CompletableFuture)
+ */
+ public CompletableFuture> previousPageAsync() {
+ CompletableFuture> future = new CompletableFuture<>();
+ future.completeExceptionally(
+ new UnsupportedOperationException("AsyncCustomPager.previousPageAsync() must be implemented. "
+ + "This method should asynchronously fetch and return the previous page of results."));
+ return future;
+ }
+
+ @Override
+ public BiDirectionalPage nextPage() throws IOException {
+ throw new UnsupportedOperationException("AsyncCustomPager.nextPage() must be implemented. "
+ + "Consider using nextPageAsync() for async operations, or implement synchronous blocking version.");
+ }
+
+ @Override
+ public BiDirectionalPage previousPage() throws IOException {
+ throw new UnsupportedOperationException(
+ "AsyncCustomPager.previousPage() must be implemented. "
+ + "Consider using previousPageAsync() for async operations, or implement synchronous blocking version.");
+ }
+
+ @Override
+ public List getItems() {
+ throw new UnsupportedOperationException("AsyncCustomPager.getItems() must be implemented. "
+ + "This method should return the items in the current page.");
+ }
+
+ @Override
+ public Optional getResponse() {
+ throw new UnsupportedOperationException("AsyncCustomPager.getResponse() must be implemented. "
+ + "This method should return the full response object for accessing pagination metadata.");
+ }
+
+ /**
+ * Asynchronously iterate through all pages starting from current.
+ * Returns a CompletableFuture that completes with all items from all pages.
+ *
+ * @return CompletableFuture containing all items across all pages
+ */
+ public CompletableFuture> getAllItemsAsync() {
+ throw new UnsupportedOperationException("AsyncCustomPager.getAllItemsAsync() must be implemented. "
+ + "This method should asynchronously fetch all pages and return all items.");
+ }
+
+ /**
+ * Process each page asynchronously as it arrives.
+ *
+ * @param pageProcessor Function to process each page
+ * @return CompletableFuture that completes when all pages are processed
+ */
+ public CompletableFuture forEachPageAsync(
+ java.util.function.Function, CompletionStage> pageProcessor) {
+ throw new UnsupportedOperationException("AsyncCustomPager.forEachPageAsync() must be implemented. "
+ + "This method should asynchronously process each page with the given function.");
+ }
+}
diff --git a/src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java b/src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java
new file mode 100644
index 0000000..2d21d7c
--- /dev/null
+++ b/src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java
@@ -0,0 +1,60 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core.pagination;
+
+import java.util.List;
+
+/**
+ * Interface for pages that support bidirectional pagination (both forward and backward navigation).
+ * This is used for custom pagination scenarios where the API provides both next and previous page links.
+ *
+ * @param The type of items in the page
+ */
+public interface BiDirectionalPage {
+ /**
+ * Returns whether there is a next page available.
+ *
+ * @return true if next page exists and can be fetched
+ */
+ boolean hasNext();
+
+ /**
+ * Returns whether there is a previous page available.
+ *
+ * @return true if previous page exists and can be fetched
+ */
+ boolean hasPrevious();
+
+ /**
+ * Fetches and returns the next page.
+ *
+ * @return the next page
+ * @throws java.util.NoSuchElementException if no next page exists
+ * @throws java.io.IOException if the HTTP request fails
+ */
+ BiDirectionalPage nextPage() throws java.io.IOException;
+
+ /**
+ * Fetches and returns the previous page.
+ *
+ * @return the previous page
+ * @throws java.util.NoSuchElementException if no previous page exists
+ * @throws java.io.IOException if the HTTP request fails
+ */
+ BiDirectionalPage previousPage() throws java.io.IOException;
+
+ /**
+ * Returns the items in the current page.
+ *
+ * @return list of items in this page
+ */
+ List getItems();
+
+ /**
+ * Returns the full response object for accessing pagination metadata.
+ *
+ * @return Optional containing the response, or empty if unavailable
+ */
+ java.util.Optional getResponse();
+}
diff --git a/src/main/java/com/pipedream/api/core/pagination/CustomPager.java b/src/main/java/com/pipedream/api/core/pagination/CustomPager.java
new file mode 100644
index 0000000..4397478
--- /dev/null
+++ b/src/main/java/com/pipedream/api/core/pagination/CustomPager.java
@@ -0,0 +1,118 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.core.pagination;
+
+import com.pipedream.api.core.ClientOptions;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Skeleton implementation for custom bidirectional pagination.
+ *
+ * THIS CLASS MUST BE IMPLEMENTED BY THE USER.
+ *
+ * This file is added to .fernignore and will not be regenerated.
+ * Replace this skeleton implementation with your custom pagination logic
+ * that handles your API's specific pagination structure (e.g., HATEOAS links).
+ *
+ * Example implementation for HATEOAS-style pagination:
+ * {@code
+ * public class CustomPager implements BiDirectionalPage, Iterable {
+ * private final List items;
+ * private final String nextUrl;
+ * private final String previousUrl;
+ * private final OkHttpClient client;
+ * private final TypeReference> responseType;
+ *
+ * public CustomPager(Response response, OkHttpClient client, ...) {
+ * this.items = response.getData();
+ * this.nextUrl = response.getLinks().getNext();
+ * this.previousUrl = response.getLinks().getPrevious();
+ * // ... store other needed context
+ * }
+ *
+ * @Override
+ * public boolean hasNext() {
+ * return nextUrl != null;
+ * }
+ *
+ * @Override
+ * public CustomPager nextPage() throws IOException {
+ * if (!hasNext()) {
+ * throw new NoSuchElementException("No next page available");
+ * }
+ * // Make HTTP request to nextUrl
+ * // Parse response
+ * // Return new CustomPager instance
+ * }
+ *
+ * // ... implement other methods
+ * }
+ * }
+ *
+ * @param The type of items in the page
+ */
+public class CustomPager implements BiDirectionalPage, Iterable {
+
+ /**
+ * Create a CustomPager from an initial response.
+ *
+ * @param initialResponse The first page response from the API
+ * @param clientOptions The client options containing HTTP client and other configuration
+ * @param requestOptions Request options for authentication, headers, etc.
+ * @return A new CustomPager instance
+ * @throws IOException if the request fails
+ */
+ public static CustomPager create(Object initialResponse, ClientOptions clientOptions, Object requestOptions)
+ throws IOException {
+ throw new UnsupportedOperationException("CustomPager must be implemented. "
+ + "Please implement this class in core/CustomPager.java to define your pagination logic. "
+ + "This file has been added to .fernignore and will not be overwritten. "
+ + "See the class documentation for implementation examples.");
+ }
+
+ @Override
+ public boolean hasNext() {
+ throw new UnsupportedOperationException("CustomPager.hasNext() must be implemented. "
+ + "This method should return true if a next page is available.");
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ throw new UnsupportedOperationException("CustomPager.hasPrevious() must be implemented. "
+ + "This method should return true if a previous page is available.");
+ }
+
+ @Override
+ public BiDirectionalPage nextPage() throws IOException {
+ throw new UnsupportedOperationException("CustomPager.nextPage() must be implemented. "
+ + "This method should fetch and return the next page of results.");
+ }
+
+ @Override
+ public BiDirectionalPage previousPage() throws IOException {
+ throw new UnsupportedOperationException("CustomPager.previousPage() must be implemented. "
+ + "This method should fetch and return the previous page of results.");
+ }
+
+ @Override
+ public List getItems() {
+ throw new UnsupportedOperationException("CustomPager.getItems() must be implemented. "
+ + "This method should return the items in the current page.");
+ }
+
+ @Override
+ public Optional getResponse() {
+ throw new UnsupportedOperationException("CustomPager.getResponse() must be implemented. "
+ + "This method should return the full response object for accessing pagination metadata.");
+ }
+
+ @Override
+ public Iterator iterator() {
+ throw new UnsupportedOperationException("CustomPager.iterator() must be implemented. "
+ + "This method should return an iterator that traverses all items across all pages.");
+ }
+}
diff --git a/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java b/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
index dd95b5f..2e1566a 100644
--- a/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
+++ b/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
@@ -111,9 +111,10 @@ public CompletableFuture>> li
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
ListAccountsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAccountsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAccountsResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
AccountsListRequest nextRequest = AccountsListRequest.builder()
@@ -135,7 +136,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -145,11 +145,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -212,12 +210,12 @@ public CompletableFuture> create(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response));
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -227,11 +225,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -294,12 +290,12 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response));
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -309,11 +305,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -375,11 +369,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -442,11 +434,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java b/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
index 777be36..c46f19e 100644
--- a/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
+++ b/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
@@ -103,9 +103,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
ListAccountsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAccountsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAccountsResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
AccountsListRequest nextRequest = AccountsListRequest.builder()
.from(request)
@@ -118,7 +119,6 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -127,11 +127,9 @@ public BaseClientHttpResponse> list(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -181,11 +179,11 @@ public BaseClientHttpResponse create(CreateAccountOpts request, Request
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -194,11 +192,9 @@ public BaseClientHttpResponse create(CreateAccountOpts request, Request
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -248,11 +244,11 @@ public BaseClientHttpResponse retrieve(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -261,11 +257,9 @@ public BaseClientHttpResponse retrieve(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -313,11 +307,9 @@ public BaseClientHttpResponse delete(String accountId, RequestOptions requ
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -366,11 +358,9 @@ public BaseClientHttpResponse deleteByApp(String appId, RequestOptions req
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java b/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java
index db2d6db..bd8df19 100644
--- a/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java
+++ b/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java
@@ -110,9 +110,10 @@ public CompletableFuture>>
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
ActionsListRequest nextRequest = ActionsListRequest.builder()
@@ -134,7 +135,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -151,11 +151,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -215,13 +213,13 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -231,11 +229,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -266,7 +262,8 @@ public CompletableFuture> configur
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("actions/configure")
+ .addPathSegments("actions")
+ .addPathSegments("configure")
.build();
RequestBody body;
try {
@@ -291,13 +288,13 @@ public CompletableFuture> configur
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -307,11 +304,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -342,7 +337,8 @@ public CompletableFuture> reloadProp
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("actions/props")
+ .addPathSegments("actions")
+ .addPathSegments("props")
.build();
RequestBody body;
try {
@@ -367,13 +363,13 @@ public CompletableFuture> reloadProp
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -383,11 +379,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -418,7 +412,8 @@ public CompletableFuture> run(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("actions/run")
+ .addPathSegments("actions")
+ .addPathSegments("run")
.build();
RequestBody body;
try {
@@ -443,13 +438,13 @@ public CompletableFuture> run(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RunActionResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, RunActionResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -459,11 +454,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java b/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java
index 902614e..438895a 100644
--- a/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java
+++ b/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java
@@ -102,9 +102,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
ActionsListRequest nextRequest = ActionsListRequest.builder()
.from(request)
@@ -117,7 +118,6 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -130,11 +130,9 @@ public BaseClientHttpResponse> list(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -181,12 +179,12 @@ public BaseClientHttpResponse retrieve(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -195,11 +193,9 @@ public BaseClientHttpResponse retrieve(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -221,7 +217,8 @@ public BaseClientHttpResponse configureProp(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("actions/configure")
+ .addPathSegments("actions")
+ .addPathSegments("configure")
.build();
RequestBody body;
try {
@@ -243,12 +240,11 @@ public BaseClientHttpResponse configureProp(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -257,11 +253,9 @@ public BaseClientHttpResponse configureProp(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -283,7 +277,8 @@ public BaseClientHttpResponse reloadProps(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("actions/props")
+ .addPathSegments("actions")
+ .addPathSegments("props")
.build();
RequestBody body;
try {
@@ -305,12 +300,11 @@ public BaseClientHttpResponse reloadProps(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -319,11 +313,9 @@ public BaseClientHttpResponse reloadProps(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -344,7 +336,8 @@ public BaseClientHttpResponse run(RunActionOpts request, Requ
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("actions/run")
+ .addPathSegments("actions")
+ .addPathSegments("run")
.build();
RequestBody body;
try {
@@ -366,11 +359,11 @@ public BaseClientHttpResponse run(RunActionOpts request, Requ
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RunActionResponse.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, RunActionResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -379,11 +372,9 @@ public BaseClientHttpResponse run(RunActionOpts request, Requ
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java b/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java
index ea828f1..a8e5d04 100644
--- a/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java
+++ b/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java
@@ -61,19 +61,17 @@ public CompletableFuture>> list(Request
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), new TypeReference>() {}),
+ responseBodyString, new TypeReference>() {}),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -119,18 +117,15 @@ public CompletableFuture> retrieve(String id
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AppCategory.class),
- response));
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AppCategory.class), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java b/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java
index 401fd49..4a40980 100644
--- a/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java
+++ b/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java
@@ -54,18 +54,16 @@ public BaseClientHttpResponse> list(RequestOptions requestOpti
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), new TypeReference>() {}),
+ responseBodyString, new TypeReference>() {}),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -99,16 +97,14 @@ public BaseClientHttpResponse retrieve(String id, RequestOptions re
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AppCategory.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AppCategory.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java b/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java
index 63900eb..7471fca 100644
--- a/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java
+++ b/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java
@@ -113,9 +113,10 @@ public CompletableFuture>> list(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
ListAppsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAppsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAppsResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
AppsListRequest nextRequest = AppsListRequest.builder()
@@ -136,12 +137,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -188,18 +186,16 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetAppResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAppResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java b/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java
index 403f724..e927b9d 100644
--- a/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java
+++ b/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java
@@ -105,9 +105,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
ListAppsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAppsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAppsResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
AppsListRequest nextRequest = AppsListRequest.builder()
.from(request)
@@ -120,12 +121,9 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -159,16 +157,14 @@ public BaseClientHttpResponse retrieve(String appId, RequestOpti
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetAppResponse.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAppResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java b/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java
index 7ad7e19..8dc133d 100644
--- a/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java
+++ b/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java
@@ -113,9 +113,10 @@ public CompletableFuture>>
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
ComponentsListRequest nextRequest = ComponentsListRequest.builder()
@@ -137,7 +138,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -154,11 +154,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -218,13 +216,13 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -234,11 +232,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -269,7 +265,8 @@ public CompletableFuture> configur
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("components/configure")
+ .addPathSegments("components")
+ .addPathSegments("configure")
.build();
RequestBody body;
try {
@@ -294,13 +291,13 @@ public CompletableFuture> configur
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -310,11 +307,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -345,7 +340,8 @@ public CompletableFuture> reloadProp
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("components/props")
+ .addPathSegments("components")
+ .addPathSegments("props")
.build();
RequestBody body;
try {
@@ -370,13 +366,13 @@ public CompletableFuture> reloadProp
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -386,11 +382,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java b/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java
index b5a237f..e186a63 100644
--- a/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java
+++ b/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java
@@ -104,9 +104,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
ComponentsListRequest nextRequest = ComponentsListRequest.builder()
.from(request)
@@ -119,7 +120,6 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -132,11 +132,9 @@ public BaseClientHttpResponse> list(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -183,12 +181,12 @@ public BaseClientHttpResponse retrieve(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -197,11 +195,9 @@ public BaseClientHttpResponse retrieve(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -223,7 +219,8 @@ public BaseClientHttpResponse configureProp(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("components/configure")
+ .addPathSegments("components")
+ .addPathSegments("configure")
.build();
RequestBody body;
try {
@@ -245,12 +242,11 @@ public BaseClientHttpResponse configureProp(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -259,11 +255,9 @@ public BaseClientHttpResponse configureProp(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -285,7 +279,8 @@ public BaseClientHttpResponse reloadProps(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("components/props")
+ .addPathSegments("components")
+ .addPathSegments("props")
.build();
RequestBody body;
try {
@@ -307,12 +302,11 @@ public BaseClientHttpResponse reloadProps(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -321,11 +315,9 @@ public BaseClientHttpResponse reloadProps(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java
index 0542a9c..9f23ad1 100644
--- a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java
+++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java
@@ -103,9 +103,10 @@ public CompletableFuture>> li
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggersResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggersResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggersResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
DeployedTriggersListRequest nextRequest = DeployedTriggersListRequest.builder()
@@ -127,7 +128,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -137,11 +137,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -191,13 +189,13 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggerResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -207,11 +205,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -268,13 +264,13 @@ public CompletableFuture> update(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggerResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -284,11 +280,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -356,11 +350,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -414,13 +406,13 @@ public CompletableFuture>> listEvents(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
- GetTriggerEventsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), GetTriggerEventsResponse.class);
+ GetTriggerEventsResponse parsedResponse =
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerEventsResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -430,11 +422,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -485,14 +475,14 @@ public CompletableFuture> li
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), GetTriggerWorkflowsResponse.class),
+ responseBodyString, GetTriggerWorkflowsResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -502,11 +492,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -565,14 +553,14 @@ public CompletableFuture> up
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), GetTriggerWorkflowsResponse.class),
+ responseBodyString, GetTriggerWorkflowsResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -582,11 +570,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -637,14 +623,14 @@ public CompletableFuture> lis
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), GetTriggerWebhooksResponse.class),
+ responseBodyString, GetTriggerWebhooksResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -654,11 +640,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -717,14 +701,14 @@ public CompletableFuture> upd
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), GetTriggerWebhooksResponse.class),
+ responseBodyString, GetTriggerWebhooksResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -734,11 +718,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java
index f5f5117..83bd803 100644
--- a/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java
+++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java
@@ -94,9 +94,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggersResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggersResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggersResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
DeployedTriggersListRequest nextRequest = DeployedTriggersListRequest.builder()
.from(request)
@@ -109,7 +110,6 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -118,11 +118,9 @@ public BaseClientHttpResponse> list(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -159,12 +157,12 @@ public BaseClientHttpResponse retrieve(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggerResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -173,11 +171,9 @@ public BaseClientHttpResponse retrieve(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -222,12 +218,12 @@ public BaseClientHttpResponse update(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggerResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -236,11 +232,9 @@ public BaseClientHttpResponse update(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -293,11 +287,9 @@ public BaseClientHttpResponse delete(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -339,12 +331,12 @@ public BaseClientHttpResponse> listEvents(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetTriggerEventsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerEventsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerEventsResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -353,11 +345,9 @@ public BaseClientHttpResponse> listEvents(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -396,12 +386,12 @@ public BaseClientHttpResponse listWorkflows(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWorkflowsResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWorkflowsResponse.class),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -410,11 +400,9 @@ public BaseClientHttpResponse listWorkflows(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -461,12 +449,12 @@ public BaseClientHttpResponse updateWorkflows(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWorkflowsResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWorkflowsResponse.class),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -475,11 +463,9 @@ public BaseClientHttpResponse updateWorkflows(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -518,12 +504,12 @@ public BaseClientHttpResponse listWebhooks(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWebhooksResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWebhooksResponse.class),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -532,11 +518,9 @@ public BaseClientHttpResponse listWebhooks(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -583,12 +567,12 @@ public BaseClientHttpResponse updateWebhooks(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWebhooksResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWebhooksResponse.class),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -597,11 +581,9 @@ public BaseClientHttpResponse updateWebhooks(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java b/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java
index aa73f5d..af09992 100644
--- a/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java
+++ b/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java
@@ -50,7 +50,8 @@ public CompletableFuture> downloadFile(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("file_stash/download");
+ .addPathSegments("file_stash")
+ .addPathSegments("download");
QueryStringMapper.addQueryParameter(httpUrl, "s3_key", request.getS3Key(), false);
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
@@ -82,11 +83,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java b/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java
index 2bd5052..e8dd8e7 100644
--- a/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java
+++ b/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java
@@ -46,7 +46,8 @@ public BaseClientHttpResponse downloadFile(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("file_stash/download");
+ .addPathSegments("file_stash")
+ .addPathSegments("download");
QueryStringMapper.addQueryParameter(httpUrl, "s3_key", request.getS3Key(), false);
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
@@ -73,11 +74,9 @@ public BaseClientHttpResponse downloadFile(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java b/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java
index a922464..1632abd 100644
--- a/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java
+++ b/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java
@@ -72,19 +72,16 @@ public CompletableFuture> creat
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBody.string(), CreateOAuthTokenResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateOAuthTokenResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java b/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java
index 23a1d85..9e8e254 100644
--- a/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java
+++ b/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java
@@ -65,17 +65,15 @@ public BaseClientHttpResponse create(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateOAuthTokenResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateOAuthTokenResponse.class),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java b/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java
index 2c9dffd..ec09065 100644
--- a/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java
+++ b/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java
@@ -98,9 +98,10 @@ public CompletableFuture>> li
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
ListProjectsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListProjectsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListProjectsResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
ProjectsListRequest nextRequest = ProjectsListRequest.builder()
@@ -122,7 +123,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 404:
@@ -139,11 +139,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -197,12 +195,12 @@ public CompletableFuture> create(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response));
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -212,11 +210,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -263,12 +259,12 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response));
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -278,11 +274,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -342,11 +336,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -408,12 +400,12 @@ public CompletableFuture> update(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response));
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -423,11 +415,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -504,11 +494,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -538,7 +526,8 @@ public CompletableFuture> retrieveIn
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("projects/info")
+ .addPathSegments("projects")
+ .addPathSegments("info")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -555,13 +544,13 @@ public CompletableFuture> retrieveIn
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProjectInfoResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProjectInfoResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -571,11 +560,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java b/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java
index 2eee1a9..f3dd810 100644
--- a/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java
+++ b/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java
@@ -90,9 +90,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
ListProjectsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListProjectsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListProjectsResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
ProjectsListRequest nextRequest = ProjectsListRequest.builder()
.from(request)
@@ -105,7 +106,6 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 404:
@@ -118,11 +118,9 @@ public BaseClientHttpResponse> list(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -163,11 +161,11 @@ public BaseClientHttpResponse create(CreateProjectOpts request, Request
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -176,11 +174,9 @@ public BaseClientHttpResponse create(CreateProjectOpts request, Request
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -214,11 +210,11 @@ public BaseClientHttpResponse retrieve(String projectId, RequestOptions
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -227,11 +223,9 @@ public BaseClientHttpResponse retrieve(String projectId, RequestOptions
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -277,11 +271,9 @@ public BaseClientHttpResponse delete(String projectId, RequestOptions requ
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -331,11 +323,11 @@ public BaseClientHttpResponse update(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -344,11 +336,9 @@ public BaseClientHttpResponse update(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -408,11 +398,9 @@ public BaseClientHttpResponse updateLogo(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -433,7 +421,8 @@ public BaseClientHttpResponse retrieveInfo(RequestOptions r
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("projects/info")
+ .addPathSegments("projects")
+ .addPathSegments("info")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -447,12 +436,11 @@ public BaseClientHttpResponse retrieveInfo(RequestOptions r
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProjectInfoResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProjectInfoResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -461,11 +449,9 @@ public BaseClientHttpResponse retrieveInfo(RequestOptions r
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java b/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java
index 5ab836b..49f9aef 100644
--- a/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java
+++ b/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java
@@ -78,13 +78,13 @@ public CompletableFuture> create(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateTokenResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateTokenResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -94,11 +94,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -151,13 +149,13 @@ public CompletableFuture> validate
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ValidateTokenResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidateTokenResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -167,11 +165,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java b/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java
index f9414f5..e5507d9 100644
--- a/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java
+++ b/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java
@@ -70,12 +70,11 @@ public BaseClientHttpResponse create(CreateTokenOpts reques
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateTokenResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateTokenResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -84,11 +83,9 @@ public BaseClientHttpResponse create(CreateTokenOpts reques
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -128,12 +125,11 @@ public BaseClientHttpResponse validate(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ValidateTokenResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidateTokenResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -142,11 +138,9 @@ public BaseClientHttpResponse validate(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java b/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java
index 714501d..8934f98 100644
--- a/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java
+++ b/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java
@@ -111,9 +111,10 @@ public CompletableFuture>>
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class);
Optional startingAfter =
parsedResponse.getPageInfo().getEndCursor();
TriggersListRequest nextRequest = TriggersListRequest.builder()
@@ -135,7 +136,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -152,11 +152,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -216,13 +214,13 @@ public CompletableFuture> retrieve(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -232,11 +230,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -267,7 +263,8 @@ public CompletableFuture> configur
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("triggers/configure")
+ .addPathSegments("triggers")
+ .addPathSegments("configure")
.build();
RequestBody body;
try {
@@ -292,13 +289,13 @@ public CompletableFuture> configur
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -308,11 +305,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -343,7 +338,8 @@ public CompletableFuture> reloadProp
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("triggers/props")
+ .addPathSegments("triggers")
+ .addPathSegments("props")
.build();
RequestBody body;
try {
@@ -368,13 +364,13 @@ public CompletableFuture> reloadProp
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class),
response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -384,11 +380,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
@@ -419,7 +413,8 @@ public CompletableFuture> deploy(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("triggers/deploy")
+ .addPathSegments("triggers")
+ .addPathSegments("deploy")
.build();
RequestBody body;
try {
@@ -444,13 +439,13 @@ public CompletableFuture> deploy(
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
DeployTriggerResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeployTriggerResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeployTriggerResponse.class);
future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response));
return;
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
@@ -460,11 +455,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java b/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java
index 481ee85..f2cbc3d 100644
--- a/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java
+++ b/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java
@@ -103,9 +103,10 @@ public BaseClientHttpResponse> list(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentsResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class);
Optional startingAfter = parsedResponse.getPageInfo().getEndCursor();
TriggersListRequest nextRequest = TriggersListRequest.builder()
.from(request)
@@ -118,7 +119,6 @@ public BaseClientHttpResponse> list(
.body()),
response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -131,11 +131,9 @@ public BaseClientHttpResponse> list(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -182,12 +180,12 @@ public BaseClientHttpResponse retrieve(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
GetComponentResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -196,11 +194,9 @@ public BaseClientHttpResponse retrieve(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -222,7 +218,8 @@ public BaseClientHttpResponse configureProp(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("triggers/configure")
+ .addPathSegments("triggers")
+ .addPathSegments("configure")
.build();
RequestBody body;
try {
@@ -244,12 +241,11 @@ public BaseClientHttpResponse configureProp(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -258,11 +254,9 @@ public BaseClientHttpResponse configureProp(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -284,7 +278,8 @@ public BaseClientHttpResponse reloadProps(
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("triggers/props")
+ .addPathSegments("triggers")
+ .addPathSegments("props")
.build();
RequestBody body;
try {
@@ -306,12 +301,11 @@ public BaseClientHttpResponse reloadProps(
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -320,11 +314,9 @@ public BaseClientHttpResponse reloadProps(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
@@ -345,7 +337,8 @@ public BaseClientHttpResponse deploy(DeployTriggerOpts request, Request
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
- .addPathSegments("triggers/deploy")
+ .addPathSegments("triggers")
+ .addPathSegments("deploy")
.build();
RequestBody body;
try {
@@ -367,12 +360,12 @@ public BaseClientHttpResponse deploy(DeployTriggerOpts request, Request
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
if (response.isSuccessful()) {
DeployTriggerResponse parsedResponse =
- ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeployTriggerResponse.class);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeployTriggerResponse.class);
return new BaseClientHttpResponse<>(parsedResponse.getData(), response);
}
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
@@ -381,11 +374,9 @@ public BaseClientHttpResponse deploy(DeployTriggerOpts request, Request
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java b/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java
index c41f6f1..a1ad961 100644
--- a/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java
+++ b/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java
@@ -78,11 +78,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
+ "Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
diff --git a/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java b/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java
index 097eaaf..15600a5 100644
--- a/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java
+++ b/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java
@@ -68,11 +68,9 @@ public BaseClientHttpResponse deleteExternalUser(String externalUserId, Re
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new BaseClientApiException(
- "Error with status code " + response.code(),
- response.code(),
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response);
+ "Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
diff --git a/src/test/java/com/pipedream/api/StreamTest.java b/src/test/java/com/pipedream/api/StreamTest.java
index 57130cb..212816c 100644
--- a/src/test/java/com/pipedream/api/StreamTest.java
+++ b/src/test/java/com/pipedream/api/StreamTest.java
@@ -9,6 +9,9 @@
import com.pipedream.api.core.Stream;
import java.io.IOException;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -17,8 +20,9 @@
public final class StreamTest {
@Test
public void testJsonStream() {
- List