From 5c6b681fa13cff4946c7611d1a92a51a395bb969 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 03:38:52 +0000 Subject: [PATCH 1/3] SDK regeneration --- gradle/wrapper/gradle-wrapper.jar | Bin 43453 -> 43504 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 7 +- gradlew.bat | 2 + .../com/assemblyai/api/core/ApiError.java | 28 -- .../api/core/AssemblyAIApiException.java | 45 ++ .../api/core/AssemblyAIException.java | 17 + .../assemblyai/api/core/RequestOptions.java | 2 +- .../api/core/ResponseBodyInputStream.java | 45 ++ .../api/core/ResponseBodyReader.java | 44 ++ .../api/errors/BadRequestError.java | 27 ++ .../api/errors/GatewayTimeoutError.java | 26 ++ .../api/errors/InternalServerError.java | 27 ++ .../assemblyai/api/errors/NotFoundError.java | 27 ++ .../api/errors/ServiceUnavailableError.java | 26 ++ .../api/errors/TooManyRequestsError.java | 27 ++ .../api/errors/UnauthorizedError.java | 27 ++ .../api/resources/files/FilesClient.java | 57 ++- .../resources/files/types/UploadedFile.java | 2 +- .../api/resources/lemur/LemurClient.java | 298 ++++++++++--- .../requests/LemurActionItemsParams.java | 16 +- .../requests/LemurQuestionAnswerParams.java | 14 +- .../lemur/requests/LemurSummaryParams.java | 16 +- .../lemur/requests/LemurTaskParams.java | 14 +- .../lemur/types/LemurActionItemsResponse.java | 2 +- .../lemur/types/LemurBaseParams.java | 14 +- .../lemur/types/LemurBaseResponse.java | 2 +- .../api/resources/lemur/types/LemurModel.java | 14 +- .../resources/lemur/types/LemurQuestion.java | 8 +- .../lemur/types/LemurQuestionAnswer.java | 2 +- .../types/LemurQuestionAnswerResponse.java | 2 +- .../lemur/types/LemurStringResponse.java | 2 +- .../lemur/types/LemurSummaryResponse.java | 2 +- .../lemur/types/LemurTaskResponse.java | 2 +- .../api/resources/lemur/types/LemurUsage.java | 2 +- .../types/PurgeLemurRequestDataResponse.java | 2 +- .../resources/realtime/RealtimeClient.java | 61 ++- .../CreateRealtimeTemporaryTokenParams.java | 2 +- ...ConfigureEndUtteranceSilenceThreshold.java | 2 +- .../realtime/types/ForceEndUtterance.java | 2 +- .../realtime/types/RealtimeBaseMessage.java | 2 +- .../types/RealtimeBaseTranscript.java | 2 +- .../realtime/types/RealtimeError.java | 2 +- .../types/RealtimeTemporaryTokenResponse.java | 2 +- .../realtime/types/SessionInformation.java | 2 +- .../realtime/types/TerminateSession.java | 2 +- .../api/resources/realtime/types/Word.java | 2 +- .../transcripts/TranscriptsClient.java | 421 ++++++++++++++---- .../requests/GetSubtitlesParams.java | 4 +- .../requests/ListTranscriptParams.java | 14 +- .../requests/TranscriptParams.java | 74 +-- .../requests/WordSearchParams.java | 4 +- .../types/AutoHighlightResult.java | 2 +- .../types/AutoHighlightsResult.java | 2 +- .../resources/transcripts/types/Chapter.java | 2 +- .../transcripts/types/ContentSafetyLabel.java | 2 +- .../types/ContentSafetyLabelResult.java | 2 +- .../types/ContentSafetyLabelsResult.java | 2 +- .../resources/transcripts/types/Entity.java | 2 +- .../transcripts/types/PageDetails.java | 6 +- .../transcripts/types/ParagraphsResponse.java | 2 +- .../types/RedactedAudioResponse.java | 2 +- .../transcripts/types/SentencesResponse.java | 2 +- .../types/SentimentAnalysisResult.java | 4 +- .../types/SeverityScoreSummary.java | 2 +- .../transcripts/types/Timestamp.java | 2 +- .../types/TopicDetectionModelResult.java | 2 +- .../types/TopicDetectionResult.java | 6 +- .../types/TopicDetectionResultLabelsItem.java | 2 +- .../transcripts/types/Transcript.java | 96 ++-- .../types/TranscriptCustomSpelling.java | 2 +- .../transcripts/types/TranscriptList.java | 2 +- .../transcripts/types/TranscriptListItem.java | 4 +- .../types/TranscriptOptionalParams.java | 74 +-- .../types/TranscriptParagraph.java | 4 +- .../types/TranscriptReadyNotification.java | 2 +- .../transcripts/types/TranscriptSentence.java | 4 +- .../types/TranscriptUtterance.java | 2 +- .../transcripts/types/TranscriptWord.java | 4 +- .../transcripts/types/WordSearchMatch.java | 2 +- .../transcripts/types/WordSearchResponse.java | 2 +- .../java/com/assemblyai/api/types/Error.java | 4 +- 82 files changed, 1237 insertions(+), 457 deletions(-) delete mode 100644 src/main/java/com/assemblyai/api/core/ApiError.java create mode 100644 src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java create mode 100644 src/main/java/com/assemblyai/api/core/AssemblyAIException.java create mode 100644 src/main/java/com/assemblyai/api/core/ResponseBodyInputStream.java create mode 100644 src/main/java/com/assemblyai/api/core/ResponseBodyReader.java create mode 100644 src/main/java/com/assemblyai/api/errors/BadRequestError.java create mode 100644 src/main/java/com/assemblyai/api/errors/GatewayTimeoutError.java create mode 100644 src/main/java/com/assemblyai/api/errors/InternalServerError.java create mode 100644 src/main/java/com/assemblyai/api/errors/NotFoundError.java create mode 100644 src/main/java/com/assemblyai/api/errors/ServiceUnavailableError.java create mode 100644 src/main/java/com/assemblyai/api/errors/TooManyRequestsError.java create mode 100644 src/main/java/com/assemblyai/api/errors/UnauthorizedError.java diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f3d4ba8a0da8d277868979cfbc8ad796..2c3521197d7c4586c843d1d3e9090525f1898cde 100644 GIT binary patch delta 8703 zcmYLtRag{&)-BQ@Dc#cDDP2Q%r*wBHJ*0FE-92)X$3_b$L+F2Fa28UVeg>}yRjC}^a^+(Cdu_FTlV;w_x7ig{yd(NYi_;SHXEq`|Qa`qPMf1B~v#%<*D zn+KWJfX#=$FMopqZ>Cv7|0WiA^M(L@tZ=_Hi z*{?)#Cn^{TIzYD|H>J3dyXQCNy8f@~OAUfR*Y@C6r=~KMZ{X}q`t@Er8NRiCUcR=?Y+RMv`o0i{krhWT6XgmUt!&X=e_Q2=u@F=PXKpr9-FL@0 zfKigQcGHyPn{3vStLFk=`h@+Lh1XBNC-_nwNU{ytxZF$o}oyVfHMj|ZHWmEmZeNIlO5eLco<=RI&3=fYK*=kmv*75aqE~&GtAp(VJ z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co0_(bD$IS6l2j>%Iv^Hc)M`n-vIu;-2T+6nhW0JZxZ|NfDEh;ZnAe d|9e8rKfIInFTYPwOD9TMuEcqhmizAn{|ERF)u#Xe diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..09523c0e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 7101f8e4..9b42019c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/src/main/java/com/assemblyai/api/core/ApiError.java b/src/main/java/com/assemblyai/api/core/ApiError.java deleted file mode 100644 index 8614764f..00000000 --- a/src/main/java/com/assemblyai/api/core/ApiError.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.assemblyai.api.core; - -public final class ApiError extends RuntimeException { - private final int statusCode; - - private final Object body; - - public ApiError(int statusCode, Object body) { - this.statusCode = statusCode; - this.body = body; - } - - public int statusCode() { - return this.statusCode; - } - - public Object body() { - return this.body; - } - - @java.lang.Override - public String toString() { - return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}"; - } -} diff --git a/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java b/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java new file mode 100644 index 00000000..ee9d3d74 --- /dev/null +++ b/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.core; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class AssemblyAIApiException extends AssemblyAIException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public AssemblyAIApiException(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + @java.lang.Override + public String toString() { + return "AssemblyAIApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + + body + "}"; + } +} diff --git a/src/main/java/com/assemblyai/api/core/AssemblyAIException.java b/src/main/java/com/assemblyai/api/core/AssemblyAIException.java new file mode 100644 index 00000000..16a86da3 --- /dev/null +++ b/src/main/java/com/assemblyai/api/core/AssemblyAIException.java @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.core; + +/** + * This class serves as the base exception for all errors in the SDK. + */ +public class AssemblyAIException extends RuntimeException { + public AssemblyAIException(String message) { + super(message); + } + + public AssemblyAIException(String message, Exception e) { + super(message, e); + } +} diff --git a/src/main/java/com/assemblyai/api/core/RequestOptions.java b/src/main/java/com/assemblyai/api/core/RequestOptions.java index 8567faa6..7d0c994c 100644 --- a/src/main/java/com/assemblyai/api/core/RequestOptions.java +++ b/src/main/java/com/assemblyai/api/core/RequestOptions.java @@ -44,7 +44,7 @@ public static Builder builder() { public static final class Builder { private String apiKey = null; - private Optional timeout = null; + private Optional timeout = Optional.empty(); private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; diff --git a/src/main/java/com/assemblyai/api/core/ResponseBodyInputStream.java b/src/main/java/com/assemblyai/api/core/ResponseBodyInputStream.java new file mode 100644 index 00000000..fc601484 --- /dev/null +++ b/src/main/java/com/assemblyai/api/core/ResponseBodyInputStream.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.core; + +import java.io.FilterInputStream; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the stream is closed. + * + * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. + * It retrieves the InputStream from the Response and overrides the close method to close + * both the InputStream and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyInputStream extends FilterInputStream { + private final Response response; + + /** + * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp + * Response object. + * + * @param response the OkHttp Response object from which the InputStream is retrieved + * @throws IOException if an I/O error occurs while retrieving the InputStream + */ + public ResponseBodyInputStream(Response response) throws IOException { + super(response.body().byteStream()); + this.response = response; + } + + /** + * Closes the InputStream and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the stream is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the stream is closed + } +} diff --git a/src/main/java/com/assemblyai/api/core/ResponseBodyReader.java b/src/main/java/com/assemblyai/api/core/ResponseBodyReader.java new file mode 100644 index 00000000..1c0717d7 --- /dev/null +++ b/src/main/java/com/assemblyai/api/core/ResponseBodyReader.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.core; + +import java.io.FilterReader; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the reader is closed. + * + * This class extends FilterReader and takes an OkHttp Response object as a parameter. + * It retrieves the Reader from the Response and overrides the close method to close + * both the Reader and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyReader extends FilterReader { + private final Response response; + + /** + * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. + * + * @param response the OkHttp Response object from which the Reader is retrieved + * @throws IOException if an I/O error occurs while retrieving the Reader + */ + public ResponseBodyReader(Response response) throws IOException { + super(response.body().charStream()); + this.response = response; + } + + /** + * Closes the Reader and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the reader is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the reader is closed + } +} diff --git a/src/main/java/com/assemblyai/api/errors/BadRequestError.java b/src/main/java/com/assemblyai/api/errors/BadRequestError.java new file mode 100644 index 00000000..8d5794c7 --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/BadRequestError.java @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.types.Error; + +public final class BadRequestError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public BadRequestError(Error body) { + super("BadRequestError", 400, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/errors/GatewayTimeoutError.java b/src/main/java/com/assemblyai/api/errors/GatewayTimeoutError.java new file mode 100644 index 00000000..ec77cc15 --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/GatewayTimeoutError.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; + +public final class GatewayTimeoutError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public GatewayTimeoutError(Object body) { + super("GatewayTimeoutError", 504, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/errors/InternalServerError.java b/src/main/java/com/assemblyai/api/errors/InternalServerError.java new file mode 100644 index 00000000..279f0063 --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/InternalServerError.java @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.types.Error; + +public final class InternalServerError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public InternalServerError(Error body) { + super("InternalServerError", 500, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/errors/NotFoundError.java b/src/main/java/com/assemblyai/api/errors/NotFoundError.java new file mode 100644 index 00000000..4ae36161 --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/NotFoundError.java @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.types.Error; + +public final class NotFoundError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public NotFoundError(Error body) { + super("NotFoundError", 404, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/errors/ServiceUnavailableError.java b/src/main/java/com/assemblyai/api/errors/ServiceUnavailableError.java new file mode 100644 index 00000000..3884ff7e --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/ServiceUnavailableError.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; + +public final class ServiceUnavailableError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public ServiceUnavailableError(Object body) { + super("ServiceUnavailableError", 503, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/errors/TooManyRequestsError.java b/src/main/java/com/assemblyai/api/errors/TooManyRequestsError.java new file mode 100644 index 00000000..3d340072 --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/TooManyRequestsError.java @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.types.Error; + +public final class TooManyRequestsError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public TooManyRequestsError(Error body) { + super("TooManyRequestsError", 429, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/errors/UnauthorizedError.java b/src/main/java/com/assemblyai/api/errors/UnauthorizedError.java new file mode 100644 index 00000000..21415918 --- /dev/null +++ b/src/main/java/com/assemblyai/api/errors/UnauthorizedError.java @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.errors; + +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.types.Error; + +public final class UnauthorizedError extends AssemblyAIApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public UnauthorizedError(Error body) { + super("UnauthorizedError", 401, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/assemblyai/api/resources/files/FilesClient.java b/src/main/java/com/assemblyai/api/resources/files/FilesClient.java index 559bf06c..16650166 100644 --- a/src/main/java/com/assemblyai/api/resources/files/FilesClient.java +++ b/src/main/java/com/assemblyai/api/resources/files/FilesClient.java @@ -3,11 +3,21 @@ */ package com.assemblyai.api.resources.files; -import com.assemblyai.api.core.ApiError; +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.core.AssemblyAIException; import com.assemblyai.api.core.ClientOptions; import com.assemblyai.api.core.ObjectMappers; import com.assemblyai.api.core.RequestOptions; +import com.assemblyai.api.errors.BadRequestError; +import com.assemblyai.api.errors.GatewayTimeoutError; +import com.assemblyai.api.errors.InternalServerError; +import com.assemblyai.api.errors.NotFoundError; +import com.assemblyai.api.errors.ServiceUnavailableError; +import com.assemblyai.api.errors.TooManyRequestsError; +import com.assemblyai.api.errors.UnauthorizedError; import com.assemblyai.api.resources.files.types.UploadedFile; +import com.assemblyai.api.types.Error; +import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -46,22 +56,47 @@ public UploadedFile upload(byte[] request, RequestOptions requestOptions) { .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/octet-stream") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UploadedFile.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } } diff --git a/src/main/java/com/assemblyai/api/resources/files/types/UploadedFile.java b/src/main/java/com/assemblyai/api/resources/files/types/UploadedFile.java index bec250b5..0b6ae036 100644 --- a/src/main/java/com/assemblyai/api/resources/files/types/UploadedFile.java +++ b/src/main/java/com/assemblyai/api/resources/files/types/UploadedFile.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UploadedFile.Builder.class) public final class UploadedFile { private final String uploadUrl; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/LemurClient.java b/src/main/java/com/assemblyai/api/resources/lemur/LemurClient.java index 5a23cf0e..05b63a42 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/LemurClient.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/LemurClient.java @@ -3,11 +3,19 @@ */ package com.assemblyai.api.resources.lemur; -import com.assemblyai.api.core.ApiError; +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.core.AssemblyAIException; import com.assemblyai.api.core.ClientOptions; import com.assemblyai.api.core.MediaTypes; import com.assemblyai.api.core.ObjectMappers; import com.assemblyai.api.core.RequestOptions; +import com.assemblyai.api.errors.BadRequestError; +import com.assemblyai.api.errors.GatewayTimeoutError; +import com.assemblyai.api.errors.InternalServerError; +import com.assemblyai.api.errors.NotFoundError; +import com.assemblyai.api.errors.ServiceUnavailableError; +import com.assemblyai.api.errors.TooManyRequestsError; +import com.assemblyai.api.errors.UnauthorizedError; import com.assemblyai.api.resources.lemur.requests.LemurActionItemsParams; import com.assemblyai.api.resources.lemur.requests.LemurQuestionAnswerParams; import com.assemblyai.api.resources.lemur.requests.LemurSummaryParams; @@ -18,6 +26,8 @@ import com.assemblyai.api.resources.lemur.types.LemurSummaryResponse; import com.assemblyai.api.resources.lemur.types.LemurTaskResponse; import com.assemblyai.api.resources.lemur.types.PurgeLemurRequestDataResponse; +import com.assemblyai.api.types.Error; +import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -53,8 +63,8 @@ public LemurTaskResponse task(LemurTaskParams request, RequestOptions requestOpt try { body = RequestBody.create( ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (JsonProcessingException e) { + throw new AssemblyAIException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -62,22 +72,47 @@ public LemurTaskResponse task(LemurTaskParams request, RequestOptions requestOpt .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurTaskResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -110,8 +145,8 @@ public LemurSummaryResponse summary(LemurSummaryParams request, RequestOptions r try { body = RequestBody.create( ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (JsonProcessingException e) { + throw new AssemblyAIException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -119,22 +154,47 @@ public LemurSummaryResponse summary(LemurSummaryParams request, RequestOptions r .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurSummaryResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -160,8 +220,8 @@ public LemurQuestionAnswerResponse questionAnswer( try { body = RequestBody.create( ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (JsonProcessingException e) { + throw new AssemblyAIException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -169,22 +229,47 @@ public LemurQuestionAnswerResponse questionAnswer( .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurQuestionAnswerResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -214,8 +299,8 @@ public LemurActionItemsResponse actionItems(LemurActionItemsParams request, Requ try { body = RequestBody.create( ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (JsonProcessingException e) { + throw new AssemblyAIException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -223,22 +308,47 @@ public LemurActionItemsResponse actionItems(LemurActionItemsParams request, Requ .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurActionItemsResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -264,22 +374,47 @@ public LemurResponse getResponse(String requestId, RequestOptions requestOptions .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -307,22 +442,47 @@ public PurgeLemurRequestDataResponse purgeRequestData(String requestId, RequestO .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurgeLemurRequestDataResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurActionItemsParams.java b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurActionItemsParams.java index 8e4faf2b..fe4a061e 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurActionItemsParams.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurActionItemsParams.java @@ -21,7 +21,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurActionItemsParams.Builder.class) public final class LemurActionItemsParams implements ILemurBaseParams { private final Optional> transcriptIds; @@ -207,7 +207,7 @@ public Builder transcriptIds(Optional> transcriptIds) { } public Builder transcriptIds(List transcriptIds) { - this.transcriptIds = Optional.of(transcriptIds); + this.transcriptIds = Optional.ofNullable(transcriptIds); return this; } @@ -218,7 +218,7 @@ public Builder inputText(Optional inputText) { } public Builder inputText(String inputText) { - this.inputText = Optional.of(inputText); + this.inputText = Optional.ofNullable(inputText); return this; } @@ -229,7 +229,7 @@ public Builder context(Optional context) { } public Builder context(LemurBaseParamsContext context) { - this.context = Optional.of(context); + this.context = Optional.ofNullable(context); return this; } @@ -240,7 +240,7 @@ public Builder finalModel(Optional finalModel) { } public Builder finalModel(LemurModel finalModel) { - this.finalModel = Optional.of(finalModel); + this.finalModel = Optional.ofNullable(finalModel); return this; } @@ -251,7 +251,7 @@ public Builder maxOutputSize(Optional maxOutputSize) { } public Builder maxOutputSize(Integer maxOutputSize) { - this.maxOutputSize = Optional.of(maxOutputSize); + this.maxOutputSize = Optional.ofNullable(maxOutputSize); return this; } @@ -262,7 +262,7 @@ public Builder temperature(Optional temperature) { } public Builder temperature(Double temperature) { - this.temperature = Optional.of(temperature); + this.temperature = Optional.ofNullable(temperature); return this; } @@ -273,7 +273,7 @@ public Builder answerFormat(Optional answerFormat) { } public Builder answerFormat(String answerFormat) { - this.answerFormat = Optional.of(answerFormat); + this.answerFormat = Optional.ofNullable(answerFormat); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurQuestionAnswerParams.java b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurQuestionAnswerParams.java index a2048b16..ae9dddaf 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurQuestionAnswerParams.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurQuestionAnswerParams.java @@ -23,7 +23,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurQuestionAnswerParams.Builder.class) public final class LemurQuestionAnswerParams implements ILemurBaseParams { private final Optional> transcriptIds; @@ -208,7 +208,7 @@ public Builder transcriptIds(Optional> transcriptIds) { } public Builder transcriptIds(List transcriptIds) { - this.transcriptIds = Optional.of(transcriptIds); + this.transcriptIds = Optional.ofNullable(transcriptIds); return this; } @@ -219,7 +219,7 @@ public Builder inputText(Optional inputText) { } public Builder inputText(String inputText) { - this.inputText = Optional.of(inputText); + this.inputText = Optional.ofNullable(inputText); return this; } @@ -230,7 +230,7 @@ public Builder context(Optional context) { } public Builder context(LemurBaseParamsContext context) { - this.context = Optional.of(context); + this.context = Optional.ofNullable(context); return this; } @@ -241,7 +241,7 @@ public Builder finalModel(Optional finalModel) { } public Builder finalModel(LemurModel finalModel) { - this.finalModel = Optional.of(finalModel); + this.finalModel = Optional.ofNullable(finalModel); return this; } @@ -252,7 +252,7 @@ public Builder maxOutputSize(Optional maxOutputSize) { } public Builder maxOutputSize(Integer maxOutputSize) { - this.maxOutputSize = Optional.of(maxOutputSize); + this.maxOutputSize = Optional.ofNullable(maxOutputSize); return this; } @@ -263,7 +263,7 @@ public Builder temperature(Optional temperature) { } public Builder temperature(Double temperature) { - this.temperature = Optional.of(temperature); + this.temperature = Optional.ofNullable(temperature); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurSummaryParams.java b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurSummaryParams.java index 80c50fe2..4bf292cb 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurSummaryParams.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurSummaryParams.java @@ -21,7 +21,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurSummaryParams.Builder.class) public final class LemurSummaryParams implements ILemurBaseParams { private final Optional> transcriptIds; @@ -206,7 +206,7 @@ public Builder transcriptIds(Optional> transcriptIds) { } public Builder transcriptIds(List transcriptIds) { - this.transcriptIds = Optional.of(transcriptIds); + this.transcriptIds = Optional.ofNullable(transcriptIds); return this; } @@ -217,7 +217,7 @@ public Builder inputText(Optional inputText) { } public Builder inputText(String inputText) { - this.inputText = Optional.of(inputText); + this.inputText = Optional.ofNullable(inputText); return this; } @@ -228,7 +228,7 @@ public Builder context(Optional context) { } public Builder context(LemurBaseParamsContext context) { - this.context = Optional.of(context); + this.context = Optional.ofNullable(context); return this; } @@ -239,7 +239,7 @@ public Builder finalModel(Optional finalModel) { } public Builder finalModel(LemurModel finalModel) { - this.finalModel = Optional.of(finalModel); + this.finalModel = Optional.ofNullable(finalModel); return this; } @@ -250,7 +250,7 @@ public Builder maxOutputSize(Optional maxOutputSize) { } public Builder maxOutputSize(Integer maxOutputSize) { - this.maxOutputSize = Optional.of(maxOutputSize); + this.maxOutputSize = Optional.ofNullable(maxOutputSize); return this; } @@ -261,7 +261,7 @@ public Builder temperature(Optional temperature) { } public Builder temperature(Double temperature) { - this.temperature = Optional.of(temperature); + this.temperature = Optional.ofNullable(temperature); return this; } @@ -272,7 +272,7 @@ public Builder answerFormat(Optional answerFormat) { } public Builder answerFormat(String answerFormat) { - this.answerFormat = Optional.of(answerFormat); + this.answerFormat = Optional.ofNullable(answerFormat); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurTaskParams.java b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurTaskParams.java index c5d7cbde..7a5d6116 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurTaskParams.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/requests/LemurTaskParams.java @@ -21,7 +21,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurTaskParams.Builder.class) public final class LemurTaskParams implements ILemurBaseParams { private final Optional> transcriptIds; @@ -253,7 +253,7 @@ public _FinalStage prompt(String prompt) { */ @java.lang.Override public _FinalStage temperature(Double temperature) { - this.temperature = Optional.of(temperature); + this.temperature = Optional.ofNullable(temperature); return this; } @@ -270,7 +270,7 @@ public _FinalStage temperature(Optional temperature) { */ @java.lang.Override public _FinalStage maxOutputSize(Integer maxOutputSize) { - this.maxOutputSize = Optional.of(maxOutputSize); + this.maxOutputSize = Optional.ofNullable(maxOutputSize); return this; } @@ -287,7 +287,7 @@ public _FinalStage maxOutputSize(Optional maxOutputSize) { */ @java.lang.Override public _FinalStage finalModel(LemurModel finalModel) { - this.finalModel = Optional.of(finalModel); + this.finalModel = Optional.ofNullable(finalModel); return this; } @@ -304,7 +304,7 @@ public _FinalStage finalModel(Optional finalModel) { */ @java.lang.Override public _FinalStage context(LemurBaseParamsContext context) { - this.context = Optional.of(context); + this.context = Optional.ofNullable(context); return this; } @@ -322,7 +322,7 @@ public _FinalStage context(Optional context) { */ @java.lang.Override public _FinalStage inputText(String inputText) { - this.inputText = Optional.of(inputText); + this.inputText = Optional.ofNullable(inputText); return this; } @@ -340,7 +340,7 @@ public _FinalStage inputText(Optional inputText) { */ @java.lang.Override public _FinalStage transcriptIds(List transcriptIds) { - this.transcriptIds = Optional.of(transcriptIds); + this.transcriptIds = Optional.ofNullable(transcriptIds); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurActionItemsResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurActionItemsResponse.java index 882ff08b..9aed7930 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurActionItemsResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurActionItemsResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurActionItemsResponse.Builder.class) public final class LemurActionItemsResponse implements ILemurStringResponse { private final String response; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseParams.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseParams.java index fbf2bceb..bcd8470a 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseParams.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseParams.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurBaseParams.Builder.class) public final class LemurBaseParams implements ILemurBaseParams { private final Optional> transcriptIds; @@ -186,7 +186,7 @@ public Builder transcriptIds(Optional> transcriptIds) { } public Builder transcriptIds(List transcriptIds) { - this.transcriptIds = Optional.of(transcriptIds); + this.transcriptIds = Optional.ofNullable(transcriptIds); return this; } @@ -197,7 +197,7 @@ public Builder inputText(Optional inputText) { } public Builder inputText(String inputText) { - this.inputText = Optional.of(inputText); + this.inputText = Optional.ofNullable(inputText); return this; } @@ -208,7 +208,7 @@ public Builder context(Optional context) { } public Builder context(LemurBaseParamsContext context) { - this.context = Optional.of(context); + this.context = Optional.ofNullable(context); return this; } @@ -219,7 +219,7 @@ public Builder finalModel(Optional finalModel) { } public Builder finalModel(LemurModel finalModel) { - this.finalModel = Optional.of(finalModel); + this.finalModel = Optional.ofNullable(finalModel); return this; } @@ -230,7 +230,7 @@ public Builder maxOutputSize(Optional maxOutputSize) { } public Builder maxOutputSize(Integer maxOutputSize) { - this.maxOutputSize = Optional.of(maxOutputSize); + this.maxOutputSize = Optional.ofNullable(maxOutputSize); return this; } @@ -241,7 +241,7 @@ public Builder temperature(Optional temperature) { } public Builder temperature(Double temperature) { - this.temperature = Optional.of(temperature); + this.temperature = Optional.ofNullable(temperature); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseResponse.java index 4ddcc518..899f4fb4 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurBaseResponse.Builder.class) public final class LemurBaseResponse implements ILemurBaseResponse { private final String requestId; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurModel.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurModel.java index 9f2e0ad7..e4491ba8 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurModel.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurModel.java @@ -11,15 +11,15 @@ public final class LemurModel { public static final LemurModel ANTHROPIC_CLAUDE2 = new LemurModel(Value.ANTHROPIC_CLAUDE2, "anthropic/claude-2"); + public static final LemurModel ANTHROPIC_CLAUDE3_5_SONNET = + new LemurModel(Value.ANTHROPIC_CLAUDE3_5_SONNET, "anthropic/claude-3-5-sonnet"); + public static final LemurModel ANTHROPIC_CLAUDE3_SONNET = new LemurModel(Value.ANTHROPIC_CLAUDE3_SONNET, "anthropic/claude-3-sonnet"); public static final LemurModel ASSEMBLYAI_MISTRAL7B = new LemurModel(Value.ASSEMBLYAI_MISTRAL7B, "assemblyai/mistral-7b"); - public static final LemurModel ANTHROPIC_CLAUDE3_5_SONNET = - new LemurModel(Value.ANTHROPIC_CLAUDE3_5_SONNET, "anthropic/claude-3-5-sonnet"); - public static final LemurModel ANTHROPIC_CLAUDE3_HAIKU = new LemurModel(Value.ANTHROPIC_CLAUDE3_HAIKU, "anthropic/claude-3-haiku"); @@ -69,12 +69,12 @@ public T visit(Visitor visitor) { return visitor.visitDefault(); case ANTHROPIC_CLAUDE2: return visitor.visitAnthropicClaude2(); + case ANTHROPIC_CLAUDE3_5_SONNET: + return visitor.visitAnthropicClaude3_5_Sonnet(); case ANTHROPIC_CLAUDE3_SONNET: return visitor.visitAnthropicClaude3_Sonnet(); case ASSEMBLYAI_MISTRAL7B: return visitor.visitAssemblyaiMistral7b(); - case ANTHROPIC_CLAUDE3_5_SONNET: - return visitor.visitAnthropicClaude3_5_Sonnet(); case ANTHROPIC_CLAUDE3_HAIKU: return visitor.visitAnthropicClaude3_Haiku(); case BASIC: @@ -98,12 +98,12 @@ public static LemurModel valueOf(String value) { return DEFAULT; case "anthropic/claude-2": return ANTHROPIC_CLAUDE2; + case "anthropic/claude-3-5-sonnet": + return ANTHROPIC_CLAUDE3_5_SONNET; case "anthropic/claude-3-sonnet": return ANTHROPIC_CLAUDE3_SONNET; case "assemblyai/mistral-7b": return ASSEMBLYAI_MISTRAL7B; - case "anthropic/claude-3-5-sonnet": - return ANTHROPIC_CLAUDE3_5_SONNET; case "anthropic/claude-3-haiku": return ANTHROPIC_CLAUDE3_HAIKU; case "basic": diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestion.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestion.java index 57e39e3e..ac1857ce 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestion.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestion.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurQuestion.Builder.class) public final class LemurQuestion { private final String question; @@ -171,7 +171,7 @@ public _FinalStage question(String question) { */ @java.lang.Override public _FinalStage answerOptions(List answerOptions) { - this.answerOptions = Optional.of(answerOptions); + this.answerOptions = Optional.ofNullable(answerOptions); return this; } @@ -188,7 +188,7 @@ public _FinalStage answerOptions(Optional> answerOptions) { */ @java.lang.Override public _FinalStage answerFormat(String answerFormat) { - this.answerFormat = Optional.of(answerFormat); + this.answerFormat = Optional.ofNullable(answerFormat); return this; } @@ -205,7 +205,7 @@ public _FinalStage answerFormat(Optional answerFormat) { */ @java.lang.Override public _FinalStage context(LemurQuestionContext context) { - this.context = Optional.of(context); + this.context = Optional.ofNullable(context); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswer.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswer.java index bd6763c7..565657b0 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswer.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswer.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurQuestionAnswer.Builder.class) public final class LemurQuestionAnswer { private final String question; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswerResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswerResponse.java index a09a97d7..e4a51a1d 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswerResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurQuestionAnswerResponse.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurQuestionAnswerResponse.Builder.class) public final class LemurQuestionAnswerResponse implements ILemurBaseResponse { private final String requestId; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurStringResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurStringResponse.java index 15f20e26..9090064d 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurStringResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurStringResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurStringResponse.Builder.class) public final class LemurStringResponse implements ILemurStringResponse, ILemurBaseResponse { private final String response; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurSummaryResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurSummaryResponse.java index 999d0b3f..c778ea4a 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurSummaryResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurSummaryResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurSummaryResponse.Builder.class) public final class LemurSummaryResponse implements ILemurStringResponse { private final String response; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurTaskResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurTaskResponse.java index e1b0c715..b1c6d0b1 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurTaskResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurTaskResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurTaskResponse.Builder.class) public final class LemurTaskResponse implements ILemurStringResponse { private final String response; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurUsage.java b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurUsage.java index b1a80ac1..19d76160 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/LemurUsage.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/LemurUsage.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LemurUsage.Builder.class) public final class LemurUsage { private final int inputTokens; diff --git a/src/main/java/com/assemblyai/api/resources/lemur/types/PurgeLemurRequestDataResponse.java b/src/main/java/com/assemblyai/api/resources/lemur/types/PurgeLemurRequestDataResponse.java index 00f712bc..0a58bd96 100644 --- a/src/main/java/com/assemblyai/api/resources/lemur/types/PurgeLemurRequestDataResponse.java +++ b/src/main/java/com/assemblyai/api/resources/lemur/types/PurgeLemurRequestDataResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PurgeLemurRequestDataResponse.Builder.class) public final class PurgeLemurRequestDataResponse { private final String requestId; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/RealtimeClient.java b/src/main/java/com/assemblyai/api/resources/realtime/RealtimeClient.java index 9758a758..0dde9dc1 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/RealtimeClient.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/RealtimeClient.java @@ -3,13 +3,23 @@ */ package com.assemblyai.api.resources.realtime; -import com.assemblyai.api.core.ApiError; +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.core.AssemblyAIException; import com.assemblyai.api.core.ClientOptions; import com.assemblyai.api.core.MediaTypes; import com.assemblyai.api.core.ObjectMappers; import com.assemblyai.api.core.RequestOptions; +import com.assemblyai.api.errors.BadRequestError; +import com.assemblyai.api.errors.GatewayTimeoutError; +import com.assemblyai.api.errors.InternalServerError; +import com.assemblyai.api.errors.NotFoundError; +import com.assemblyai.api.errors.ServiceUnavailableError; +import com.assemblyai.api.errors.TooManyRequestsError; +import com.assemblyai.api.errors.UnauthorizedError; import com.assemblyai.api.resources.realtime.requests.CreateRealtimeTemporaryTokenParams; import com.assemblyai.api.resources.realtime.types.RealtimeTemporaryTokenResponse; +import com.assemblyai.api.types.Error; +import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -46,8 +56,8 @@ public RealtimeTemporaryTokenResponse createTemporaryToken( try { body = RequestBody.create( ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (JsonProcessingException e) { + throw new AssemblyAIException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -55,22 +65,47 @@ public RealtimeTemporaryTokenResponse createTemporaryToken( .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RealtimeTemporaryTokenResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } } diff --git a/src/main/java/com/assemblyai/api/resources/realtime/requests/CreateRealtimeTemporaryTokenParams.java b/src/main/java/com/assemblyai/api/resources/realtime/requests/CreateRealtimeTemporaryTokenParams.java index 8f0f9558..9462632d 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/requests/CreateRealtimeTemporaryTokenParams.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/requests/CreateRealtimeTemporaryTokenParams.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateRealtimeTemporaryTokenParams.Builder.class) public final class CreateRealtimeTemporaryTokenParams { private final int expiresIn; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/ConfigureEndUtteranceSilenceThreshold.java b/src/main/java/com/assemblyai/api/resources/realtime/types/ConfigureEndUtteranceSilenceThreshold.java index 1932fc77..8cd2a1af 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/ConfigureEndUtteranceSilenceThreshold.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/ConfigureEndUtteranceSilenceThreshold.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigureEndUtteranceSilenceThreshold.Builder.class) public final class ConfigureEndUtteranceSilenceThreshold { private final int endUtteranceSilenceThreshold; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/ForceEndUtterance.java b/src/main/java/com/assemblyai/api/resources/realtime/types/ForceEndUtterance.java index 1c3d8c4b..6407c6ba 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/ForceEndUtterance.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/ForceEndUtterance.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ForceEndUtterance.Builder.class) public final class ForceEndUtterance { private final boolean forceEndUtterance; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseMessage.java b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseMessage.java index e159c785..72eb0333 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseMessage.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseMessage.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = RealtimeBaseMessage.Builder.class) public final class RealtimeBaseMessage { private final MessageType messageType; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseTranscript.java b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseTranscript.java index 9b09a579..d1f43b2e 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseTranscript.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeBaseTranscript.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = RealtimeBaseTranscript.Builder.class) public final class RealtimeBaseTranscript implements IRealtimeBaseTranscript { private final int audioStart; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeError.java b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeError.java index 3394916a..4ff09b97 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeError.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeError.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = RealtimeError.Builder.class) public final class RealtimeError { private final String error; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeTemporaryTokenResponse.java b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeTemporaryTokenResponse.java index 1ac92dee..50d58c56 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeTemporaryTokenResponse.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/RealtimeTemporaryTokenResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = RealtimeTemporaryTokenResponse.Builder.class) public final class RealtimeTemporaryTokenResponse { private final String token; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/SessionInformation.java b/src/main/java/com/assemblyai/api/resources/realtime/types/SessionInformation.java index 44fd4e7e..05773fc9 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/SessionInformation.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/SessionInformation.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SessionInformation.Builder.class) public final class SessionInformation { private final double audioDurationSeconds; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/TerminateSession.java b/src/main/java/com/assemblyai/api/resources/realtime/types/TerminateSession.java index b9edb81c..1e61756d 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/TerminateSession.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/TerminateSession.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TerminateSession.Builder.class) public final class TerminateSession { private final boolean terminateSession; diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/Word.java b/src/main/java/com/assemblyai/api/resources/realtime/types/Word.java index e304d73f..d35a00c0 100644 --- a/src/main/java/com/assemblyai/api/resources/realtime/types/Word.java +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/Word.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Word.Builder.class) public final class Word { private final int start; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/TranscriptsClient.java b/src/main/java/com/assemblyai/api/resources/transcripts/TranscriptsClient.java index 74cbec3e..4e7a6a27 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/TranscriptsClient.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/TranscriptsClient.java @@ -3,11 +3,19 @@ */ package com.assemblyai.api.resources.transcripts; -import com.assemblyai.api.core.ApiError; +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.core.AssemblyAIException; import com.assemblyai.api.core.ClientOptions; import com.assemblyai.api.core.MediaTypes; import com.assemblyai.api.core.ObjectMappers; import com.assemblyai.api.core.RequestOptions; +import com.assemblyai.api.errors.BadRequestError; +import com.assemblyai.api.errors.GatewayTimeoutError; +import com.assemblyai.api.errors.InternalServerError; +import com.assemblyai.api.errors.NotFoundError; +import com.assemblyai.api.errors.ServiceUnavailableError; +import com.assemblyai.api.errors.TooManyRequestsError; +import com.assemblyai.api.errors.UnauthorizedError; import com.assemblyai.api.resources.transcripts.requests.GetSubtitlesParams; import com.assemblyai.api.resources.transcripts.requests.ListTranscriptParams; import com.assemblyai.api.resources.transcripts.requests.TranscriptParams; @@ -19,6 +27,8 @@ import com.assemblyai.api.resources.transcripts.types.Transcript; import com.assemblyai.api.resources.transcripts.types.TranscriptList; import com.assemblyai.api.resources.transcripts.types.WordSearchResponse; +import com.assemblyai.api.types.Error; +import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -84,22 +94,47 @@ public TranscriptList list(ListTranscriptParams request, RequestOptions requestO .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json"); Request okhttpRequest = _requestBuilder.build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TranscriptList.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -122,8 +157,8 @@ public Transcript submit(TranscriptParams request, RequestOptions requestOptions try { body = RequestBody.create( ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (JsonProcessingException e) { + throw new AssemblyAIException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -131,22 +166,47 @@ public Transcript submit(TranscriptParams request, RequestOptions requestOptions .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Transcript.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -172,22 +232,47 @@ public Transcript get(String transcriptId, RequestOptions requestOptions) { .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Transcript.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -215,22 +300,47 @@ public Transcript delete(String transcriptId, RequestOptions requestOptions) { .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Transcript.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -272,22 +382,47 @@ public String getSubtitles( .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json"); Request okhttpRequest = _requestBuilder.build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return responseBody.string(); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -314,22 +449,47 @@ public SentencesResponse getSentences(String transcriptId, RequestOptions reques .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SentencesResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -356,22 +516,47 @@ public ParagraphsResponse getParagraphs(String transcriptId, RequestOptions requ .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParagraphsResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -407,22 +592,47 @@ public WordSearchResponse wordSearch(String transcriptId, WordSearchParams reque .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json"); Request okhttpRequest = _requestBuilder.build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WordSearchResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } @@ -449,22 +659,47 @@ public RedactedAudioResponse getRedactedAudio(String transcriptId, RequestOption .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .build(); - try { - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - Response response = client.newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RedactedAudioResponse.class); } - throw new ApiError( + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 503: + throw new ServiceUnavailableError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 504: + throw new GatewayTimeoutError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new AssemblyAIApiException( + "Error with status code " + response.code(), response.code(), - ObjectMappers.JSON_MAPPER.readValue( - responseBody != null ? responseBody.string() : "{}", Object.class)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } catch (IOException e) { - throw new RuntimeException(e); + throw new AssemblyAIException("Network error executing HTTP request", e); } } } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/requests/GetSubtitlesParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/requests/GetSubtitlesParams.java index 4ac76c22..b73fc40b 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/requests/GetSubtitlesParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/requests/GetSubtitlesParams.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetSubtitlesParams.Builder.class) public final class GetSubtitlesParams { private final Optional charsPerCaption; @@ -87,7 +87,7 @@ public Builder charsPerCaption(Optional charsPerCaption) { } public Builder charsPerCaption(Integer charsPerCaption) { - this.charsPerCaption = Optional.of(charsPerCaption); + this.charsPerCaption = Optional.ofNullable(charsPerCaption); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/requests/ListTranscriptParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/requests/ListTranscriptParams.java index 7c03b822..39191237 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/requests/ListTranscriptParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/requests/ListTranscriptParams.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListTranscriptParams.Builder.class) public final class ListTranscriptParams { private final Optional limit; @@ -170,7 +170,7 @@ public Builder limit(Optional limit) { } public Builder limit(Integer limit) { - this.limit = Optional.of(limit); + this.limit = Optional.ofNullable(limit); return this; } @@ -181,7 +181,7 @@ public Builder status(Optional status) { } public Builder status(TranscriptStatus status) { - this.status = Optional.of(status); + this.status = Optional.ofNullable(status); return this; } @@ -192,7 +192,7 @@ public Builder createdOn(Optional createdOn) { } public Builder createdOn(String createdOn) { - this.createdOn = Optional.of(createdOn); + this.createdOn = Optional.ofNullable(createdOn); return this; } @@ -203,7 +203,7 @@ public Builder beforeId(Optional beforeId) { } public Builder beforeId(String beforeId) { - this.beforeId = Optional.of(beforeId); + this.beforeId = Optional.ofNullable(beforeId); return this; } @@ -214,7 +214,7 @@ public Builder afterId(Optional afterId) { } public Builder afterId(String afterId) { - this.afterId = Optional.of(afterId); + this.afterId = Optional.ofNullable(afterId); return this; } @@ -225,7 +225,7 @@ public Builder throttledOnly(Optional throttledOnly) { } public Builder throttledOnly(Boolean throttledOnly) { - this.throttledOnly = Optional.of(throttledOnly); + this.throttledOnly = Optional.ofNullable(throttledOnly); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java index c6dfd5d3..01a1f695 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java @@ -28,7 +28,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptParams.Builder.class) public final class TranscriptParams implements ITranscriptOptionalParams { private final Optional languageCode; @@ -906,7 +906,7 @@ public _FinalStage audioUrl(String audioUrl) { */ @java.lang.Override public _FinalStage topics(List topics) { - this.topics = Optional.of(topics); + this.topics = Optional.ofNullable(topics); return this; } @@ -923,7 +923,7 @@ public _FinalStage topics(Optional> topics) { */ @java.lang.Override public _FinalStage customTopics(Boolean customTopics) { - this.customTopics = Optional.of(customTopics); + this.customTopics = Optional.ofNullable(customTopics); return this; } @@ -940,7 +940,7 @@ public _FinalStage customTopics(Optional customTopics) { */ @java.lang.Override public _FinalStage summaryType(SummaryType summaryType) { - this.summaryType = Optional.of(summaryType); + this.summaryType = Optional.ofNullable(summaryType); return this; } @@ -957,7 +957,7 @@ public _FinalStage summaryType(Optional summaryType) { */ @java.lang.Override public _FinalStage summaryModel(SummaryModel summaryModel) { - this.summaryModel = Optional.of(summaryModel); + this.summaryModel = Optional.ofNullable(summaryModel); return this; } @@ -974,7 +974,7 @@ public _FinalStage summaryModel(Optional summaryModel) { */ @java.lang.Override public _FinalStage summarization(Boolean summarization) { - this.summarization = Optional.of(summarization); + this.summarization = Optional.ofNullable(summarization); return this; } @@ -992,7 +992,7 @@ public _FinalStage summarization(Optional summarization) { */ @java.lang.Override public _FinalStage speechThreshold(Double speechThreshold) { - this.speechThreshold = Optional.of(speechThreshold); + this.speechThreshold = Optional.ofNullable(speechThreshold); return this; } @@ -1009,7 +1009,7 @@ public _FinalStage speechThreshold(Optional speechThreshold) { */ @java.lang.Override public _FinalStage entityDetection(Boolean entityDetection) { - this.entityDetection = Optional.of(entityDetection); + this.entityDetection = Optional.ofNullable(entityDetection); return this; } @@ -1026,7 +1026,7 @@ public _FinalStage entityDetection(Optional entityDetection) { */ @java.lang.Override public _FinalStage autoChapters(Boolean autoChapters) { - this.autoChapters = Optional.of(autoChapters); + this.autoChapters = Optional.ofNullable(autoChapters); return this; } @@ -1043,7 +1043,7 @@ public _FinalStage autoChapters(Optional autoChapters) { */ @java.lang.Override public _FinalStage sentimentAnalysis(Boolean sentimentAnalysis) { - this.sentimentAnalysis = Optional.of(sentimentAnalysis); + this.sentimentAnalysis = Optional.ofNullable(sentimentAnalysis); return this; } @@ -1060,7 +1060,7 @@ public _FinalStage sentimentAnalysis(Optional sentimentAnalysis) { */ @java.lang.Override public _FinalStage disfluencies(Boolean disfluencies) { - this.disfluencies = Optional.of(disfluencies); + this.disfluencies = Optional.ofNullable(disfluencies); return this; } @@ -1077,7 +1077,7 @@ public _FinalStage disfluencies(Optional disfluencies) { */ @java.lang.Override public _FinalStage customSpelling(List customSpelling) { - this.customSpelling = Optional.of(customSpelling); + this.customSpelling = Optional.ofNullable(customSpelling); return this; } @@ -1094,7 +1094,7 @@ public _FinalStage customSpelling(Optional> custo */ @java.lang.Override public _FinalStage languageDetection(Boolean languageDetection) { - this.languageDetection = Optional.of(languageDetection); + this.languageDetection = Optional.ofNullable(languageDetection); return this; } @@ -1111,7 +1111,7 @@ public _FinalStage languageDetection(Optional languageDetection) { */ @java.lang.Override public _FinalStage iabCategories(Boolean iabCategories) { - this.iabCategories = Optional.of(iabCategories); + this.iabCategories = Optional.ofNullable(iabCategories); return this; } @@ -1128,7 +1128,7 @@ public _FinalStage iabCategories(Optional iabCategories) { */ @java.lang.Override public _FinalStage contentSafetyConfidence(Integer contentSafetyConfidence) { - this.contentSafetyConfidence = Optional.of(contentSafetyConfidence); + this.contentSafetyConfidence = Optional.ofNullable(contentSafetyConfidence); return this; } @@ -1145,7 +1145,7 @@ public _FinalStage contentSafetyConfidence(Optional contentSafetyConfid */ @java.lang.Override public _FinalStage contentSafety(Boolean contentSafety) { - this.contentSafety = Optional.of(contentSafety); + this.contentSafety = Optional.ofNullable(contentSafety); return this; } @@ -1162,7 +1162,7 @@ public _FinalStage contentSafety(Optional contentSafety) { */ @java.lang.Override public _FinalStage speakersExpected(Integer speakersExpected) { - this.speakersExpected = Optional.of(speakersExpected); + this.speakersExpected = Optional.ofNullable(speakersExpected); return this; } @@ -1179,7 +1179,7 @@ public _FinalStage speakersExpected(Optional speakersExpected) { */ @java.lang.Override public _FinalStage speakerLabels(Boolean speakerLabels) { - this.speakerLabels = Optional.of(speakerLabels); + this.speakerLabels = Optional.ofNullable(speakerLabels); return this; } @@ -1192,7 +1192,7 @@ public _FinalStage speakerLabels(Optional speakerLabels) { @java.lang.Override public _FinalStage redactPiiSub(SubstitutionPolicy redactPiiSub) { - this.redactPiiSub = Optional.of(redactPiiSub); + this.redactPiiSub = Optional.ofNullable(redactPiiSub); return this; } @@ -1209,7 +1209,7 @@ public _FinalStage redactPiiSub(Optional redactPiiSub) { */ @java.lang.Override public _FinalStage redactPiiPolicies(List redactPiiPolicies) { - this.redactPiiPolicies = Optional.of(redactPiiPolicies); + this.redactPiiPolicies = Optional.ofNullable(redactPiiPolicies); return this; } @@ -1226,7 +1226,7 @@ public _FinalStage redactPiiPolicies(Optional> redactPiiPolicies */ @java.lang.Override public _FinalStage redactPiiAudioQuality(RedactPiiAudioQuality redactPiiAudioQuality) { - this.redactPiiAudioQuality = Optional.of(redactPiiAudioQuality); + this.redactPiiAudioQuality = Optional.ofNullable(redactPiiAudioQuality); return this; } @@ -1243,7 +1243,7 @@ public _FinalStage redactPiiAudioQuality(Optional redactP */ @java.lang.Override public _FinalStage redactPiiAudio(Boolean redactPiiAudio) { - this.redactPiiAudio = Optional.of(redactPiiAudio); + this.redactPiiAudio = Optional.ofNullable(redactPiiAudio); return this; } @@ -1260,7 +1260,7 @@ public _FinalStage redactPiiAudio(Optional redactPiiAudio) { */ @java.lang.Override public _FinalStage redactPii(Boolean redactPii) { - this.redactPii = Optional.of(redactPii); + this.redactPii = Optional.ofNullable(redactPii); return this; } @@ -1277,7 +1277,7 @@ public _FinalStage redactPii(Optional redactPii) { */ @java.lang.Override public _FinalStage filterProfanity(Boolean filterProfanity) { - this.filterProfanity = Optional.of(filterProfanity); + this.filterProfanity = Optional.ofNullable(filterProfanity); return this; } @@ -1294,7 +1294,7 @@ public _FinalStage filterProfanity(Optional filterProfanity) { */ @java.lang.Override public _FinalStage boostParam(TranscriptBoostParam boostParam) { - this.boostParam = Optional.of(boostParam); + this.boostParam = Optional.ofNullable(boostParam); return this; } @@ -1311,7 +1311,7 @@ public _FinalStage boostParam(Optional boostParam) { */ @java.lang.Override public _FinalStage wordBoost(List wordBoost) { - this.wordBoost = Optional.of(wordBoost); + this.wordBoost = Optional.ofNullable(wordBoost); return this; } @@ -1328,7 +1328,7 @@ public _FinalStage wordBoost(Optional> wordBoost) { */ @java.lang.Override public _FinalStage audioEndAt(Integer audioEndAt) { - this.audioEndAt = Optional.of(audioEndAt); + this.audioEndAt = Optional.ofNullable(audioEndAt); return this; } @@ -1345,7 +1345,7 @@ public _FinalStage audioEndAt(Optional audioEndAt) { */ @java.lang.Override public _FinalStage audioStartFrom(Integer audioStartFrom) { - this.audioStartFrom = Optional.of(audioStartFrom); + this.audioStartFrom = Optional.ofNullable(audioStartFrom); return this; } @@ -1362,7 +1362,7 @@ public _FinalStage audioStartFrom(Optional audioStartFrom) { */ @java.lang.Override public _FinalStage autoHighlights(Boolean autoHighlights) { - this.autoHighlights = Optional.of(autoHighlights); + this.autoHighlights = Optional.ofNullable(autoHighlights); return this; } @@ -1379,7 +1379,7 @@ public _FinalStage autoHighlights(Optional autoHighlights) { */ @java.lang.Override public _FinalStage webhookAuthHeaderValue(String webhookAuthHeaderValue) { - this.webhookAuthHeaderValue = Optional.of(webhookAuthHeaderValue); + this.webhookAuthHeaderValue = Optional.ofNullable(webhookAuthHeaderValue); return this; } @@ -1396,7 +1396,7 @@ public _FinalStage webhookAuthHeaderValue(Optional webhookAuthHeaderValu */ @java.lang.Override public _FinalStage webhookAuthHeaderName(String webhookAuthHeaderName) { - this.webhookAuthHeaderName = Optional.of(webhookAuthHeaderName); + this.webhookAuthHeaderName = Optional.ofNullable(webhookAuthHeaderName); return this; } @@ -1413,7 +1413,7 @@ public _FinalStage webhookAuthHeaderName(Optional webhookAuthHeaderName) */ @java.lang.Override public _FinalStage webhookUrl(String webhookUrl) { - this.webhookUrl = Optional.of(webhookUrl); + this.webhookUrl = Optional.ofNullable(webhookUrl); return this; } @@ -1426,7 +1426,7 @@ public _FinalStage webhookUrl(Optional webhookUrl) { @java.lang.Override public _FinalStage speechModel(SpeechModel speechModel) { - this.speechModel = Optional.of(speechModel); + this.speechModel = Optional.ofNullable(speechModel); return this; } @@ -1443,7 +1443,7 @@ public _FinalStage speechModel(Optional speechModel) { */ @java.lang.Override public _FinalStage dualChannel(Boolean dualChannel) { - this.dualChannel = Optional.of(dualChannel); + this.dualChannel = Optional.ofNullable(dualChannel); return this; } @@ -1460,7 +1460,7 @@ public _FinalStage dualChannel(Optional dualChannel) { */ @java.lang.Override public _FinalStage formatText(Boolean formatText) { - this.formatText = Optional.of(formatText); + this.formatText = Optional.ofNullable(formatText); return this; } @@ -1477,7 +1477,7 @@ public _FinalStage formatText(Optional formatText) { */ @java.lang.Override public _FinalStage punctuate(Boolean punctuate) { - this.punctuate = Optional.of(punctuate); + this.punctuate = Optional.ofNullable(punctuate); return this; } @@ -1490,7 +1490,7 @@ public _FinalStage punctuate(Optional punctuate) { @java.lang.Override public _FinalStage languageCode(TranscriptLanguageCode languageCode) { - this.languageCode = Optional.of(languageCode); + this.languageCode = Optional.ofNullable(languageCode); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/requests/WordSearchParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/requests/WordSearchParams.java index 6535e611..e298f065 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/requests/WordSearchParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/requests/WordSearchParams.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = WordSearchParams.Builder.class) public final class WordSearchParams { private final Optional words; @@ -87,7 +87,7 @@ public Builder words(Optional words) { } public Builder words(String words) { - this.words = Optional.of(words); + this.words = Optional.ofNullable(words); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightResult.java index 9e450c09..3d1de8e8 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightResult.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AutoHighlightResult.Builder.class) public final class AutoHighlightResult { private final int count; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightsResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightsResult.java index d10bf7a3..18966b5e 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightsResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/AutoHighlightsResult.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AutoHighlightsResult.Builder.class) public final class AutoHighlightsResult { private final AudioIntelligenceModelStatus status; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/Chapter.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/Chapter.java index 93f7f2c3..c5ac605a 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/Chapter.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/Chapter.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Chapter.Builder.class) public final class Chapter { private final String gist; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabel.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabel.java index 4346b00f..ac64e0cb 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabel.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabel.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContentSafetyLabel.Builder.class) public final class ContentSafetyLabel { private final String label; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelResult.java index c49629c4..7e5239c1 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelResult.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContentSafetyLabelResult.Builder.class) public final class ContentSafetyLabelResult { private final String text; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelsResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelsResult.java index cd050525..0ea3051e 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelsResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/ContentSafetyLabelsResult.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContentSafetyLabelsResult.Builder.class) public final class ContentSafetyLabelsResult { private final AudioIntelligenceModelStatus status; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/Entity.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/Entity.java index a946f0aa..e0363a32 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/Entity.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/Entity.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Entity.Builder.class) public final class Entity { private final EntityType entityType; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/PageDetails.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/PageDetails.java index 327c9f17..a32f3c77 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/PageDetails.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/PageDetails.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PageDetails.Builder.class) public final class PageDetails { private final int limit; @@ -212,7 +212,7 @@ public _FinalStage currentUrl(String currentUrl) { */ @java.lang.Override public _FinalStage nextUrl(String nextUrl) { - this.nextUrl = Optional.of(nextUrl); + this.nextUrl = Optional.ofNullable(nextUrl); return this; } @@ -229,7 +229,7 @@ public _FinalStage nextUrl(Optional nextUrl) { */ @java.lang.Override public _FinalStage prevUrl(String prevUrl) { - this.prevUrl = Optional.of(prevUrl); + this.prevUrl = Optional.ofNullable(prevUrl); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java index 3890a97d..0722070b 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ParagraphsResponse.Builder.class) public final class ParagraphsResponse { private final String id; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/RedactedAudioResponse.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/RedactedAudioResponse.java index 49a18f31..0e7d0028 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/RedactedAudioResponse.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/RedactedAudioResponse.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = RedactedAudioResponse.Builder.class) public final class RedactedAudioResponse { private final String status; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java index 18295bbf..8149a139 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SentencesResponse.Builder.class) public final class SentencesResponse { private final String id; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/SentimentAnalysisResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/SentimentAnalysisResult.java index 07df3043..aabe4072 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/SentimentAnalysisResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/SentimentAnalysisResult.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SentimentAnalysisResult.Builder.class) public final class SentimentAnalysisResult { private final String text; @@ -255,7 +255,7 @@ public _FinalStage confidence(double confidence) { */ @java.lang.Override public _FinalStage speaker(String speaker) { - this.speaker = Optional.of(speaker); + this.speaker = Optional.ofNullable(speaker); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/SeverityScoreSummary.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/SeverityScoreSummary.java index 3737c130..239835e5 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/SeverityScoreSummary.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/SeverityScoreSummary.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SeverityScoreSummary.Builder.class) public final class SeverityScoreSummary { private final double low; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/Timestamp.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/Timestamp.java index 87e34198..2d408037 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/Timestamp.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/Timestamp.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Timestamp.Builder.class) public final class Timestamp { private final int start; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionModelResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionModelResult.java index c1e14eb8..6dc59595 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionModelResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionModelResult.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TopicDetectionModelResult.Builder.class) public final class TopicDetectionModelResult { private final AudioIntelligenceModelStatus status; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResult.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResult.java index b7fe01c0..54fbe14c 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResult.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResult.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TopicDetectionResult.Builder.class) public final class TopicDetectionResult { private final String text; @@ -139,7 +139,7 @@ public _FinalStage text(String text) { @java.lang.Override public _FinalStage timestamp(Timestamp timestamp) { - this.timestamp = Optional.of(timestamp); + this.timestamp = Optional.ofNullable(timestamp); return this; } @@ -152,7 +152,7 @@ public _FinalStage timestamp(Optional timestamp) { @java.lang.Override public _FinalStage labels(List labels) { - this.labels = Optional.of(labels); + this.labels = Optional.ofNullable(labels); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResultLabelsItem.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResultLabelsItem.java index 10c22b9a..ecf37434 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResultLabelsItem.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TopicDetectionResultLabelsItem.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TopicDetectionResultLabelsItem.Builder.class) public final class TopicDetectionResultLabelsItem { private final double relevance; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java index 2ee86b40..13fead01 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Transcript.Builder.class) public final class Transcript { private final String id; @@ -1362,7 +1362,7 @@ public _FinalStage summarization(boolean summarization) { */ @java.lang.Override public _FinalStage error(String error) { - this.error = Optional.of(error); + this.error = Optional.ofNullable(error); return this; } @@ -1379,7 +1379,7 @@ public _FinalStage error(Optional error) { */ @java.lang.Override public _FinalStage throttled(Boolean throttled) { - this.throttled = Optional.of(throttled); + this.throttled = Optional.ofNullable(throttled); return this; } @@ -1397,7 +1397,7 @@ public _FinalStage throttled(Optional throttled) { */ @java.lang.Override public _FinalStage speechThreshold(Double speechThreshold) { - this.speechThreshold = Optional.of(speechThreshold); + this.speechThreshold = Optional.ofNullable(speechThreshold); return this; } @@ -1415,7 +1415,7 @@ public _FinalStage speechThreshold(Optional speechThreshold) { */ @java.lang.Override public _FinalStage entities(List entities) { - this.entities = Optional.of(entities); + this.entities = Optional.ofNullable(entities); return this; } @@ -1432,7 +1432,7 @@ public _FinalStage entities(Optional> entities) { */ @java.lang.Override public _FinalStage entityDetection(Boolean entityDetection) { - this.entityDetection = Optional.of(entityDetection); + this.entityDetection = Optional.ofNullable(entityDetection); return this; } @@ -1450,7 +1450,7 @@ public _FinalStage entityDetection(Optional entityDetection) { */ @java.lang.Override public _FinalStage sentimentAnalysisResults(List sentimentAnalysisResults) { - this.sentimentAnalysisResults = Optional.of(sentimentAnalysisResults); + this.sentimentAnalysisResults = Optional.ofNullable(sentimentAnalysisResults); return this; } @@ -1467,7 +1467,7 @@ public _FinalStage sentimentAnalysisResults(Optional sentimentAnalysis) { */ @java.lang.Override public _FinalStage disfluencies(Boolean disfluencies) { - this.disfluencies = Optional.of(disfluencies); + this.disfluencies = Optional.ofNullable(disfluencies); return this; } @@ -1501,7 +1501,7 @@ public _FinalStage disfluencies(Optional disfluencies) { */ @java.lang.Override public _FinalStage topics(List topics) { - this.topics = Optional.of(topics); + this.topics = Optional.ofNullable(topics); return this; } @@ -1518,7 +1518,7 @@ public _FinalStage topics(Optional> topics) { */ @java.lang.Override public _FinalStage customTopics(Boolean customTopics) { - this.customTopics = Optional.of(customTopics); + this.customTopics = Optional.ofNullable(customTopics); return this; } @@ -1535,7 +1535,7 @@ public _FinalStage customTopics(Optional customTopics) { */ @java.lang.Override public _FinalStage summary(String summary) { - this.summary = Optional.of(summary); + this.summary = Optional.ofNullable(summary); return this; } @@ -1553,7 +1553,7 @@ public _FinalStage summary(Optional summary) { */ @java.lang.Override public _FinalStage summaryModel(String summaryModel) { - this.summaryModel = Optional.of(summaryModel); + this.summaryModel = Optional.ofNullable(summaryModel); return this; } @@ -1570,7 +1570,7 @@ public _FinalStage summaryModel(Optional summaryModel) { */ @java.lang.Override public _FinalStage summaryType(String summaryType) { - this.summaryType = Optional.of(summaryType); + this.summaryType = Optional.ofNullable(summaryType); return this; } @@ -1587,7 +1587,7 @@ public _FinalStage summaryType(Optional summaryType) { */ @java.lang.Override public _FinalStage chapters(List chapters) { - this.chapters = Optional.of(chapters); + this.chapters = Optional.ofNullable(chapters); return this; } @@ -1604,7 +1604,7 @@ public _FinalStage chapters(Optional> chapters) { */ @java.lang.Override public _FinalStage autoChapters(Boolean autoChapters) { - this.autoChapters = Optional.of(autoChapters); + this.autoChapters = Optional.ofNullable(autoChapters); return this; } @@ -1621,7 +1621,7 @@ public _FinalStage autoChapters(Optional autoChapters) { */ @java.lang.Override public _FinalStage customSpelling(List customSpelling) { - this.customSpelling = Optional.of(customSpelling); + this.customSpelling = Optional.ofNullable(customSpelling); return this; } @@ -1638,7 +1638,7 @@ public _FinalStage customSpelling(Optional> custo */ @java.lang.Override public _FinalStage languageDetection(Boolean languageDetection) { - this.languageDetection = Optional.of(languageDetection); + this.languageDetection = Optional.ofNullable(languageDetection); return this; } @@ -1651,7 +1651,7 @@ public _FinalStage languageDetection(Optional languageDetection) { @java.lang.Override public _FinalStage iabCategoriesResult(TopicDetectionModelResult iabCategoriesResult) { - this.iabCategoriesResult = Optional.of(iabCategoriesResult); + this.iabCategoriesResult = Optional.ofNullable(iabCategoriesResult); return this; } @@ -1668,7 +1668,7 @@ public _FinalStage iabCategoriesResult(Optional iabCa */ @java.lang.Override public _FinalStage iabCategories(Boolean iabCategories) { - this.iabCategories = Optional.of(iabCategories); + this.iabCategories = Optional.ofNullable(iabCategories); return this; } @@ -1681,7 +1681,7 @@ public _FinalStage iabCategories(Optional iabCategories) { @java.lang.Override public _FinalStage contentSafetyLabels(ContentSafetyLabelsResult contentSafetyLabels) { - this.contentSafetyLabels = Optional.of(contentSafetyLabels); + this.contentSafetyLabels = Optional.ofNullable(contentSafetyLabels); return this; } @@ -1698,7 +1698,7 @@ public _FinalStage contentSafetyLabels(Optional conte */ @java.lang.Override public _FinalStage contentSafety(Boolean contentSafety) { - this.contentSafety = Optional.of(contentSafety); + this.contentSafety = Optional.ofNullable(contentSafety); return this; } @@ -1715,7 +1715,7 @@ public _FinalStage contentSafety(Optional contentSafety) { */ @java.lang.Override public _FinalStage speakersExpected(Integer speakersExpected) { - this.speakersExpected = Optional.of(speakersExpected); + this.speakersExpected = Optional.ofNullable(speakersExpected); return this; } @@ -1732,7 +1732,7 @@ public _FinalStage speakersExpected(Optional speakersExpected) { */ @java.lang.Override public _FinalStage speakerLabels(Boolean speakerLabels) { - this.speakerLabels = Optional.of(speakerLabels); + this.speakerLabels = Optional.ofNullable(speakerLabels); return this; } @@ -1749,7 +1749,7 @@ public _FinalStage speakerLabels(Optional speakerLabels) { */ @java.lang.Override public _FinalStage redactPiiSub(SubstitutionPolicy redactPiiSub) { - this.redactPiiSub = Optional.of(redactPiiSub); + this.redactPiiSub = Optional.ofNullable(redactPiiSub); return this; } @@ -1767,7 +1767,7 @@ public _FinalStage redactPiiSub(Optional redactPiiSub) { */ @java.lang.Override public _FinalStage redactPiiPolicies(List redactPiiPolicies) { - this.redactPiiPolicies = Optional.of(redactPiiPolicies); + this.redactPiiPolicies = Optional.ofNullable(redactPiiPolicies); return this; } @@ -1780,7 +1780,7 @@ public _FinalStage redactPiiPolicies(Optional> redactPiiPolicies @java.lang.Override public _FinalStage redactPiiAudioQuality(RedactPiiAudioQuality redactPiiAudioQuality) { - this.redactPiiAudioQuality = Optional.of(redactPiiAudioQuality); + this.redactPiiAudioQuality = Optional.ofNullable(redactPiiAudioQuality); return this; } @@ -1798,7 +1798,7 @@ public _FinalStage redactPiiAudioQuality(Optional redactP */ @java.lang.Override public _FinalStage redactPiiAudio(Boolean redactPiiAudio) { - this.redactPiiAudio = Optional.of(redactPiiAudio); + this.redactPiiAudio = Optional.ofNullable(redactPiiAudio); return this; } @@ -1815,7 +1815,7 @@ public _FinalStage redactPiiAudio(Optional redactPiiAudio) { */ @java.lang.Override public _FinalStage filterProfanity(Boolean filterProfanity) { - this.filterProfanity = Optional.of(filterProfanity); + this.filterProfanity = Optional.ofNullable(filterProfanity); return this; } @@ -1832,7 +1832,7 @@ public _FinalStage filterProfanity(Optional filterProfanity) { */ @java.lang.Override public _FinalStage boostParam(String boostParam) { - this.boostParam = Optional.of(boostParam); + this.boostParam = Optional.ofNullable(boostParam); return this; } @@ -1849,7 +1849,7 @@ public _FinalStage boostParam(Optional boostParam) { */ @java.lang.Override public _FinalStage wordBoost(List wordBoost) { - this.wordBoost = Optional.of(wordBoost); + this.wordBoost = Optional.ofNullable(wordBoost); return this; } @@ -1866,7 +1866,7 @@ public _FinalStage wordBoost(Optional> wordBoost) { */ @java.lang.Override public _FinalStage audioEndAt(Integer audioEndAt) { - this.audioEndAt = Optional.of(audioEndAt); + this.audioEndAt = Optional.ofNullable(audioEndAt); return this; } @@ -1883,7 +1883,7 @@ public _FinalStage audioEndAt(Optional audioEndAt) { */ @java.lang.Override public _FinalStage audioStartFrom(Integer audioStartFrom) { - this.audioStartFrom = Optional.of(audioStartFrom); + this.audioStartFrom = Optional.ofNullable(audioStartFrom); return this; } @@ -1896,7 +1896,7 @@ public _FinalStage audioStartFrom(Optional audioStartFrom) { @java.lang.Override public _FinalStage autoHighlightsResult(AutoHighlightsResult autoHighlightsResult) { - this.autoHighlightsResult = Optional.of(autoHighlightsResult); + this.autoHighlightsResult = Optional.ofNullable(autoHighlightsResult); return this; } @@ -1913,7 +1913,7 @@ public _FinalStage autoHighlightsResult(Optional autoHighl */ @java.lang.Override public _FinalStage speedBoost(Boolean speedBoost) { - this.speedBoost = Optional.of(speedBoost); + this.speedBoost = Optional.ofNullable(speedBoost); return this; } @@ -1930,7 +1930,7 @@ public _FinalStage speedBoost(Optional speedBoost) { */ @java.lang.Override public _FinalStage webhookAuthHeaderName(String webhookAuthHeaderName) { - this.webhookAuthHeaderName = Optional.of(webhookAuthHeaderName); + this.webhookAuthHeaderName = Optional.ofNullable(webhookAuthHeaderName); return this; } @@ -1947,7 +1947,7 @@ public _FinalStage webhookAuthHeaderName(Optional webhookAuthHeaderName) */ @java.lang.Override public _FinalStage webhookStatusCode(Integer webhookStatusCode) { - this.webhookStatusCode = Optional.of(webhookStatusCode); + this.webhookStatusCode = Optional.ofNullable(webhookStatusCode); return this; } @@ -1966,7 +1966,7 @@ public _FinalStage webhookStatusCode(Optional webhookStatusCode) { */ @java.lang.Override public _FinalStage webhookUrl(String webhookUrl) { - this.webhookUrl = Optional.of(webhookUrl); + this.webhookUrl = Optional.ofNullable(webhookUrl); return this; } @@ -1979,7 +1979,7 @@ public _FinalStage webhookUrl(Optional webhookUrl) { @java.lang.Override public _FinalStage speechModel(SpeechModel speechModel) { - this.speechModel = Optional.of(speechModel); + this.speechModel = Optional.ofNullable(speechModel); return this; } @@ -1996,7 +1996,7 @@ public _FinalStage speechModel(Optional speechModel) { */ @java.lang.Override public _FinalStage dualChannel(Boolean dualChannel) { - this.dualChannel = Optional.of(dualChannel); + this.dualChannel = Optional.ofNullable(dualChannel); return this; } @@ -2013,7 +2013,7 @@ public _FinalStage dualChannel(Optional dualChannel) { */ @java.lang.Override public _FinalStage formatText(Boolean formatText) { - this.formatText = Optional.of(formatText); + this.formatText = Optional.ofNullable(formatText); return this; } @@ -2030,7 +2030,7 @@ public _FinalStage formatText(Optional formatText) { */ @java.lang.Override public _FinalStage punctuate(Boolean punctuate) { - this.punctuate = Optional.of(punctuate); + this.punctuate = Optional.ofNullable(punctuate); return this; } @@ -2047,7 +2047,7 @@ public _FinalStage punctuate(Optional punctuate) { */ @java.lang.Override public _FinalStage audioDuration(Integer audioDuration) { - this.audioDuration = Optional.of(audioDuration); + this.audioDuration = Optional.ofNullable(audioDuration); return this; } @@ -2064,7 +2064,7 @@ public _FinalStage audioDuration(Optional audioDuration) { */ @java.lang.Override public _FinalStage confidence(Double confidence) { - this.confidence = Optional.of(confidence); + this.confidence = Optional.ofNullable(confidence); return this; } @@ -2082,7 +2082,7 @@ public _FinalStage confidence(Optional confidence) { */ @java.lang.Override public _FinalStage utterances(List utterances) { - this.utterances = Optional.of(utterances); + this.utterances = Optional.ofNullable(utterances); return this; } @@ -2100,7 +2100,7 @@ public _FinalStage utterances(Optional> utterances) { */ @java.lang.Override public _FinalStage words(List words) { - this.words = Optional.of(words); + this.words = Optional.ofNullable(words); return this; } @@ -2117,7 +2117,7 @@ public _FinalStage words(Optional> words) { */ @java.lang.Override public _FinalStage text(String text) { - this.text = Optional.of(text); + this.text = Optional.ofNullable(text); return this; } @@ -2136,7 +2136,7 @@ public _FinalStage text(Optional text) { */ @java.lang.Override public _FinalStage languageCode(TranscriptLanguageCode languageCode) { - this.languageCode = Optional.of(languageCode); + this.languageCode = Optional.ofNullable(languageCode); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptCustomSpelling.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptCustomSpelling.java index de9492b2..78fc5b7b 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptCustomSpelling.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptCustomSpelling.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptCustomSpelling.Builder.class) public final class TranscriptCustomSpelling { private final List from; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptList.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptList.java index b7e75e7f..6ee8c77c 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptList.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptList.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptList.Builder.class) public final class TranscriptList { private final PageDetails pageDetails; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptListItem.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptListItem.java index 5a11891c..73da374b 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptListItem.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptListItem.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptListItem.Builder.class) public final class TranscriptListItem { private final String id; @@ -252,7 +252,7 @@ public _FinalStage audioUrl(String audioUrl) { */ @java.lang.Override public _FinalStage error(String error) { - this.error = Optional.of(error); + this.error = Optional.ofNullable(error); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java index 9225f696..b2f266fa 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptOptionalParams.Builder.class) public final class TranscriptOptionalParams implements ITranscriptOptionalParams { private final Optional languageCode; @@ -714,7 +714,7 @@ public Builder languageCode(Optional languageCode) { } public Builder languageCode(TranscriptLanguageCode languageCode) { - this.languageCode = Optional.of(languageCode); + this.languageCode = Optional.ofNullable(languageCode); return this; } @@ -725,7 +725,7 @@ public Builder punctuate(Optional punctuate) { } public Builder punctuate(Boolean punctuate) { - this.punctuate = Optional.of(punctuate); + this.punctuate = Optional.ofNullable(punctuate); return this; } @@ -736,7 +736,7 @@ public Builder formatText(Optional formatText) { } public Builder formatText(Boolean formatText) { - this.formatText = Optional.of(formatText); + this.formatText = Optional.ofNullable(formatText); return this; } @@ -747,7 +747,7 @@ public Builder dualChannel(Optional dualChannel) { } public Builder dualChannel(Boolean dualChannel) { - this.dualChannel = Optional.of(dualChannel); + this.dualChannel = Optional.ofNullable(dualChannel); return this; } @@ -758,7 +758,7 @@ public Builder speechModel(Optional speechModel) { } public Builder speechModel(SpeechModel speechModel) { - this.speechModel = Optional.of(speechModel); + this.speechModel = Optional.ofNullable(speechModel); return this; } @@ -769,7 +769,7 @@ public Builder webhookUrl(Optional webhookUrl) { } public Builder webhookUrl(String webhookUrl) { - this.webhookUrl = Optional.of(webhookUrl); + this.webhookUrl = Optional.ofNullable(webhookUrl); return this; } @@ -780,7 +780,7 @@ public Builder webhookAuthHeaderName(Optional webhookAuthHeaderName) { } public Builder webhookAuthHeaderName(String webhookAuthHeaderName) { - this.webhookAuthHeaderName = Optional.of(webhookAuthHeaderName); + this.webhookAuthHeaderName = Optional.ofNullable(webhookAuthHeaderName); return this; } @@ -791,7 +791,7 @@ public Builder webhookAuthHeaderValue(Optional webhookAuthHeaderValue) { } public Builder webhookAuthHeaderValue(String webhookAuthHeaderValue) { - this.webhookAuthHeaderValue = Optional.of(webhookAuthHeaderValue); + this.webhookAuthHeaderValue = Optional.ofNullable(webhookAuthHeaderValue); return this; } @@ -802,7 +802,7 @@ public Builder autoHighlights(Optional autoHighlights) { } public Builder autoHighlights(Boolean autoHighlights) { - this.autoHighlights = Optional.of(autoHighlights); + this.autoHighlights = Optional.ofNullable(autoHighlights); return this; } @@ -813,7 +813,7 @@ public Builder audioStartFrom(Optional audioStartFrom) { } public Builder audioStartFrom(Integer audioStartFrom) { - this.audioStartFrom = Optional.of(audioStartFrom); + this.audioStartFrom = Optional.ofNullable(audioStartFrom); return this; } @@ -824,7 +824,7 @@ public Builder audioEndAt(Optional audioEndAt) { } public Builder audioEndAt(Integer audioEndAt) { - this.audioEndAt = Optional.of(audioEndAt); + this.audioEndAt = Optional.ofNullable(audioEndAt); return this; } @@ -835,7 +835,7 @@ public Builder wordBoost(Optional> wordBoost) { } public Builder wordBoost(List wordBoost) { - this.wordBoost = Optional.of(wordBoost); + this.wordBoost = Optional.ofNullable(wordBoost); return this; } @@ -846,7 +846,7 @@ public Builder boostParam(Optional boostParam) { } public Builder boostParam(TranscriptBoostParam boostParam) { - this.boostParam = Optional.of(boostParam); + this.boostParam = Optional.ofNullable(boostParam); return this; } @@ -857,7 +857,7 @@ public Builder filterProfanity(Optional filterProfanity) { } public Builder filterProfanity(Boolean filterProfanity) { - this.filterProfanity = Optional.of(filterProfanity); + this.filterProfanity = Optional.ofNullable(filterProfanity); return this; } @@ -868,7 +868,7 @@ public Builder redactPii(Optional redactPii) { } public Builder redactPii(Boolean redactPii) { - this.redactPii = Optional.of(redactPii); + this.redactPii = Optional.ofNullable(redactPii); return this; } @@ -879,7 +879,7 @@ public Builder redactPiiAudio(Optional redactPiiAudio) { } public Builder redactPiiAudio(Boolean redactPiiAudio) { - this.redactPiiAudio = Optional.of(redactPiiAudio); + this.redactPiiAudio = Optional.ofNullable(redactPiiAudio); return this; } @@ -890,7 +890,7 @@ public Builder redactPiiAudioQuality(Optional redactPiiAu } public Builder redactPiiAudioQuality(RedactPiiAudioQuality redactPiiAudioQuality) { - this.redactPiiAudioQuality = Optional.of(redactPiiAudioQuality); + this.redactPiiAudioQuality = Optional.ofNullable(redactPiiAudioQuality); return this; } @@ -901,7 +901,7 @@ public Builder redactPiiPolicies(Optional> redactPiiPolicies) { } public Builder redactPiiPolicies(List redactPiiPolicies) { - this.redactPiiPolicies = Optional.of(redactPiiPolicies); + this.redactPiiPolicies = Optional.ofNullable(redactPiiPolicies); return this; } @@ -912,7 +912,7 @@ public Builder redactPiiSub(Optional redactPiiSub) { } public Builder redactPiiSub(SubstitutionPolicy redactPiiSub) { - this.redactPiiSub = Optional.of(redactPiiSub); + this.redactPiiSub = Optional.ofNullable(redactPiiSub); return this; } @@ -923,7 +923,7 @@ public Builder speakerLabels(Optional speakerLabels) { } public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = Optional.of(speakerLabels); + this.speakerLabels = Optional.ofNullable(speakerLabels); return this; } @@ -934,7 +934,7 @@ public Builder speakersExpected(Optional speakersExpected) { } public Builder speakersExpected(Integer speakersExpected) { - this.speakersExpected = Optional.of(speakersExpected); + this.speakersExpected = Optional.ofNullable(speakersExpected); return this; } @@ -945,7 +945,7 @@ public Builder contentSafety(Optional contentSafety) { } public Builder contentSafety(Boolean contentSafety) { - this.contentSafety = Optional.of(contentSafety); + this.contentSafety = Optional.ofNullable(contentSafety); return this; } @@ -956,7 +956,7 @@ public Builder contentSafetyConfidence(Optional contentSafetyConfidence } public Builder contentSafetyConfidence(Integer contentSafetyConfidence) { - this.contentSafetyConfidence = Optional.of(contentSafetyConfidence); + this.contentSafetyConfidence = Optional.ofNullable(contentSafetyConfidence); return this; } @@ -967,7 +967,7 @@ public Builder iabCategories(Optional iabCategories) { } public Builder iabCategories(Boolean iabCategories) { - this.iabCategories = Optional.of(iabCategories); + this.iabCategories = Optional.ofNullable(iabCategories); return this; } @@ -978,7 +978,7 @@ public Builder languageDetection(Optional languageDetection) { } public Builder languageDetection(Boolean languageDetection) { - this.languageDetection = Optional.of(languageDetection); + this.languageDetection = Optional.ofNullable(languageDetection); return this; } @@ -989,7 +989,7 @@ public Builder customSpelling(Optional> customSpe } public Builder customSpelling(List customSpelling) { - this.customSpelling = Optional.of(customSpelling); + this.customSpelling = Optional.ofNullable(customSpelling); return this; } @@ -1000,7 +1000,7 @@ public Builder disfluencies(Optional disfluencies) { } public Builder disfluencies(Boolean disfluencies) { - this.disfluencies = Optional.of(disfluencies); + this.disfluencies = Optional.ofNullable(disfluencies); return this; } @@ -1011,7 +1011,7 @@ public Builder sentimentAnalysis(Optional sentimentAnalysis) { } public Builder sentimentAnalysis(Boolean sentimentAnalysis) { - this.sentimentAnalysis = Optional.of(sentimentAnalysis); + this.sentimentAnalysis = Optional.ofNullable(sentimentAnalysis); return this; } @@ -1022,7 +1022,7 @@ public Builder autoChapters(Optional autoChapters) { } public Builder autoChapters(Boolean autoChapters) { - this.autoChapters = Optional.of(autoChapters); + this.autoChapters = Optional.ofNullable(autoChapters); return this; } @@ -1033,7 +1033,7 @@ public Builder entityDetection(Optional entityDetection) { } public Builder entityDetection(Boolean entityDetection) { - this.entityDetection = Optional.of(entityDetection); + this.entityDetection = Optional.ofNullable(entityDetection); return this; } @@ -1044,7 +1044,7 @@ public Builder speechThreshold(Optional speechThreshold) { } public Builder speechThreshold(Double speechThreshold) { - this.speechThreshold = Optional.of(speechThreshold); + this.speechThreshold = Optional.ofNullable(speechThreshold); return this; } @@ -1055,7 +1055,7 @@ public Builder summarization(Optional summarization) { } public Builder summarization(Boolean summarization) { - this.summarization = Optional.of(summarization); + this.summarization = Optional.ofNullable(summarization); return this; } @@ -1066,7 +1066,7 @@ public Builder summaryModel(Optional summaryModel) { } public Builder summaryModel(SummaryModel summaryModel) { - this.summaryModel = Optional.of(summaryModel); + this.summaryModel = Optional.ofNullable(summaryModel); return this; } @@ -1077,7 +1077,7 @@ public Builder summaryType(Optional summaryType) { } public Builder summaryType(SummaryType summaryType) { - this.summaryType = Optional.of(summaryType); + this.summaryType = Optional.ofNullable(summaryType); return this; } @@ -1088,7 +1088,7 @@ public Builder customTopics(Optional customTopics) { } public Builder customTopics(Boolean customTopics) { - this.customTopics = Optional.of(customTopics); + this.customTopics = Optional.ofNullable(customTopics); return this; } @@ -1099,7 +1099,7 @@ public Builder topics(Optional> topics) { } public Builder topics(List topics) { - this.topics = Optional.of(topics); + this.topics = Optional.ofNullable(topics); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptParagraph.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptParagraph.java index 7e31f4c4..5647839f 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptParagraph.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptParagraph.java @@ -19,7 +19,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptParagraph.Builder.class) public final class TranscriptParagraph { private final String text; @@ -216,7 +216,7 @@ public _FinalStage confidence(double confidence) { */ @java.lang.Override public _FinalStage speaker(String speaker) { - this.speaker = Optional.of(speaker); + this.speaker = Optional.ofNullable(speaker); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptReadyNotification.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptReadyNotification.java index 2143e86c..dc87ec8f 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptReadyNotification.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptReadyNotification.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptReadyNotification.Builder.class) public final class TranscriptReadyNotification { private final String transcriptId; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptSentence.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptSentence.java index 459cbeb3..da835722 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptSentence.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptSentence.java @@ -19,7 +19,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptSentence.Builder.class) public final class TranscriptSentence { private final String text; @@ -216,7 +216,7 @@ public _FinalStage confidence(double confidence) { */ @java.lang.Override public _FinalStage speaker(String speaker) { - this.speaker = Optional.of(speaker); + this.speaker = Optional.ofNullable(speaker); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptUtterance.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptUtterance.java index 522000d4..f556b5cf 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptUtterance.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptUtterance.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptUtterance.Builder.class) public final class TranscriptUtterance { private final double confidence; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWord.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWord.java index 8ae924e8..f6c63531 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWord.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWord.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TranscriptWord.Builder.class) public final class TranscriptWord { private final double confidence; @@ -195,7 +195,7 @@ public _FinalStage text(String text) { */ @java.lang.Override public _FinalStage speaker(String speaker) { - this.speaker = Optional.of(speaker); + this.speaker = Optional.ofNullable(speaker); return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchMatch.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchMatch.java index 6d6ed8eb..d158dfce 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchMatch.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchMatch.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = WordSearchMatch.Builder.class) public final class WordSearchMatch { private final String text; diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchResponse.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchResponse.java index 40cec383..208692ba 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchResponse.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/WordSearchResponse.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.Objects; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = WordSearchResponse.Builder.class) public final class WordSearchResponse { private final String id; diff --git a/src/main/java/com/assemblyai/api/types/Error.java b/src/main/java/com/assemblyai/api/types/Error.java index 799558d0..626e8a08 100644 --- a/src/main/java/com/assemblyai/api/types/Error.java +++ b/src/main/java/com/assemblyai/api/types/Error.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Optional; -@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Error.Builder.class) public final class Error { private final String error; @@ -119,7 +119,7 @@ public _FinalStage error(String error) { @java.lang.Override public _FinalStage status(String status) { - this.status = Optional.of(status); + this.status = Optional.ofNullable(status); return this; } From a4f715ccfaeda2595c250e8be8400353dfb58137 Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:11:40 +0900 Subject: [PATCH 2/3] Add ApiError back for backwards compat --- .fernignore | 2 + sample-app/src/main/java/sample/App.java | 30 +++++++++++++ .../com/assemblyai/api/core/ApiError.java | 42 +++++++++++++++++++ .../api/core/AssemblyAIApiException.java | 39 +---------------- 4 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/assemblyai/api/core/ApiError.java diff --git a/.fernignore b/.fernignore index 7af5a7c1..68a71a86 100644 --- a/.fernignore +++ b/.fernignore @@ -4,6 +4,8 @@ src/main/java/com/assemblyai/api/PollingTranscriptsClient.java src/main/java/com/assemblyai/api/Transcriber.java src/main/java/com/assemblyai/api/RealtimeTranscriber.java src/main/java/com/assemblyai/api/core/Constants.java +src/main/java/com/assemblyai/api/core/ApiError.java +src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java # Temporarily update deserialization logic src/main/java/com/assemblyai/api/core/ObjectMappers.java diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java index e1a88d06..9eda95f4 100644 --- a/sample-app/src/main/java/sample/App.java +++ b/sample-app/src/main/java/sample/App.java @@ -2,6 +2,9 @@ import com.assemblyai.api.AssemblyAI; import com.assemblyai.api.RealtimeTranscriber; +import com.assemblyai.api.core.ApiError; +import com.assemblyai.api.core.AssemblyAIApiException; +import com.assemblyai.api.core.AssemblyAIException; import com.assemblyai.api.resources.files.types.UploadedFile; import com.assemblyai.api.resources.lemur.requests.LemurQuestionAnswerParams; import com.assemblyai.api.resources.lemur.requests.LemurTaskParams; @@ -94,6 +97,33 @@ public static void main(String... args) throws IOException, InterruptedException LemurQuestionAnswer qa2 = lemurQuestionAnswerResponse2.getResponse().get(0); System.out.println("Q&A: " + qa2.getQuestion() + ": " + qa2.getAnswer()); + try { + client.lemur().task(LemurTaskParams.builder().prompt("test").build()); + } catch (AssemblyAIException e) { + System.out.println("Caught expected AssemblyAIException"); + } catch (Exception e) { + System.err.println("Error: " + e.getMessage()); + System.err.println("This error should've been AssemblyAIException, but is not."); + } + + try { + client.lemur().task(LemurTaskParams.builder().prompt("test").build()); + } catch (AssemblyAIApiException e) { + System.out.println("Caught expected AssemblyAIApiException"); + } catch (Exception e) { + System.err.println("Error: " + e.getMessage()); + System.err.println("This error should've been AssemblyAIApiException, but is not."); + } + + try { + client.lemur().task(LemurTaskParams.builder().prompt("test").build()); + } catch (ApiError e) { + System.out.println("Caught expected ApiError"); + } catch (Exception e) { + System.err.println("Error: " + e.getMessage()); + System.err.println("This error should've been ApiError, but is not."); + } + transcript = client.transcripts().delete(transcript.getId()); System.out.println("Delete transcript. " + transcript); diff --git a/src/main/java/com/assemblyai/api/core/ApiError.java b/src/main/java/com/assemblyai/api/core/ApiError.java new file mode 100644 index 00000000..ffcf78f9 --- /dev/null +++ b/src/main/java/com/assemblyai/api/core/ApiError.java @@ -0,0 +1,42 @@ +package com.assemblyai.api.core; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class ApiError extends AssemblyAIException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public ApiError(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + @java.lang.Override + public String toString() { + return "AssemblyAIApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + + body + "}"; + } +} diff --git a/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java b/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java index ee9d3d74..6fdea974 100644 --- a/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java +++ b/src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java @@ -1,45 +1,10 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ package com.assemblyai.api.core; /** * This exception type will be thrown for any non-2XX API responses. */ -public class AssemblyAIApiException extends AssemblyAIException { - /** - * The error code of the response that triggered the exception. - */ - private final int statusCode; - - /** - * The body of the response that triggered the exception. - */ - private final Object body; - +public class AssemblyAIApiException extends ApiError { public AssemblyAIApiException(String message, int statusCode, Object body) { - super(message); - this.statusCode = statusCode; - this.body = body; - } - - /** - * @return the statusCode - */ - public int statusCode() { - return this.statusCode; - } - - /** - * @return the body - */ - public Object body() { - return this.body; - } - - @java.lang.Override - public String toString() { - return "AssemblyAIApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " - + body + "}"; + super(message, statusCode, body); } } From 64689c05441964b5174fc5e44dd06c7098d41862 Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:18:35 +0900 Subject: [PATCH 3/3] Mark ApiError as deprecated --- src/main/java/com/assemblyai/api/core/ApiError.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/assemblyai/api/core/ApiError.java b/src/main/java/com/assemblyai/api/core/ApiError.java index ffcf78f9..91884dd8 100644 --- a/src/main/java/com/assemblyai/api/core/ApiError.java +++ b/src/main/java/com/assemblyai/api/core/ApiError.java @@ -2,7 +2,9 @@ /** * This exception type will be thrown for any non-2XX API responses. + * @deprecated Use {@link AssemblyAIApiException}. ApiError will be removed in a future release. */ +@Deprecated public class ApiError extends AssemblyAIException { /** * The error code of the response that triggered the exception.