From be6c7000aa0ec54b5abd5acc023c3d2ffd69969a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 02:03:50 +0000 Subject: [PATCH 01/16] chore(ci): skip lint on metadata-only changes Note that we still want to run tests, as these depend on the metadata. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6d1424..63b78ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/nuntly-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -46,7 +46,7 @@ jobs: contents: read id-token: write runs-on: ${{ github.repository == 'stainless-sdks/nuntly-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 From 9ad4c85cf8e51352f661d7ee640ae1d8dd724a8f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 02:04:35 +0000 Subject: [PATCH 02/16] chore(tests): bump steady to v0.19.7 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index b319bdf..09eb49f 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.6 -- steady --version + npm exec --package=@stdy/cli@0.19.7 -- steady --version - npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index cc7059c..ec1f890 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.6 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From 7cc35eb8ed276450e7fbc1617c32149a12818dd4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Mar 2026 02:07:09 +0000 Subject: [PATCH 03/16] chore(internal): update multipart form array serialization --- scripts/mock | 4 ++-- scripts/test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mock b/scripts/mock index 09eb49f..290e21b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -24,7 +24,7 @@ if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout npm exec --package=@stdy/cli@0.19.7 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index ec1f890..415d174 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 4ca6c5e8299d69f16020dc83f95452a25e9de016 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 02:19:24 +0000 Subject: [PATCH 04/16] chore(tests): bump steady to v0.20.1 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 290e21b..15c2994 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.7 -- steady --version + npm exec --package=@stdy/cli@0.20.1 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 415d174..d533ebc 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From f406712b2daed702c802028b63b1f97facd75454 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 02:23:37 +0000 Subject: [PATCH 05/16] chore(tests): bump steady to v0.20.2 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 15c2994..5cd7c15 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.20.1 -- steady --version + npm exec --package=@stdy/cli@0.20.2 -- steady --version - npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index d533ebc..61c1163 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 9106e39a9f68032114ada016fb3e6d6a1be4cf27 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 11:29:00 +0000 Subject: [PATCH 06/16] feat(api): implement label --- .stats.yml | 8 +- .../inboxes/threads/ThreadListParams.kt | 67 +-- .../com/nuntly/models/messages/Message.kt | 55 +- .../nuntly/models/messages/MessageDetail.kt | 55 +- .../models/messages/MessageUpdateParams.kt | 535 ++++++++++++++++++ .../models/messages/MessageUpdateResponse.kt | 170 ++++++ .../com/nuntly/models/threads/Thread.kt | 95 ++-- .../models/threads/ThreadRetrieveParams.kt | 40 +- .../models/threads/ThreadUpdateParams.kt | 223 +++++--- .../threads/messages/MessageListResponse.kt | 55 +- .../services/async/MessageServiceAsync.kt | 78 +++ .../services/async/MessageServiceAsyncImpl.kt | 44 ++ .../services/async/ThreadServiceAsync.kt | 10 +- .../services/blocking/MessageService.kt | 78 +++ .../services/blocking/MessageServiceImpl.kt | 41 ++ .../nuntly/services/blocking/ThreadService.kt | 10 +- .../threads/ThreadListPageResponseTest.kt | 9 +- .../inboxes/threads/ThreadListParamsTest.kt | 9 +- .../models/messages/MessageDetailTest.kt | 3 + .../messages/MessageListPageResponseTest.kt | 3 + .../com/nuntly/models/messages/MessageTest.kt | 3 + .../messages/MessageUpdateParamsTest.kt | 52 ++ .../messages/MessageUpdateResponseTest.kt | 32 ++ .../threads/ThreadRetrieveParamsTest.kt | 29 +- .../com/nuntly/models/threads/ThreadTest.kt | 9 +- .../models/threads/ThreadUpdateParamsTest.kt | 13 +- .../messages/MessageListPageResponseTest.kt | 3 + .../messages/MessageListResponseTest.kt | 3 + .../services/async/MessageServiceAsyncTest.kt | 23 + .../services/async/ThreadServiceAsyncTest.kt | 13 +- .../services/blocking/MessageServiceTest.kt | 22 + .../services/blocking/ThreadServiceTest.kt | 13 +- 32 files changed, 1570 insertions(+), 233 deletions(-) create mode 100644 nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt create mode 100644 nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt create mode 100644 nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateParamsTest.kt create mode 100644 nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 5071f13..b4d4e48 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 55 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/bazoud-corp%2Fnuntly-b843f02910523cb4ef8c23e1094c8421eb3bd6f78d9af975c12a162615bfd8e1.yml -openapi_spec_hash: a6cd2ac946127a11e40151aa47452036 -config_hash: f7efb1381efa887568a5e7028908ebd3 +configured_endpoints: 56 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/bazoud-corp%2Fnuntly-68da5d8336861a0f3138393f343d443a1b446ef8c5b0572e8278e9a7c93b2747.yml +openapi_spec_hash: 3e951a779e301ace98f73eabfe149e9b +config_hash: cf044f6bbd66c7aaf276100fe2f65f7e diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListParams.kt index 0f96013..25932a0 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListParams.kt @@ -14,8 +14,7 @@ class ThreadListParams private constructor( private val inboxId: String?, private val cursor: String?, - private val isRead: Boolean?, - private val isSpam: Boolean?, + private val labels: String?, private val limit: Double?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -26,11 +25,11 @@ private constructor( /** The cursor to retrieve the next page of results */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Filter by read status. */ - fun isRead(): Optional = Optional.ofNullable(isRead) - - /** Filter by spam status. */ - fun isSpam(): Optional = Optional.ofNullable(isSpam) + /** + * Comma-separated labels to filter by (AND logic). Threads with spam/trash are excluded by + * default unless explicitly requested via ?labels=spam or ?labels=trash. + */ + fun labels(): Optional = Optional.ofNullable(labels) /** The maximum number of results to return */ fun limit(): Optional = Optional.ofNullable(limit) @@ -56,8 +55,7 @@ private constructor( private var inboxId: String? = null private var cursor: String? = null - private var isRead: Boolean? = null - private var isSpam: Boolean? = null + private var labels: String? = null private var limit: Double? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -66,8 +64,7 @@ private constructor( internal fun from(threadListParams: ThreadListParams) = apply { inboxId = threadListParams.inboxId cursor = threadListParams.cursor - isRead = threadListParams.isRead - isSpam = threadListParams.isSpam + labels = threadListParams.labels limit = threadListParams.limit additionalHeaders = threadListParams.additionalHeaders.toBuilder() additionalQueryParams = threadListParams.additionalQueryParams.toBuilder() @@ -84,31 +81,14 @@ private constructor( /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Filter by read status. */ - fun isRead(isRead: Boolean?) = apply { this.isRead = isRead } - /** - * Alias for [Builder.isRead]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun isRead(isRead: Boolean) = isRead(isRead as Boolean?) - - /** Alias for calling [Builder.isRead] with `isRead.orElse(null)`. */ - fun isRead(isRead: Optional) = isRead(isRead.getOrNull()) - - /** Filter by spam status. */ - fun isSpam(isSpam: Boolean?) = apply { this.isSpam = isSpam } - - /** - * Alias for [Builder.isSpam]. - * - * This unboxed primitive overload exists for backwards compatibility. + * Comma-separated labels to filter by (AND logic). Threads with spam/trash are excluded by + * default unless explicitly requested via ?labels=spam or ?labels=trash. */ - fun isSpam(isSpam: Boolean) = isSpam(isSpam as Boolean?) + fun labels(labels: String?) = apply { this.labels = labels } - /** Alias for calling [Builder.isSpam] with `isSpam.orElse(null)`. */ - fun isSpam(isSpam: Optional) = isSpam(isSpam.getOrNull()) + /** Alias for calling [Builder.labels] with `labels.orElse(null)`. */ + fun labels(labels: Optional) = labels(labels.getOrNull()) /** The maximum number of results to return */ fun limit(limit: Double?) = apply { this.limit = limit } @@ -230,8 +210,7 @@ private constructor( ThreadListParams( inboxId, cursor, - isRead, - isSpam, + labels, limit, additionalHeaders.build(), additionalQueryParams.build(), @@ -250,8 +229,7 @@ private constructor( QueryParams.builder() .apply { cursor?.let { put("cursor", it) } - isRead?.let { put("isRead", it.toString()) } - isSpam?.let { put("isSpam", it.toString()) } + labels?.let { put("labels", it) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) } @@ -265,24 +243,15 @@ private constructor( return other is ThreadListParams && inboxId == other.inboxId && cursor == other.cursor && - isRead == other.isRead && - isSpam == other.isSpam && + labels == other.labels && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash( - inboxId, - cursor, - isRead, - isSpam, - limit, - additionalHeaders, - additionalQueryParams, - ) + Objects.hash(inboxId, cursor, labels, limit, additionalHeaders, additionalQueryParams) override fun toString() = - "ThreadListParams{inboxId=$inboxId, cursor=$cursor, isRead=$isRead, isSpam=$isSpam, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ThreadListParams{inboxId=$inboxId, cursor=$cursor, labels=$labels, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt index 4f0662b..2c88339 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt @@ -30,6 +30,7 @@ private constructor( private val createdAt: JsonField, private val from: JsonField, private val inboxId: JsonField, + private val labels: JsonField>, private val messageId: JsonField, private val receivedAt: JsonField, private val replyTo: JsonField>, @@ -51,6 +52,7 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), @JsonProperty("inboxId") @ExcludeMissing inboxId: JsonField = JsonMissing.of(), + @JsonProperty("labels") @ExcludeMissing labels: JsonField> = JsonMissing.of(), @JsonProperty("messageId") @ExcludeMissing messageId: JsonField = JsonMissing.of(), @JsonProperty("receivedAt") @ExcludeMissing @@ -70,6 +72,7 @@ private constructor( createdAt, from, inboxId, + labels, messageId, receivedAt, replyTo, @@ -137,6 +140,14 @@ private constructor( */ fun inboxId(): Optional = inboxId.getOptional("inboxId") + /** + * The message labels. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun labels(): List = labels.getRequired("labels") + /** * The email Message-ID header. * @@ -244,6 +255,13 @@ private constructor( */ @JsonProperty("inboxId") @ExcludeMissing fun _inboxId(): JsonField = inboxId + /** + * Returns the raw JSON value of [labels]. + * + * Unlike [labels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("labels") @ExcludeMissing fun _labels(): JsonField> = labels + /** * Returns the raw JSON value of [messageId]. * @@ -319,6 +337,7 @@ private constructor( * .createdAt() * .from() * .inboxId() + * .labels() * .messageId() * .receivedAt() * .replyTo() @@ -341,6 +360,7 @@ private constructor( private var createdAt: JsonField? = null private var from: JsonField? = null private var inboxId: JsonField? = null + private var labels: JsonField>? = null private var messageId: JsonField? = null private var receivedAt: JsonField? = null private var replyTo: JsonField>? = null @@ -359,6 +379,7 @@ private constructor( createdAt = message.createdAt from = message.from inboxId = message.inboxId + labels = message.labels.map { it.toMutableList() } messageId = message.messageId receivedAt = message.receivedAt replyTo = message.replyTo.map { it.toMutableList() } @@ -484,6 +505,32 @@ private constructor( */ fun inboxId(inboxId: JsonField) = apply { this.inboxId = inboxId } + /** The message labels. */ + fun labels(labels: List) = labels(JsonField.of(labels)) + + /** + * Sets [Builder.labels] to an arbitrary JSON value. + * + * You should usually call [Builder.labels] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun labels(labels: JsonField>) = apply { + this.labels = labels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [labels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLabel(label: String) = apply { + labels = + (labels ?: JsonField.of(mutableListOf())).also { + checkKnown("labels", it).add(label) + } + } + /** The email Message-ID header. */ fun messageId(messageId: String) = messageId(JsonField.of(messageId)) @@ -624,6 +671,7 @@ private constructor( * .createdAt() * .from() * .inboxId() + * .labels() * .messageId() * .receivedAt() * .replyTo() @@ -644,6 +692,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("from", from), checkRequired("inboxId", inboxId), + checkRequired("labels", labels).map { it.toImmutable() }, checkRequired("messageId", messageId), checkRequired("receivedAt", receivedAt), checkRequired("replyTo", replyTo).map { it.toImmutable() }, @@ -669,6 +718,7 @@ private constructor( createdAt() from() inboxId() + labels() messageId() receivedAt() replyTo() @@ -701,6 +751,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (if (from.asKnown().isPresent) 1 else 0) + (if (inboxId.asKnown().isPresent) 1 else 0) + + (labels.asKnown().getOrNull()?.size ?: 0) + (if (messageId.asKnown().isPresent) 1 else 0) + (if (receivedAt.asKnown().isPresent) 1 else 0) + (replyTo.asKnown().getOrNull()?.size ?: 0) + @@ -860,6 +911,7 @@ private constructor( createdAt == other.createdAt && from == other.from && inboxId == other.inboxId && + labels == other.labels && messageId == other.messageId && receivedAt == other.receivedAt && replyTo == other.replyTo && @@ -879,6 +931,7 @@ private constructor( createdAt, from, inboxId, + labels, messageId, receivedAt, replyTo, @@ -893,5 +946,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Message{id=$id, attachmentCount=$attachmentCount, bcc=$bcc, cc=$cc, createdAt=$createdAt, from=$from, inboxId=$inboxId, messageId=$messageId, receivedAt=$receivedAt, replyTo=$replyTo, status=$status, subject=$subject, threadId=$threadId, to=$to, additionalProperties=$additionalProperties}" + "Message{id=$id, attachmentCount=$attachmentCount, bcc=$bcc, cc=$cc, createdAt=$createdAt, from=$from, inboxId=$inboxId, labels=$labels, messageId=$messageId, receivedAt=$receivedAt, replyTo=$replyTo, status=$status, subject=$subject, threadId=$threadId, to=$to, additionalProperties=$additionalProperties}" } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt index e599307..3c70703 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt @@ -31,6 +31,7 @@ private constructor( private val from: JsonField, private val headers: JsonField, private val inboxId: JsonField, + private val labels: JsonField>, private val messageId: JsonField, private val receivedAt: JsonField, private val replyTo: JsonField>, @@ -53,6 +54,7 @@ private constructor( @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), @JsonProperty("inboxId") @ExcludeMissing inboxId: JsonField = JsonMissing.of(), + @JsonProperty("labels") @ExcludeMissing labels: JsonField> = JsonMissing.of(), @JsonProperty("messageId") @ExcludeMissing messageId: JsonField = JsonMissing.of(), @JsonProperty("receivedAt") @ExcludeMissing @@ -73,6 +75,7 @@ private constructor( from, headers, inboxId, + labels, messageId, receivedAt, replyTo, @@ -148,6 +151,14 @@ private constructor( */ fun inboxId(): Optional = inboxId.getOptional("inboxId") + /** + * The message labels. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun labels(): List = labels.getRequired("labels") + /** * The email Message-ID header. * @@ -262,6 +273,13 @@ private constructor( */ @JsonProperty("inboxId") @ExcludeMissing fun _inboxId(): JsonField = inboxId + /** + * Returns the raw JSON value of [labels]. + * + * Unlike [labels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("labels") @ExcludeMissing fun _labels(): JsonField> = labels + /** * Returns the raw JSON value of [messageId]. * @@ -338,6 +356,7 @@ private constructor( * .from() * .headers() * .inboxId() + * .labels() * .messageId() * .receivedAt() * .replyTo() @@ -361,6 +380,7 @@ private constructor( private var from: JsonField? = null private var headers: JsonField? = null private var inboxId: JsonField? = null + private var labels: JsonField>? = null private var messageId: JsonField? = null private var receivedAt: JsonField? = null private var replyTo: JsonField>? = null @@ -380,6 +400,7 @@ private constructor( from = messageDetail.from headers = messageDetail.headers inboxId = messageDetail.inboxId + labels = messageDetail.labels.map { it.toMutableList() } messageId = messageDetail.messageId receivedAt = messageDetail.receivedAt replyTo = messageDetail.replyTo.map { it.toMutableList() } @@ -519,6 +540,32 @@ private constructor( */ fun inboxId(inboxId: JsonField) = apply { this.inboxId = inboxId } + /** The message labels. */ + fun labels(labels: List) = labels(JsonField.of(labels)) + + /** + * Sets [Builder.labels] to an arbitrary JSON value. + * + * You should usually call [Builder.labels] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun labels(labels: JsonField>) = apply { + this.labels = labels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [labels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLabel(label: String) = apply { + labels = + (labels ?: JsonField.of(mutableListOf())).also { + checkKnown("labels", it).add(label) + } + } + /** The email Message-ID header. */ fun messageId(messageId: String) = messageId(JsonField.of(messageId)) @@ -660,6 +707,7 @@ private constructor( * .from() * .headers() * .inboxId() + * .labels() * .messageId() * .receivedAt() * .replyTo() @@ -681,6 +729,7 @@ private constructor( checkRequired("from", from), checkRequired("headers", headers), checkRequired("inboxId", inboxId), + checkRequired("labels", labels).map { it.toImmutable() }, checkRequired("messageId", messageId), checkRequired("receivedAt", receivedAt), checkRequired("replyTo", replyTo).map { it.toImmutable() }, @@ -707,6 +756,7 @@ private constructor( from() headers().ifPresent { it.validate() } inboxId() + labels() messageId() receivedAt() replyTo() @@ -740,6 +790,7 @@ private constructor( (if (from.asKnown().isPresent) 1 else 0) + (headers.asKnown().getOrNull()?.validity() ?: 0) + (if (inboxId.asKnown().isPresent) 1 else 0) + + (labels.asKnown().getOrNull()?.size ?: 0) + (if (messageId.asKnown().isPresent) 1 else 0) + (if (receivedAt.asKnown().isPresent) 1 else 0) + (replyTo.asKnown().getOrNull()?.size ?: 0) + @@ -1000,6 +1051,7 @@ private constructor( from == other.from && headers == other.headers && inboxId == other.inboxId && + labels == other.labels && messageId == other.messageId && receivedAt == other.receivedAt && replyTo == other.replyTo && @@ -1020,6 +1072,7 @@ private constructor( from, headers, inboxId, + labels, messageId, receivedAt, replyTo, @@ -1034,5 +1087,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MessageDetail{id=$id, attachmentCount=$attachmentCount, bcc=$bcc, cc=$cc, createdAt=$createdAt, from=$from, headers=$headers, inboxId=$inboxId, messageId=$messageId, receivedAt=$receivedAt, replyTo=$replyTo, status=$status, subject=$subject, threadId=$threadId, to=$to, additionalProperties=$additionalProperties}" + "MessageDetail{id=$id, attachmentCount=$attachmentCount, bcc=$bcc, cc=$cc, createdAt=$createdAt, from=$from, headers=$headers, inboxId=$inboxId, labels=$labels, messageId=$messageId, receivedAt=$receivedAt, replyTo=$replyTo, status=$status, subject=$subject, threadId=$threadId, to=$to, additionalProperties=$additionalProperties}" } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt new file mode 100644 index 0000000..25d8e1c --- /dev/null +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt @@ -0,0 +1,535 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.nuntly.models.messages + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.nuntly.core.ExcludeMissing +import com.nuntly.core.JsonField +import com.nuntly.core.JsonMissing +import com.nuntly.core.JsonValue +import com.nuntly.core.Params +import com.nuntly.core.checkKnown +import com.nuntly.core.http.Headers +import com.nuntly.core.http.QueryParams +import com.nuntly.core.toImmutable +import com.nuntly.errors.NuntlyInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update message labels. Only available for messages in user-created inboxes. */ +class MessageUpdateParams +private constructor( + private val messageId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun messageId(): Optional = Optional.ofNullable(messageId) + + /** + * Labels to add to the message. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addLabels(): Optional> = body.addLabels() + + /** + * Labels to remove from the message. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun removeLabels(): Optional> = body.removeLabels() + + /** + * Returns the raw JSON value of [addLabels]. + * + * Unlike [addLabels], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _addLabels(): JsonField> = body._addLabels() + + /** + * Returns the raw JSON value of [removeLabels]. + * + * Unlike [removeLabels], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _removeLabels(): JsonField> = body._removeLabels() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MessageUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageUpdateParams]. */ + class Builder internal constructor() { + + private var messageId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(messageUpdateParams: MessageUpdateParams) = apply { + messageId = messageUpdateParams.messageId + body = messageUpdateParams.body.toBuilder() + additionalHeaders = messageUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = messageUpdateParams.additionalQueryParams.toBuilder() + } + + fun messageId(messageId: String?) = apply { this.messageId = messageId } + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [addLabels] + * - [removeLabels] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Labels to add to the message. */ + fun addLabels(addLabels: List) = apply { body.addLabels(addLabels) } + + /** + * Sets [Builder.addLabels] to an arbitrary JSON value. + * + * You should usually call [Builder.addLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addLabels(addLabels: JsonField>) = apply { body.addLabels(addLabels) } + + /** + * Adds a single [String] to [addLabels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddLabel(addLabel: String) = apply { body.addAddLabel(addLabel) } + + /** Labels to remove from the message. */ + fun removeLabels(removeLabels: List) = apply { body.removeLabels(removeLabels) } + + /** + * Sets [Builder.removeLabels] to an arbitrary JSON value. + * + * You should usually call [Builder.removeLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun removeLabels(removeLabels: JsonField>) = apply { + body.removeLabels(removeLabels) + } + + /** + * Adds a single [String] to [removeLabels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRemoveLabel(removeLabel: String) = apply { body.addRemoveLabel(removeLabel) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MessageUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageUpdateParams = + MessageUpdateParams( + messageId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> messageId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addLabels: JsonField>, + private val removeLabels: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("addLabels") + @ExcludeMissing + addLabels: JsonField> = JsonMissing.of(), + @JsonProperty("removeLabels") + @ExcludeMissing + removeLabels: JsonField> = JsonMissing.of(), + ) : this(addLabels, removeLabels, mutableMapOf()) + + /** + * Labels to add to the message. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addLabels(): Optional> = addLabels.getOptional("addLabels") + + /** + * Labels to remove from the message. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun removeLabels(): Optional> = removeLabels.getOptional("removeLabels") + + /** + * Returns the raw JSON value of [addLabels]. + * + * Unlike [addLabels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("addLabels") + @ExcludeMissing + fun _addLabels(): JsonField> = addLabels + + /** + * Returns the raw JSON value of [removeLabels]. + * + * Unlike [removeLabels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("removeLabels") + @ExcludeMissing + fun _removeLabels(): JsonField> = removeLabels + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var addLabels: JsonField>? = null + private var removeLabels: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + addLabels = body.addLabels.map { it.toMutableList() } + removeLabels = body.removeLabels.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Labels to add to the message. */ + fun addLabels(addLabels: List) = addLabels(JsonField.of(addLabels)) + + /** + * Sets [Builder.addLabels] to an arbitrary JSON value. + * + * You should usually call [Builder.addLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addLabels(addLabels: JsonField>) = apply { + this.addLabels = addLabels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addLabels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddLabel(addLabel: String) = apply { + addLabels = + (addLabels ?: JsonField.of(mutableListOf())).also { + checkKnown("addLabels", it).add(addLabel) + } + } + + /** Labels to remove from the message. */ + fun removeLabels(removeLabels: List) = removeLabels(JsonField.of(removeLabels)) + + /** + * Sets [Builder.removeLabels] to an arbitrary JSON value. + * + * You should usually call [Builder.removeLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun removeLabels(removeLabels: JsonField>) = apply { + this.removeLabels = removeLabels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeLabels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRemoveLabel(removeLabel: String) = apply { + removeLabels = + (removeLabels ?: JsonField.of(mutableListOf())).also { + checkKnown("removeLabels", it).add(removeLabel) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (addLabels ?: JsonMissing.of()).map { it.toImmutable() }, + (removeLabels ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + addLabels() + removeLabels() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: NuntlyInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addLabels.asKnown().getOrNull()?.size ?: 0) + + (removeLabels.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + addLabels == other.addLabels && + removeLabels == other.removeLabels && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(addLabels, removeLabels, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{addLabels=$addLabels, removeLabels=$removeLabels, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageUpdateParams && + messageId == other.messageId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(messageId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MessageUpdateParams{messageId=$messageId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt new file mode 100644 index 0000000..dceaabd --- /dev/null +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.nuntly.models.messages + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.nuntly.core.ExcludeMissing +import com.nuntly.core.JsonField +import com.nuntly.core.JsonMissing +import com.nuntly.core.JsonValue +import com.nuntly.core.checkRequired +import com.nuntly.errors.NuntlyInvalidDataException +import java.util.Collections +import java.util.Objects + +class MessageUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * The id of the resource. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageUpdateResponse]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageUpdateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageUpdateResponse: MessageUpdateResponse) = apply { + id = messageUpdateResponse.id + additionalProperties = messageUpdateResponse.additionalProperties.toMutableMap() + } + + /** The id of the resource. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageUpdateResponse = + MessageUpdateResponse(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MessageUpdateResponse = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: NuntlyInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageUpdateResponse && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageUpdateResponse{id=$id, additionalProperties=$additionalProperties}" +} diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/Thread.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/Thread.kt index 2fe3261..6a524bc 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/Thread.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/Thread.kt @@ -10,7 +10,9 @@ import com.nuntly.core.ExcludeMissing import com.nuntly.core.JsonField import com.nuntly.core.JsonMissing import com.nuntly.core.JsonValue +import com.nuntly.core.checkKnown import com.nuntly.core.checkRequired +import com.nuntly.core.toImmutable import com.nuntly.errors.NuntlyInvalidDataException import java.util.Collections import java.util.Objects @@ -26,8 +28,7 @@ private constructor( private val domainId: JsonField, private val domainName: JsonField, private val inboxId: JsonField, - private val isRead: JsonField, - private val isSpam: JsonField, + private val labels: JsonField>, private val lastMessageAt: JsonField, private val messageCount: JsonField, private val subject: JsonField, @@ -45,8 +46,7 @@ private constructor( @ExcludeMissing domainName: JsonField = JsonMissing.of(), @JsonProperty("inboxId") @ExcludeMissing inboxId: JsonField = JsonMissing.of(), - @JsonProperty("isRead") @ExcludeMissing isRead: JsonField = JsonMissing.of(), - @JsonProperty("isSpam") @ExcludeMissing isSpam: JsonField = JsonMissing.of(), + @JsonProperty("labels") @ExcludeMissing labels: JsonField> = JsonMissing.of(), @JsonProperty("lastMessageAt") @ExcludeMissing lastMessageAt: JsonField = JsonMissing.of(), @@ -62,8 +62,7 @@ private constructor( domainId, domainName, inboxId, - isRead, - isSpam, + labels, lastMessageAt, messageCount, subject, @@ -120,20 +119,12 @@ private constructor( fun inboxId(): String = inboxId.getRequired("inboxId") /** - * Whether the thread has been read. + * Aggregated labels from all messages in the thread. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun isRead(): Boolean = isRead.getRequired("isRead") - - /** - * Whether the thread is marked as spam. - * - * @throws NuntlyInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun isSpam(): Boolean = isSpam.getRequired("isSpam") + fun labels(): List = labels.getRequired("labels") /** * The timestamp of the most recent message. @@ -210,18 +201,11 @@ private constructor( @JsonProperty("inboxId") @ExcludeMissing fun _inboxId(): JsonField = inboxId /** - * Returns the raw JSON value of [isRead]. + * Returns the raw JSON value of [labels]. * - * Unlike [isRead], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [labels], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("isRead") @ExcludeMissing fun _isRead(): JsonField = isRead - - /** - * Returns the raw JSON value of [isSpam]. - * - * Unlike [isSpam], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isSpam") @ExcludeMissing fun _isSpam(): JsonField = isSpam + @JsonProperty("labels") @ExcludeMissing fun _labels(): JsonField> = labels /** * Returns the raw JSON value of [lastMessageAt]. @@ -280,8 +264,7 @@ private constructor( * .domainId() * .domainName() * .inboxId() - * .isRead() - * .isSpam() + * .labels() * .lastMessageAt() * .messageCount() * .subject() @@ -299,8 +282,7 @@ private constructor( private var domainId: JsonField? = null private var domainName: JsonField? = null private var inboxId: JsonField? = null - private var isRead: JsonField? = null - private var isSpam: JsonField? = null + private var labels: JsonField>? = null private var lastMessageAt: JsonField? = null private var messageCount: JsonField? = null private var subject: JsonField? = null @@ -315,8 +297,7 @@ private constructor( domainId = thread.domainId domainName = thread.domainName inboxId = thread.inboxId - isRead = thread.isRead - isSpam = thread.isSpam + labels = thread.labels.map { it.toMutableList() } lastMessageAt = thread.lastMessageAt messageCount = thread.messageCount subject = thread.subject @@ -398,27 +379,31 @@ private constructor( */ fun inboxId(inboxId: JsonField) = apply { this.inboxId = inboxId } - /** Whether the thread has been read. */ - fun isRead(isRead: Boolean) = isRead(JsonField.of(isRead)) + /** Aggregated labels from all messages in the thread. */ + fun labels(labels: List) = labels(JsonField.of(labels)) /** - * Sets [Builder.isRead] to an arbitrary JSON value. + * Sets [Builder.labels] to an arbitrary JSON value. * - * You should usually call [Builder.isRead] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.labels] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun isRead(isRead: JsonField) = apply { this.isRead = isRead } - - /** Whether the thread is marked as spam. */ - fun isSpam(isSpam: Boolean) = isSpam(JsonField.of(isSpam)) + fun labels(labels: JsonField>) = apply { + this.labels = labels.map { it.toMutableList() } + } /** - * Sets [Builder.isSpam] to an arbitrary JSON value. + * Adds a single [String] to [labels]. * - * You should usually call [Builder.isSpam] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun isSpam(isSpam: JsonField) = apply { this.isSpam = isSpam } + fun addLabel(label: String) = apply { + labels = + (labels ?: JsonField.of(mutableListOf())).also { + checkKnown("labels", it).add(label) + } + } /** The timestamp of the most recent message. */ fun lastMessageAt(lastMessageAt: String) = lastMessageAt(JsonField.of(lastMessageAt)) @@ -503,8 +488,7 @@ private constructor( * .domainId() * .domainName() * .inboxId() - * .isRead() - * .isSpam() + * .labels() * .lastMessageAt() * .messageCount() * .subject() @@ -520,8 +504,7 @@ private constructor( checkRequired("domainId", domainId), checkRequired("domainName", domainName), checkRequired("inboxId", inboxId), - checkRequired("isRead", isRead), - checkRequired("isSpam", isSpam), + checkRequired("labels", labels).map { it.toImmutable() }, checkRequired("lastMessageAt", lastMessageAt), checkRequired("messageCount", messageCount), checkRequired("subject", subject), @@ -543,8 +526,7 @@ private constructor( domainId() domainName() inboxId() - isRead() - isSpam() + labels() lastMessageAt() messageCount() subject() @@ -573,8 +555,7 @@ private constructor( (if (domainId.asKnown().isPresent) 1 else 0) + (if (domainName.asKnown().isPresent) 1 else 0) + (if (inboxId.asKnown().isPresent) 1 else 0) + - (if (isRead.asKnown().isPresent) 1 else 0) + - (if (isSpam.asKnown().isPresent) 1 else 0) + + (labels.asKnown().getOrNull()?.size ?: 0) + (if (lastMessageAt.asKnown().isPresent) 1 else 0) + (if (messageCount.asKnown().isPresent) 1 else 0) + (if (subject.asKnown().isPresent) 1 else 0) + @@ -592,8 +573,7 @@ private constructor( domainId == other.domainId && domainName == other.domainName && inboxId == other.inboxId && - isRead == other.isRead && - isSpam == other.isSpam && + labels == other.labels && lastMessageAt == other.lastMessageAt && messageCount == other.messageCount && subject == other.subject && @@ -609,8 +589,7 @@ private constructor( domainId, domainName, inboxId, - isRead, - isSpam, + labels, lastMessageAt, messageCount, subject, @@ -622,5 +601,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Thread{id=$id, agentId=$agentId, createdAt=$createdAt, domainId=$domainId, domainName=$domainName, inboxId=$inboxId, isRead=$isRead, isSpam=$isSpam, lastMessageAt=$lastMessageAt, messageCount=$messageCount, subject=$subject, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "Thread{id=$id, agentId=$agentId, createdAt=$createdAt, domainId=$domainId, domainName=$domainName, inboxId=$inboxId, labels=$labels, lastMessageAt=$lastMessageAt, messageCount=$messageCount, subject=$subject, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadRetrieveParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadRetrieveParams.kt index 9167b99..e52030e 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadRetrieveParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadRetrieveParams.kt @@ -9,16 +9,23 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Retrieve a thread. Auto-marks as read. */ +/** + * Retrieve a thread. Pass ?markRead=true to automatically remove the unread label from all + * messages. + */ class ThreadRetrieveParams private constructor( private val threadId: String?, + private val markRead: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun threadId(): Optional = Optional.ofNullable(threadId) + /** Set to "true" to automatically remove the unread label from all messages in the thread. */ + fun markRead(): Optional = Optional.ofNullable(markRead) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -39,12 +46,14 @@ private constructor( class Builder internal constructor() { private var threadId: String? = null + private var markRead: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(threadRetrieveParams: ThreadRetrieveParams) = apply { threadId = threadRetrieveParams.threadId + markRead = threadRetrieveParams.markRead additionalHeaders = threadRetrieveParams.additionalHeaders.toBuilder() additionalQueryParams = threadRetrieveParams.additionalQueryParams.toBuilder() } @@ -54,6 +63,14 @@ private constructor( /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) + /** + * Set to "true" to automatically remove the unread label from all messages in the thread. + */ + fun markRead(markRead: String?) = apply { this.markRead = markRead } + + /** Alias for calling [Builder.markRead] with `markRead.orElse(null)`. */ + fun markRead(markRead: Optional) = markRead(markRead.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -158,7 +175,12 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): ThreadRetrieveParams = - ThreadRetrieveParams(threadId, additionalHeaders.build(), additionalQueryParams.build()) + ThreadRetrieveParams( + threadId, + markRead, + additionalHeaders.build(), + additionalQueryParams.build(), + ) } fun _pathParam(index: Int): String = @@ -169,7 +191,13 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + markRead?.let { put("markRead", it) } + putAll(additionalQueryParams) + } + .build() override fun equals(other: Any?): Boolean { if (this === other) { @@ -178,12 +206,14 @@ private constructor( return other is ThreadRetrieveParams && threadId == other.threadId && + markRead == other.markRead && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(threadId, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(threadId, markRead, additionalHeaders, additionalQueryParams) override fun toString() = - "ThreadRetrieveParams{threadId=$threadId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ThreadRetrieveParams{threadId=$threadId, markRead=$markRead, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadUpdateParams.kt index a7ce613..ff09c74 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/ThreadUpdateParams.kt @@ -11,15 +11,19 @@ import com.nuntly.core.JsonField import com.nuntly.core.JsonMissing import com.nuntly.core.JsonValue import com.nuntly.core.Params +import com.nuntly.core.checkKnown import com.nuntly.core.http.Headers import com.nuntly.core.http.QueryParams +import com.nuntly.core.toImmutable import com.nuntly.errors.NuntlyInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Update thread properties (read status, spam, agent). */ +/** + * Update thread labels and agent assignment. Label operations apply to all messages in the thread. + */ class ThreadUpdateParams private constructor( private val threadId: String?, @@ -31,49 +35,49 @@ private constructor( fun threadId(): Optional = Optional.ofNullable(threadId) /** - * The AI agent identifier. + * Labels to add to all messages in the thread. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun agentId(): Optional = body.agentId() + fun addLabels(): Optional> = body.addLabels() /** - * Mark the thread as read or unread. + * The AI agent identifier. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun isRead(): Optional = body.isRead() + fun agentId(): Optional = body.agentId() /** - * Mark the thread as spam or not spam. + * Labels to remove from all messages in the thread. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun isSpam(): Optional = body.isSpam() + fun removeLabels(): Optional> = body.removeLabels() /** - * Returns the raw JSON value of [agentId]. + * Returns the raw JSON value of [addLabels]. * - * Unlike [agentId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [addLabels], this method doesn't throw if the JSON field has an unexpected type. */ - fun _agentId(): JsonField = body._agentId() + fun _addLabels(): JsonField> = body._addLabels() /** - * Returns the raw JSON value of [isRead]. + * Returns the raw JSON value of [agentId]. * - * Unlike [isRead], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [agentId], this method doesn't throw if the JSON field has an unexpected type. */ - fun _isRead(): JsonField = body._isRead() + fun _agentId(): JsonField = body._agentId() /** - * Returns the raw JSON value of [isSpam]. + * Returns the raw JSON value of [removeLabels]. * - * Unlike [isSpam], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [removeLabels], this method doesn't throw if the JSON field has an unexpected type. */ - fun _isSpam(): JsonField = body._isSpam() + fun _removeLabels(): JsonField> = body._removeLabels() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -119,12 +123,31 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [addLabels] * - [agentId] - * - [isRead] - * - [isSpam] + * - [removeLabels] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Labels to add to all messages in the thread. */ + fun addLabels(addLabels: List) = apply { body.addLabels(addLabels) } + + /** + * Sets [Builder.addLabels] to an arbitrary JSON value. + * + * You should usually call [Builder.addLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addLabels(addLabels: JsonField>) = apply { body.addLabels(addLabels) } + + /** + * Adds a single [String] to [addLabels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddLabel(addLabel: String) = apply { body.addAddLabel(addLabel) } + /** The AI agent identifier. */ fun agentId(agentId: String?) = apply { body.agentId(agentId) } @@ -139,27 +162,26 @@ private constructor( */ fun agentId(agentId: JsonField) = apply { body.agentId(agentId) } - /** Mark the thread as read or unread. */ - fun isRead(isRead: Boolean) = apply { body.isRead(isRead) } + /** Labels to remove from all messages in the thread. */ + fun removeLabels(removeLabels: List) = apply { body.removeLabels(removeLabels) } /** - * Sets [Builder.isRead] to an arbitrary JSON value. + * Sets [Builder.removeLabels] to an arbitrary JSON value. * - * You should usually call [Builder.isRead] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.removeLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun isRead(isRead: JsonField) = apply { body.isRead(isRead) } - - /** Mark the thread as spam or not spam. */ - fun isSpam(isSpam: Boolean) = apply { body.isSpam(isSpam) } + fun removeLabels(removeLabels: JsonField>) = apply { + body.removeLabels(removeLabels) + } /** - * Sets [Builder.isSpam] to an arbitrary JSON value. + * Adds a single [String] to [removeLabels]. * - * You should usually call [Builder.isSpam] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun isSpam(isSpam: JsonField) = apply { body.isSpam(isSpam) } + fun addRemoveLabel(removeLabel: String) = apply { body.addRemoveLabel(removeLabel) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -307,63 +329,72 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val addLabels: JsonField>, private val agentId: JsonField, - private val isRead: JsonField, - private val isSpam: JsonField, + private val removeLabels: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("addLabels") + @ExcludeMissing + addLabels: JsonField> = JsonMissing.of(), @JsonProperty("agentId") @ExcludeMissing agentId: JsonField = JsonMissing.of(), - @JsonProperty("isRead") @ExcludeMissing isRead: JsonField = JsonMissing.of(), - @JsonProperty("isSpam") @ExcludeMissing isSpam: JsonField = JsonMissing.of(), - ) : this(agentId, isRead, isSpam, mutableMapOf()) + @JsonProperty("removeLabels") + @ExcludeMissing + removeLabels: JsonField> = JsonMissing.of(), + ) : this(addLabels, agentId, removeLabels, mutableMapOf()) /** - * The AI agent identifier. + * Labels to add to all messages in the thread. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun agentId(): Optional = agentId.getOptional("agentId") + fun addLabels(): Optional> = addLabels.getOptional("addLabels") /** - * Mark the thread as read or unread. + * The AI agent identifier. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun isRead(): Optional = isRead.getOptional("isRead") + fun agentId(): Optional = agentId.getOptional("agentId") /** - * Mark the thread as spam or not spam. + * Labels to remove from all messages in the thread. * * @throws NuntlyInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun isSpam(): Optional = isSpam.getOptional("isSpam") + fun removeLabels(): Optional> = removeLabels.getOptional("removeLabels") /** - * Returns the raw JSON value of [agentId]. + * Returns the raw JSON value of [addLabels]. * - * Unlike [agentId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [addLabels], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("agentId") @ExcludeMissing fun _agentId(): JsonField = agentId + @JsonProperty("addLabels") + @ExcludeMissing + fun _addLabels(): JsonField> = addLabels /** - * Returns the raw JSON value of [isRead]. + * Returns the raw JSON value of [agentId]. * - * Unlike [isRead], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [agentId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("isRead") @ExcludeMissing fun _isRead(): JsonField = isRead + @JsonProperty("agentId") @ExcludeMissing fun _agentId(): JsonField = agentId /** - * Returns the raw JSON value of [isSpam]. + * Returns the raw JSON value of [removeLabels]. * - * Unlike [isSpam], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [removeLabels], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("isSpam") @ExcludeMissing fun _isSpam(): JsonField = isSpam + @JsonProperty("removeLabels") + @ExcludeMissing + fun _removeLabels(): JsonField> = removeLabels @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -386,19 +417,45 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var addLabels: JsonField>? = null private var agentId: JsonField = JsonMissing.of() - private var isRead: JsonField = JsonMissing.of() - private var isSpam: JsonField = JsonMissing.of() + private var removeLabels: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + addLabels = body.addLabels.map { it.toMutableList() } agentId = body.agentId - isRead = body.isRead - isSpam = body.isSpam + removeLabels = body.removeLabels.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } + /** Labels to add to all messages in the thread. */ + fun addLabels(addLabels: List) = addLabels(JsonField.of(addLabels)) + + /** + * Sets [Builder.addLabels] to an arbitrary JSON value. + * + * You should usually call [Builder.addLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addLabels(addLabels: JsonField>) = apply { + this.addLabels = addLabels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addLabels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddLabel(addLabel: String) = apply { + addLabels = + (addLabels ?: JsonField.of(mutableListOf())).also { + checkKnown("addLabels", it).add(addLabel) + } + } + /** The AI agent identifier. */ fun agentId(agentId: String?) = agentId(JsonField.ofNullable(agentId)) @@ -414,29 +471,31 @@ private constructor( */ fun agentId(agentId: JsonField) = apply { this.agentId = agentId } - /** Mark the thread as read or unread. */ - fun isRead(isRead: Boolean) = isRead(JsonField.of(isRead)) + /** Labels to remove from all messages in the thread. */ + fun removeLabels(removeLabels: List) = removeLabels(JsonField.of(removeLabels)) /** - * Sets [Builder.isRead] to an arbitrary JSON value. + * Sets [Builder.removeLabels] to an arbitrary JSON value. * - * You should usually call [Builder.isRead] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.removeLabels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun isRead(isRead: JsonField) = apply { this.isRead = isRead } - - /** Mark the thread as spam or not spam. */ - fun isSpam(isSpam: Boolean) = isSpam(JsonField.of(isSpam)) + fun removeLabels(removeLabels: JsonField>) = apply { + this.removeLabels = removeLabels.map { it.toMutableList() } + } /** - * Sets [Builder.isSpam] to an arbitrary JSON value. + * Adds a single [String] to [removeLabels]. * - * You should usually call [Builder.isSpam] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun isSpam(isSpam: JsonField) = apply { this.isSpam = isSpam } + fun addRemoveLabel(removeLabel: String) = apply { + removeLabels = + (removeLabels ?: JsonField.of(mutableListOf())).also { + checkKnown("removeLabels", it).add(removeLabel) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -462,7 +521,13 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(agentId, isRead, isSpam, additionalProperties.toMutableMap()) + fun build(): Body = + Body( + (addLabels ?: JsonMissing.of()).map { it.toImmutable() }, + agentId, + (removeLabels ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -472,9 +537,9 @@ private constructor( return@apply } + addLabels() agentId() - isRead() - isSpam() + removeLabels() validated = true } @@ -494,9 +559,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (agentId.asKnown().isPresent) 1 else 0) + - (if (isRead.asKnown().isPresent) 1 else 0) + - (if (isSpam.asKnown().isPresent) 1 else 0) + (addLabels.asKnown().getOrNull()?.size ?: 0) + + (if (agentId.asKnown().isPresent) 1 else 0) + + (removeLabels.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -504,20 +569,20 @@ private constructor( } return other is Body && + addLabels == other.addLabels && agentId == other.agentId && - isRead == other.isRead && - isSpam == other.isSpam && + removeLabels == other.removeLabels && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(agentId, isRead, isSpam, additionalProperties) + Objects.hash(addLabels, agentId, removeLabels, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{agentId=$agentId, isRead=$isRead, isSpam=$isSpam, additionalProperties=$additionalProperties}" + "Body{addLabels=$addLabels, agentId=$agentId, removeLabels=$removeLabels, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/messages/MessageListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/messages/MessageListResponse.kt index 29eff86..eb1f3cb 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/messages/MessageListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/threads/messages/MessageListResponse.kt @@ -29,6 +29,7 @@ private constructor( private val cc: JsonField>, private val createdAt: JsonField, private val from: JsonField, + private val labels: JsonField>, private val messageId: JsonField, private val receivedAt: JsonField, private val replyTo: JsonField>, @@ -49,6 +50,7 @@ private constructor( @JsonProperty("cc") @ExcludeMissing cc: JsonField> = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("labels") @ExcludeMissing labels: JsonField> = JsonMissing.of(), @JsonProperty("messageId") @ExcludeMissing messageId: JsonField = JsonMissing.of(), @JsonProperty("receivedAt") @ExcludeMissing @@ -67,6 +69,7 @@ private constructor( cc, createdAt, from, + labels, messageId, receivedAt, replyTo, @@ -126,6 +129,14 @@ private constructor( */ fun from(): String = from.getRequired("from") + /** + * The message labels. + * + * @throws NuntlyInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun labels(): List = labels.getRequired("labels") + /** * The email Message-ID header. * @@ -226,6 +237,13 @@ private constructor( */ @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from + /** + * Returns the raw JSON value of [labels]. + * + * Unlike [labels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("labels") @ExcludeMissing fun _labels(): JsonField> = labels + /** * Returns the raw JSON value of [messageId]. * @@ -300,6 +318,7 @@ private constructor( * .cc() * .createdAt() * .from() + * .labels() * .messageId() * .receivedAt() * .replyTo() @@ -321,6 +340,7 @@ private constructor( private var cc: JsonField>? = null private var createdAt: JsonField? = null private var from: JsonField? = null + private var labels: JsonField>? = null private var messageId: JsonField? = null private var receivedAt: JsonField? = null private var replyTo: JsonField>? = null @@ -338,6 +358,7 @@ private constructor( cc = messageListResponse.cc.map { it.toMutableList() } createdAt = messageListResponse.createdAt from = messageListResponse.from + labels = messageListResponse.labels.map { it.toMutableList() } messageId = messageListResponse.messageId receivedAt = messageListResponse.receivedAt replyTo = messageListResponse.replyTo.map { it.toMutableList() } @@ -449,6 +470,32 @@ private constructor( */ fun from(from: JsonField) = apply { this.from = from } + /** The message labels. */ + fun labels(labels: List) = labels(JsonField.of(labels)) + + /** + * Sets [Builder.labels] to an arbitrary JSON value. + * + * You should usually call [Builder.labels] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun labels(labels: JsonField>) = apply { + this.labels = labels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [labels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLabel(label: String) = apply { + labels = + (labels ?: JsonField.of(mutableListOf())).also { + checkKnown("labels", it).add(label) + } + } + /** The email Message-ID header. */ fun messageId(messageId: String) = messageId(JsonField.of(messageId)) @@ -588,6 +635,7 @@ private constructor( * .cc() * .createdAt() * .from() + * .labels() * .messageId() * .receivedAt() * .replyTo() @@ -607,6 +655,7 @@ private constructor( checkRequired("cc", cc).map { it.toImmutable() }, checkRequired("createdAt", createdAt), checkRequired("from", from), + checkRequired("labels", labels).map { it.toImmutable() }, checkRequired("messageId", messageId), checkRequired("receivedAt", receivedAt), checkRequired("replyTo", replyTo).map { it.toImmutable() }, @@ -631,6 +680,7 @@ private constructor( cc() createdAt() from() + labels() messageId() receivedAt() replyTo() @@ -662,6 +712,7 @@ private constructor( (cc.asKnown().getOrNull()?.size ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (from.asKnown().isPresent) 1 else 0) + + (labels.asKnown().getOrNull()?.size ?: 0) + (if (messageId.asKnown().isPresent) 1 else 0) + (if (receivedAt.asKnown().isPresent) 1 else 0) + (replyTo.asKnown().getOrNull()?.size ?: 0) + @@ -820,6 +871,7 @@ private constructor( cc == other.cc && createdAt == other.createdAt && from == other.from && + labels == other.labels && messageId == other.messageId && receivedAt == other.receivedAt && replyTo == other.replyTo && @@ -838,6 +890,7 @@ private constructor( cc, createdAt, from, + labels, messageId, receivedAt, replyTo, @@ -852,5 +905,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MessageListResponse{id=$id, attachmentCount=$attachmentCount, bcc=$bcc, cc=$cc, createdAt=$createdAt, from=$from, messageId=$messageId, receivedAt=$receivedAt, replyTo=$replyTo, status=$status, subject=$subject, threadId=$threadId, to=$to, additionalProperties=$additionalProperties}" + "MessageListResponse{id=$id, attachmentCount=$attachmentCount, bcc=$bcc, cc=$cc, createdAt=$createdAt, from=$from, labels=$labels, messageId=$messageId, receivedAt=$receivedAt, replyTo=$replyTo, status=$status, subject=$subject, threadId=$threadId, to=$to, additionalProperties=$additionalProperties}" } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsync.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsync.kt index 80fc2a8..73b817a 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsync.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsync.kt @@ -13,6 +13,8 @@ import com.nuntly.models.messages.MessageListParams import com.nuntly.models.messages.MessageReplyParams import com.nuntly.models.messages.MessageReplyResponse import com.nuntly.models.messages.MessageRetrieveParams +import com.nuntly.models.messages.MessageUpdateParams +import com.nuntly.models.messages.MessageUpdateResponse import com.nuntly.services.async.messages.AttachmentServiceAsync import com.nuntly.services.async.messages.ContentServiceAsync import java.util.concurrent.CompletableFuture @@ -78,6 +80,41 @@ interface MessageServiceAsync { ): CompletableFuture = retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + /** Update message labels. Only available for messages in user-created inboxes. */ + fun update(messageId: String): CompletableFuture = + update(messageId, MessageUpdateParams.none()) + + /** @see update */ + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see update */ + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + ): CompletableFuture = update(messageId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: MessageUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(messageId, MessageUpdateParams.none(), requestOptions) + /** List all received messages across inboxes. */ fun list(): CompletableFuture = list(MessageListParams.none()) @@ -222,6 +259,47 @@ interface MessageServiceAsync { ): CompletableFuture> = retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `patch /messages/{messageId}`, but is otherwise the same + * as [MessageServiceAsync.update]. + */ + fun update(messageId: String): CompletableFuture> = + update(messageId, MessageUpdateParams.none()) + + /** @see update */ + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see update */ + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + ): CompletableFuture> = + update(messageId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: MessageUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(messageId, MessageUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /messages`, but is otherwise the same as * [MessageServiceAsync.list]. diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsyncImpl.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsyncImpl.kt index 1a862a8..34c0d7c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsyncImpl.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/MessageServiceAsyncImpl.kt @@ -26,6 +26,8 @@ import com.nuntly.models.messages.MessageListParams import com.nuntly.models.messages.MessageReplyParams import com.nuntly.models.messages.MessageReplyResponse import com.nuntly.models.messages.MessageRetrieveParams +import com.nuntly.models.messages.MessageUpdateParams +import com.nuntly.models.messages.MessageUpdateResponse import com.nuntly.services.async.messages.AttachmentServiceAsync import com.nuntly.services.async.messages.AttachmentServiceAsyncImpl import com.nuntly.services.async.messages.ContentServiceAsync @@ -70,6 +72,13 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl // get /messages/{messageId} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + override fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /messages/{messageId} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + override fun list( params: MessageListParams, requestOptions: RequestOptions, @@ -158,6 +167,41 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val updateHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .data() + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/ThreadServiceAsync.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/ThreadServiceAsync.kt index 070201d..d4b8ef8 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/ThreadServiceAsync.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/services/async/ThreadServiceAsync.kt @@ -37,7 +37,10 @@ interface ThreadServiceAsync { */ fun messages(): MessageServiceAsync - /** Retrieve a thread. Auto-marks as read. */ + /** + * Retrieve a thread. Pass ?markRead=true to automatically remove the unread label from all + * messages. + */ fun retrieve(threadId: String): CompletableFuture = retrieve(threadId, ThreadRetrieveParams.none()) @@ -69,7 +72,10 @@ interface ThreadServiceAsync { fun retrieve(threadId: String, requestOptions: RequestOptions): CompletableFuture = retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) - /** Update thread properties (read status, spam, agent). */ + /** + * Update thread labels and agent assignment. Label operations apply to all messages in the + * thread. + */ fun update(threadId: String): CompletableFuture = update(threadId, ThreadUpdateParams.none()) diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageService.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageService.kt index 3baff8a..23b6616 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageService.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageService.kt @@ -14,6 +14,8 @@ import com.nuntly.models.messages.MessageListParams import com.nuntly.models.messages.MessageReplyParams import com.nuntly.models.messages.MessageReplyResponse import com.nuntly.models.messages.MessageRetrieveParams +import com.nuntly.models.messages.MessageUpdateParams +import com.nuntly.models.messages.MessageUpdateResponse import com.nuntly.services.blocking.messages.AttachmentService import com.nuntly.services.blocking.messages.ContentService import java.util.function.Consumer @@ -74,6 +76,38 @@ interface MessageService { fun retrieve(messageId: String, requestOptions: RequestOptions): MessageDetail = retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + /** Update message labels. Only available for messages in user-created inboxes. */ + fun update(messageId: String): MessageUpdateResponse = + update(messageId, MessageUpdateParams.none()) + + /** @see update */ + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageUpdateResponse = + update(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see update */ + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + ): MessageUpdateResponse = update(messageId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageUpdateResponse + + /** @see update */ + fun update(params: MessageUpdateParams): MessageUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(messageId: String, requestOptions: RequestOptions): MessageUpdateResponse = + update(messageId, MessageUpdateParams.none(), requestOptions) + /** List all received messages across inboxes. */ fun list(): MessageListPage = list(MessageListParams.none()) @@ -209,6 +243,50 @@ interface MessageService { ): HttpResponseFor = retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `patch /messages/{messageId}`, but is otherwise the same + * as [MessageService.update]. + */ + @MustBeClosed + fun update(messageId: String): HttpResponseFor = + update(messageId, MessageUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + messageId: String, + params: MessageUpdateParams = MessageUpdateParams.none(), + ): HttpResponseFor = update(messageId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: MessageUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + messageId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(messageId, MessageUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /messages`, but is otherwise the same as * [MessageService.list]. diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageServiceImpl.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageServiceImpl.kt index 5ab2754..e7aaa07 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageServiceImpl.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/MessageServiceImpl.kt @@ -26,6 +26,8 @@ import com.nuntly.models.messages.MessageListParams import com.nuntly.models.messages.MessageReplyParams import com.nuntly.models.messages.MessageReplyResponse import com.nuntly.models.messages.MessageRetrieveParams +import com.nuntly.models.messages.MessageUpdateParams +import com.nuntly.models.messages.MessageUpdateResponse import com.nuntly.services.blocking.messages.AttachmentService import com.nuntly.services.blocking.messages.AttachmentServiceImpl import com.nuntly.services.blocking.messages.ContentService @@ -67,6 +69,13 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO // get /messages/{messageId} withRawResponse().retrieve(params, requestOptions).parse() + override fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions, + ): MessageUpdateResponse = + // patch /messages/{messageId} + withRawResponse().update(params, requestOptions).parse() + override fun list(params: MessageListParams, requestOptions: RequestOptions): MessageListPage = // get /messages withRawResponse().list(params, requestOptions).parse() @@ -149,6 +158,38 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO } } + private val updateHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun update( + params: MessageUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .data() + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/ThreadService.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/ThreadService.kt index 96ea06c..2c28adb 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/ThreadService.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/services/blocking/ThreadService.kt @@ -37,7 +37,10 @@ interface ThreadService { */ fun messages(): MessageService - /** Retrieve a thread. Auto-marks as read. */ + /** + * Retrieve a thread. Pass ?markRead=true to automatically remove the unread label from all + * messages. + */ fun retrieve(threadId: String): Thread = retrieve(threadId, ThreadRetrieveParams.none()) /** @see retrieve */ @@ -66,7 +69,10 @@ interface ThreadService { fun retrieve(threadId: String, requestOptions: RequestOptions): Thread = retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) - /** Update thread properties (read status, spam, agent). */ + /** + * Update thread labels and agent assignment. Label operations apply to all messages in the + * thread. + */ fun update(threadId: String): ThreadUpdateResponse = update(threadId, ThreadUpdateParams.none()) /** @see update */ diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponseTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponseTest.kt index 13a486f..5648463 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponseTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponseTest.kt @@ -22,8 +22,7 @@ internal class ThreadListPageResponseTest { .domainId("domainId") .domainName("domainName") .inboxId("inboxId") - .isRead(true) - .isSpam(true) + .addLabel("string") .lastMessageAt("lastMessageAt") .messageCount(0.0) .subject("subject") @@ -42,8 +41,7 @@ internal class ThreadListPageResponseTest { .domainId("domainId") .domainName("domainName") .inboxId("inboxId") - .isRead(true) - .isSpam(true) + .addLabel("string") .lastMessageAt("lastMessageAt") .messageCount(0.0) .subject("subject") @@ -66,8 +64,7 @@ internal class ThreadListPageResponseTest { .domainId("domainId") .domainName("domainName") .inboxId("inboxId") - .isRead(true) - .isSpam(true) + .addLabel("string") .lastMessageAt("lastMessageAt") .messageCount(0.0) .subject("subject") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListParamsTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListParamsTest.kt index da2f925..04b563c 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListParamsTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/inboxes/threads/ThreadListParamsTest.kt @@ -13,8 +13,7 @@ internal class ThreadListParamsTest { ThreadListParams.builder() .inboxId("ibx_01kabn43yqyxn2bx4ve84mczd3") .cursor("cursor") - .isRead(true) - .isSpam(true) + .labels("labels") .limit(1.0) .build() } @@ -34,8 +33,7 @@ internal class ThreadListParamsTest { ThreadListParams.builder() .inboxId("ibx_01kabn43yqyxn2bx4ve84mczd3") .cursor("cursor") - .isRead(true) - .isSpam(true) + .labels("labels") .limit(1.0) .build() @@ -45,8 +43,7 @@ internal class ThreadListParamsTest { .isEqualTo( QueryParams.builder() .put("cursor", "cursor") - .put("isRead", "true") - .put("isSpam", "true") + .put("labels", "labels") .put("limit", "1.0") .build() ) diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageDetailTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageDetailTest.kt index 0d7e666..acee59c 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageDetailTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageDetailTest.kt @@ -27,6 +27,7 @@ internal class MessageDetailTest { .build() ) .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -49,6 +50,7 @@ internal class MessageDetailTest { .build() ) assertThat(messageDetail.inboxId()).contains("inboxId") + assertThat(messageDetail.labels()).containsExactly("string") assertThat(messageDetail.messageId()).isEqualTo("messageId") assertThat(messageDetail.receivedAt()).isEqualTo("receivedAt") assertThat(messageDetail.replyTo().getOrNull()).containsExactly("string") @@ -75,6 +77,7 @@ internal class MessageDetailTest { .build() ) .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageListPageResponseTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageListPageResponseTest.kt index 5ca801c..786a09c 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageListPageResponseTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageListPageResponseTest.kt @@ -22,6 +22,7 @@ internal class MessageListPageResponseTest { .createdAt("createdAt") .from("from") .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -44,6 +45,7 @@ internal class MessageListPageResponseTest { .createdAt("createdAt") .from("from") .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -70,6 +72,7 @@ internal class MessageListPageResponseTest { .createdAt("createdAt") .from("from") .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageTest.kt index 81152e4..92c198e 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageTest.kt @@ -21,6 +21,7 @@ internal class MessageTest { .createdAt("createdAt") .from("from") .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -37,6 +38,7 @@ internal class MessageTest { assertThat(message.createdAt()).isEqualTo("createdAt") assertThat(message.from()).isEqualTo("from") assertThat(message.inboxId()).contains("inboxId") + assertThat(message.labels()).containsExactly("string") assertThat(message.messageId()).isEqualTo("messageId") assertThat(message.receivedAt()).isEqualTo("receivedAt") assertThat(message.replyTo().getOrNull()).containsExactly("string") @@ -58,6 +60,7 @@ internal class MessageTest { .createdAt("createdAt") .from("from") .inboxId("inboxId") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateParamsTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateParamsTest.kt new file mode 100644 index 0000000..38f16de --- /dev/null +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.nuntly.models.messages + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageUpdateParamsTest { + + @Test + fun create() { + MessageUpdateParams.builder() + .messageId("imsg_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") + .addRemoveLabel("x") + .build() + } + + @Test + fun pathParams() { + val params = + MessageUpdateParams.builder().messageId("imsg_01kabn43yqyxn2bx4ve84mczd3").build() + + assertThat(params._pathParam(0)).isEqualTo("imsg_01kabn43yqyxn2bx4ve84mczd3") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + MessageUpdateParams.builder() + .messageId("imsg_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") + .addRemoveLabel("x") + .build() + + val body = params._body() + + assertThat(body.addLabels().getOrNull()).containsExactly("x") + assertThat(body.removeLabels().getOrNull()).containsExactly("x") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + MessageUpdateParams.builder().messageId("imsg_01kabn43yqyxn2bx4ve84mczd3").build() + + val body = params._body() + } +} diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateResponseTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateResponseTest.kt new file mode 100644 index 0000000..0d56210 --- /dev/null +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/messages/MessageUpdateResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.nuntly.models.messages + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.nuntly.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageUpdateResponseTest { + + @Test + fun create() { + val messageUpdateResponse = MessageUpdateResponse.builder().id("id").build() + + assertThat(messageUpdateResponse.id()).isEqualTo("id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageUpdateResponse = MessageUpdateResponse.builder().id("id").build() + + val roundtrippedMessageUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageUpdateResponse).isEqualTo(messageUpdateResponse) + } +} diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadRetrieveParamsTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadRetrieveParamsTest.kt index 3186886..d613fd9 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadRetrieveParamsTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadRetrieveParamsTest.kt @@ -2,6 +2,7 @@ package com.nuntly.models.threads +import com.nuntly.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -9,7 +10,10 @@ internal class ThreadRetrieveParamsTest { @Test fun create() { - ThreadRetrieveParams.builder().threadId("thr_01kabn43yqyxn2bx4ve84mczd3").build() + ThreadRetrieveParams.builder() + .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .markRead("markRead") + .build() } @Test @@ -21,4 +25,27 @@ internal class ThreadRetrieveParamsTest { // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } + + @Test + fun queryParams() { + val params = + ThreadRetrieveParams.builder() + .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .markRead("markRead") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("markRead", "markRead").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ThreadRetrieveParams.builder().threadId("thr_01kabn43yqyxn2bx4ve84mczd3").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } } diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadTest.kt index 8850517..56470f5 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadTest.kt @@ -19,8 +19,7 @@ internal class ThreadTest { .domainId("domainId") .domainName("domainName") .inboxId("inboxId") - .isRead(true) - .isSpam(true) + .addLabel("string") .lastMessageAt("lastMessageAt") .messageCount(0.0) .subject("subject") @@ -33,8 +32,7 @@ internal class ThreadTest { assertThat(thread.domainId()).contains("domainId") assertThat(thread.domainName()).isEqualTo("domainName") assertThat(thread.inboxId()).isEqualTo("inboxId") - assertThat(thread.isRead()).isEqualTo(true) - assertThat(thread.isSpam()).isEqualTo(true) + assertThat(thread.labels()).containsExactly("string") assertThat(thread.lastMessageAt()).isEqualTo("lastMessageAt") assertThat(thread.messageCount()).isEqualTo(0.0) assertThat(thread.subject()).isEqualTo("subject") @@ -52,8 +50,7 @@ internal class ThreadTest { .domainId("domainId") .domainName("domainName") .inboxId("inboxId") - .isRead(true) - .isSpam(true) + .addLabel("string") .lastMessageAt("lastMessageAt") .messageCount(0.0) .subject("subject") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadUpdateParamsTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadUpdateParamsTest.kt index 7659fd4..682d453 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadUpdateParamsTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/ThreadUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.nuntly.models.threads +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,9 +12,9 @@ internal class ThreadUpdateParamsTest { fun create() { ThreadUpdateParams.builder() .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") .agentId("agentId") - .isRead(true) - .isSpam(true) + .addRemoveLabel("x") .build() } @@ -31,16 +32,16 @@ internal class ThreadUpdateParamsTest { val params = ThreadUpdateParams.builder() .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") .agentId("agentId") - .isRead(true) - .isSpam(true) + .addRemoveLabel("x") .build() val body = params._body() + assertThat(body.addLabels().getOrNull()).containsExactly("x") assertThat(body.agentId()).contains("agentId") - assertThat(body.isRead()).contains(true) - assertThat(body.isSpam()).contains(true) + assertThat(body.removeLabels().getOrNull()).containsExactly("x") } @Test diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListPageResponseTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListPageResponseTest.kt index 6d4b832..c44c0f5 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListPageResponseTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListPageResponseTest.kt @@ -21,6 +21,7 @@ internal class MessageListPageResponseTest { .addCc("string") .createdAt("createdAt") .from("from") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -42,6 +43,7 @@ internal class MessageListPageResponseTest { .addCc("string") .createdAt("createdAt") .from("from") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -67,6 +69,7 @@ internal class MessageListPageResponseTest { .addCc("string") .createdAt("createdAt") .from("from") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListResponseTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListResponseTest.kt index 003d372..a838628 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListResponseTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/models/threads/messages/MessageListResponseTest.kt @@ -20,6 +20,7 @@ internal class MessageListResponseTest { .addCc("string") .createdAt("createdAt") .from("from") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") @@ -35,6 +36,7 @@ internal class MessageListResponseTest { assertThat(messageListResponse.cc().getOrNull()).containsExactly("string") assertThat(messageListResponse.createdAt()).isEqualTo("createdAt") assertThat(messageListResponse.from()).isEqualTo("from") + assertThat(messageListResponse.labels()).containsExactly("string") assertThat(messageListResponse.messageId()).isEqualTo("messageId") assertThat(messageListResponse.receivedAt()).isEqualTo("receivedAt") assertThat(messageListResponse.replyTo().getOrNull()).containsExactly("string") @@ -55,6 +57,7 @@ internal class MessageListResponseTest { .addCc("string") .createdAt("createdAt") .from("from") + .addLabel("string") .messageId("messageId") .receivedAt("receivedAt") .addReplyTo("string") diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/MessageServiceAsyncTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/MessageServiceAsyncTest.kt index eafd47f..0dfe1c5 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/MessageServiceAsyncTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/MessageServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.nuntly.TestServerExtension import com.nuntly.client.okhttp.NuntlyOkHttpClientAsync import com.nuntly.models.messages.MessageForwardParams import com.nuntly.models.messages.MessageReplyParams +import com.nuntly.models.messages.MessageUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -27,6 +28,28 @@ internal class MessageServiceAsyncTest { messageDetail.validate() } + @Test + fun update() { + val client = + NuntlyOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageServiceAsync = client.messages() + + val messageFuture = + messageServiceAsync.update( + MessageUpdateParams.builder() + .messageId("imsg_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") + .addRemoveLabel("x") + .build() + ) + + val message = messageFuture.get() + message.validate() + } + @Test fun list() { val client = diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/ThreadServiceAsyncTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/ThreadServiceAsyncTest.kt index e1460a2..0292cfd 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/ThreadServiceAsyncTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/services/async/ThreadServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.nuntly.services.async import com.nuntly.TestServerExtension import com.nuntly.client.okhttp.NuntlyOkHttpClientAsync +import com.nuntly.models.threads.ThreadRetrieveParams import com.nuntly.models.threads.ThreadUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,7 +21,13 @@ internal class ThreadServiceAsyncTest { .build() val threadServiceAsync = client.threads() - val threadFuture = threadServiceAsync.retrieve("thr_01kabn43yqyxn2bx4ve84mczd3") + val threadFuture = + threadServiceAsync.retrieve( + ThreadRetrieveParams.builder() + .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .markRead("markRead") + .build() + ) val thread = threadFuture.get() thread.validate() @@ -39,9 +46,9 @@ internal class ThreadServiceAsyncTest { threadServiceAsync.update( ThreadUpdateParams.builder() .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") .agentId("agentId") - .isRead(true) - .isSpam(true) + .addRemoveLabel("x") .build() ) diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/MessageServiceTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/MessageServiceTest.kt index 3cd702f..ebffb18 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/MessageServiceTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/MessageServiceTest.kt @@ -6,6 +6,7 @@ import com.nuntly.TestServerExtension import com.nuntly.client.okhttp.NuntlyOkHttpClient import com.nuntly.models.messages.MessageForwardParams import com.nuntly.models.messages.MessageReplyParams +import com.nuntly.models.messages.MessageUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,6 +27,27 @@ internal class MessageServiceTest { messageDetail.validate() } + @Test + fun update() { + val client = + NuntlyOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageService = client.messages() + + val message = + messageService.update( + MessageUpdateParams.builder() + .messageId("imsg_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") + .addRemoveLabel("x") + .build() + ) + + message.validate() + } + @Test fun list() { val client = diff --git a/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/ThreadServiceTest.kt b/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/ThreadServiceTest.kt index a11d08f..c4a81be 100644 --- a/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/ThreadServiceTest.kt +++ b/nuntly-java-core/src/test/kotlin/com/nuntly/services/blocking/ThreadServiceTest.kt @@ -4,6 +4,7 @@ package com.nuntly.services.blocking import com.nuntly.TestServerExtension import com.nuntly.client.okhttp.NuntlyOkHttpClient +import com.nuntly.models.threads.ThreadRetrieveParams import com.nuntly.models.threads.ThreadUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,7 +21,13 @@ internal class ThreadServiceTest { .build() val threadService = client.threads() - val thread = threadService.retrieve("thr_01kabn43yqyxn2bx4ve84mczd3") + val thread = + threadService.retrieve( + ThreadRetrieveParams.builder() + .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .markRead("markRead") + .build() + ) thread.validate() } @@ -38,9 +45,9 @@ internal class ThreadServiceTest { threadService.update( ThreadUpdateParams.builder() .threadId("thr_01kabn43yqyxn2bx4ve84mczd3") + .addAddLabel("x") .agentId("agentId") - .isRead(true) - .isSpam(true) + .addRemoveLabel("x") .build() ) From 0043aa083c9f94bd71e9be4552431ffee23c76c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 02:33:20 +0000 Subject: [PATCH 07/16] chore(tests): bump steady to v0.22.1 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 5cd7c15..feebe5e 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.20.2 -- steady --version + npm exec --package=@stdy/cli@0.22.1 -- steady --version - npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 61c1163..7d7f08e 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From fba15cddd34b79348161aa1036496e5aeb9e3170 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 02:07:21 +0000 Subject: [PATCH 08/16] feat: support setting headers via env --- .../src/main/kotlin/com/nuntly/core/ClientOptions.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt index 5dcce5c..0c97306 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt @@ -409,6 +409,14 @@ private constructor( (System.getProperty("nuntly.apiKey") ?: System.getenv("NUNTLY_API_KEY"))?.let { apiKey(it) } + System.getenv("NUNTLY_CUSTOM_HEADERS")?.let { customHeadersEnv -> + for (line in customHeadersEnv.split("\n")) { + val colon = line.indexOf(':') + if (colon >= 0) { + putHeader(line.substring(0, colon).trim(), line.substring(colon + 1).trim()) + } + } + } } /** From c607bbea76f94f9c69ae8e225da29211d3719bfb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 08:31:37 +0000 Subject: [PATCH 09/16] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b4d4e48..9318ce8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 56 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/bazoud-corp%2Fnuntly-68da5d8336861a0f3138393f343d443a1b446ef8c5b0572e8278e9a7c93b2747.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/bazoud-corp/nuntly-68da5d8336861a0f3138393f343d443a1b446ef8c5b0572e8278e9a7c93b2747.yml openapi_spec_hash: 3e951a779e301ace98f73eabfe149e9b config_hash: cf044f6bbd66c7aaf276100fe2f65f7e From 15c00eda9e937c17791afb56147652b1ee825e82 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 03:39:44 +0000 Subject: [PATCH 10/16] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9318ce8..54e4c4e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 56 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/bazoud-corp/nuntly-68da5d8336861a0f3138393f343d443a1b446ef8c5b0572e8278e9a7c93b2747.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/bazoud-corp/nuntly-8c62ff49f7cf36d877996fed2351b4e8e81f2397f5c7cb9d54b417f37cda8cd7.yml openapi_spec_hash: 3e951a779e301ace98f73eabfe149e9b config_hash: cf044f6bbd66c7aaf276100fe2f65f7e From 3dfae7a1b98935aba71e07f06e13f2e68888203d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 04:02:05 +0000 Subject: [PATCH 11/16] docs: clarify forwards compat behavior --- README.md | 4 +- .../client/okhttp/NuntlyOkHttpClient.kt | 3 + .../client/okhttp/NuntlyOkHttpClientAsync.kt | 3 + .../kotlin/com/nuntly/core/ClientOptions.kt | 6 + .../kotlin/com/nuntly/core/RequestOptions.kt | 9 + .../kotlin/com/nuntly/models/DataEnvelope.kt | 8 + .../com/nuntly/models/agents/AgentMemory.kt | 17 + .../agents/memory/MemoryUpsertParams.kt | 18 + .../models/apikeys/ApiKeyCreateParams.kt | 27 ++ .../models/apikeys/ApiKeyCreateResponse.kt | 17 + .../models/apikeys/ApiKeyDeleteResponse.kt | 8 + .../models/apikeys/ApiKeyListPageResponse.kt | 8 + .../models/apikeys/ApiKeyListResponse.kt | 17 + .../models/apikeys/ApiKeyRetrieveResponse.kt | 17 + .../models/apikeys/ApiKeyUpdateParams.kt | 27 ++ .../models/apikeys/ApiKeyUpdateResponse.kt | 8 + .../models/domains/DomainCreateParams.kt | 9 + .../models/domains/DomainCreateResponse.kt | 83 ++++ .../models/domains/DomainDeleteResponse.kt | 8 + .../models/domains/DomainListPageResponse.kt | 8 + .../models/domains/DomainListResponse.kt | 44 ++ .../models/domains/DomainRetrieveResponse.kt | 83 ++++ .../models/domains/DomainUpdateParams.kt | 9 + .../models/domains/DomainUpdateResponse.kt | 8 + .../models/emails/EmailCancelResponse.kt | 8 + .../nuntly/models/emails/EmailContentItem.kt | 8 + .../models/emails/EmailListPageResponse.kt | 8 + .../nuntly/models/emails/EmailListResponse.kt | 46 +++ .../models/emails/EmailRetrieveResponse.kt | 196 +++++++++ .../nuntly/models/emails/EmailSendParams.kt | 188 +++++++++ .../nuntly/models/emails/EmailSendResponse.kt | 8 + .../kotlin/com/nuntly/models/emails/Status.kt | 8 + .../kotlin/com/nuntly/models/emails/Tag.kt | 8 + .../emails/bulk/BulkRetrieveResponse.kt | 17 + .../models/emails/bulk/BulkSendParams.kt | 387 ++++++++++++++++++ .../models/emails/bulk/BulkSendResponse.kt | 17 + .../emails/content/ContentRetrieveResponse.kt | 8 + .../models/emails/events/EventListResponse.kt | 8 + .../models/emails/stats/StatListResponse.kt | 17 + .../kotlin/com/nuntly/models/inboxes/Inbox.kt | 8 + .../models/inboxes/InboxCreateParams.kt | 9 + .../models/inboxes/InboxDeleteResponse.kt | 8 + .../models/inboxes/InboxListPageResponse.kt | 8 + .../nuntly/models/inboxes/InboxSendParams.kt | 9 + .../models/inboxes/InboxSendResponse.kt | 8 + .../models/inboxes/InboxUpdateParams.kt | 9 + .../models/inboxes/InboxUpdateResponse.kt | 8 + .../inboxes/threads/ThreadListPageResponse.kt | 8 + .../com/nuntly/models/messages/Message.kt | 17 + .../models/messages/MessageAttachment.kt | 8 + .../nuntly/models/messages/MessageContent.kt | 8 + .../models/messages/MessageContentItem.kt | 8 + .../nuntly/models/messages/MessageDetail.kt | 26 ++ .../models/messages/MessageForwardParams.kt | 9 + .../models/messages/MessageForwardResponse.kt | 8 + .../messages/MessageListPageResponse.kt | 8 + .../models/messages/MessageReplyParams.kt | 9 + .../models/messages/MessageReplyResponse.kt | 8 + .../models/messages/MessageUpdateParams.kt | 9 + .../models/messages/MessageUpdateResponse.kt | 8 + .../messages/content/ContentRetrieveParams.kt | 9 + .../com/nuntly/models/namespaces/Namespace.kt | 8 + .../namespaces/NamespaceCreateParams.kt | 9 + .../namespaces/NamespaceDeleteResponse.kt | 8 + .../models/namespaces/NamespaceDetail.kt | 8 + .../namespaces/NamespaceListPageResponse.kt | 8 + .../namespaces/NamespaceUpdateParams.kt | 9 + .../namespaces/NamespaceUpdateResponse.kt | 8 + .../inboxes/InboxListPageResponse.kt | 8 + .../OrganizationListPageResponse.kt | 8 + .../organizations/OrganizationListResponse.kt | 17 + .../OrganizationRetrieveResponse.kt | 17 + .../usage/UsageRetrieveResponse.kt | 57 +++ .../com/nuntly/models/shared/EventType.kt | 8 + .../com/nuntly/models/threads/Thread.kt | 8 + .../models/threads/ThreadUpdateParams.kt | 9 + .../models/threads/ThreadUpdateResponse.kt | 8 + .../messages/MessageListPageResponse.kt | 8 + .../threads/messages/MessageListResponse.kt | 17 + .../models/webhooks/EmailBouncedEvent.kt | 246 +++++++++++ .../models/webhooks/EmailClickedEvent.kt | 216 ++++++++++ .../models/webhooks/EmailComplainedEvent.kt | 246 +++++++++++ .../models/webhooks/EmailDeliveredEvent.kt | 216 ++++++++++ .../webhooks/EmailDeliveryDelayedEvent.kt | 236 +++++++++++ .../models/webhooks/EmailFailedEvent.kt | 207 ++++++++++ .../models/webhooks/EmailOpenedEvent.kt | 216 ++++++++++ .../models/webhooks/EmailProcessedEvent.kt | 26 ++ .../models/webhooks/EmailQueuedEvent.kt | 26 ++ .../models/webhooks/EmailRejectedEvent.kt | 207 ++++++++++ .../models/webhooks/EmailScheduledEvent.kt | 36 ++ .../models/webhooks/EmailSendingEvent.kt | 206 ++++++++++ .../nuntly/models/webhooks/EmailSentEvent.kt | 206 ++++++++++ .../com/nuntly/models/webhooks/Event.kt | 66 +++ .../webhooks/MessageAgentTriggeredEvent.kt | 26 ++ .../models/webhooks/MessageReceivedEvent.kt | 26 ++ .../webhooks/MessageSecurityFlaggedEvent.kt | 26 ++ .../models/webhooks/MessageSentEvent.kt | 26 ++ .../models/webhooks/UnwrapWebhookEvent.kt | 66 +++ .../models/webhooks/WebhookCreateParams.kt | 18 + .../models/webhooks/WebhookCreateResponse.kt | 17 + .../models/webhooks/WebhookDeleteResponse.kt | 8 + .../webhooks/WebhookListPageResponse.kt | 8 + .../models/webhooks/WebhookListResponse.kt | 17 + .../webhooks/WebhookRetrieveResponse.kt | 17 + .../models/webhooks/WebhookUpdateParams.kt | 18 + .../models/webhooks/WebhookUpdateResponse.kt | 8 + .../events/EventDeliveriesResponse.kt | 26 ++ .../webhooks/events/EventListPageResponse.kt | 8 + .../webhooks/events/EventListResponse.kt | 26 ++ .../webhooks/events/EventReplayResponse.kt | 8 + 110 files changed, 4518 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b84b66f..48d7b0a 100644 --- a/README.md +++ b/README.md @@ -700,7 +700,9 @@ In rare cases, the API may return a response that doesn't match the expected typ By default, the SDK will not throw an exception in this case. It will throw [`NuntlyInvalidDataException`](nuntly-java-core/src/main/kotlin/com/nuntly/errors/NuntlyInvalidDataException.kt) only if you directly access the property. -If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: +Validating the response is _not_ forwards compatible with new types from the API for existing fields. + +If you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java import com.nuntly.models.emails.EmailSendResponse; diff --git a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt index 1bfd88d..7b86bf6 100644 --- a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt +++ b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt @@ -230,6 +230,9 @@ class NuntlyOkHttpClient private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ diff --git a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt index c5a2ff4..ec34703 100644 --- a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt +++ b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt @@ -230,6 +230,9 @@ class NuntlyOkHttpClientAsync private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt index 0c97306..083455c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/core/ClientOptions.kt @@ -80,6 +80,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for existing + * fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -261,6 +264,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/core/RequestOptions.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/core/RequestOptions.kt index 7500bcd..62782b4 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/core/RequestOptions.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/core/RequestOptions.kt @@ -33,6 +33,15 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t private var responseValidation: Boolean? = null private var timeout: Timeout? = null + /** + * Whether to call `validate` on the response before returning it. + * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/DataEnvelope.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/DataEnvelope.kt index f4013e1..b3d5adf 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/DataEnvelope.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/DataEnvelope.kt @@ -43,6 +43,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DataEnvelope = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/AgentMemory.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/AgentMemory.kt index 65d2c0d..c98eae5 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/AgentMemory.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/AgentMemory.kt @@ -373,6 +373,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AgentMemory = apply { if (validated) { return@apply @@ -472,6 +480,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Memory = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/memory/MemoryUpsertParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/memory/MemoryUpsertParams.kt index 9faab49..8eb6bc2 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/memory/MemoryUpsertParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/agents/memory/MemoryUpsertParams.kt @@ -560,6 +560,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -675,6 +684,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Memory = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateParams.kt index 9b33159..413d503 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateParams.kt @@ -545,6 +545,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -691,6 +700,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Permission = apply { if (validated) { return@apply @@ -823,6 +841,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateResponse.kt index 489bc79..c5da27c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyCreateResponse.kt @@ -266,6 +266,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ApiKeyCreateResponse = apply { if (validated) { return@apply @@ -394,6 +402,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyDeleteResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyDeleteResponse.kt index 636f195..691667f 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyDeleteResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyDeleteResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ApiKeyDeleteResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListPageResponse.kt index fbaf6a3..66e502f 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListPageResponse.kt @@ -178,6 +178,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ApiKeyListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListResponse.kt index ed5fe11..d25ad0b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyListResponse.kt @@ -267,6 +267,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ApiKeyListResponse = apply { if (validated) { return@apply @@ -395,6 +403,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyRetrieveResponse.kt index 28a0984..7291633 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyRetrieveResponse.kt @@ -267,6 +267,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ApiKeyRetrieveResponse = apply { if (validated) { return@apply @@ -395,6 +403,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateParams.kt index 4453c96..8e038b0 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateParams.kt @@ -583,6 +583,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -729,6 +738,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Permission = apply { if (validated) { return@apply @@ -854,6 +872,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateResponse.kt index 0ec1010..17b70bc 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/apikeys/ApiKeyUpdateResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ApiKeyUpdateResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateParams.kt index 3728f11..de2939d 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateParams.kt @@ -479,6 +479,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateResponse.kt index 46dcfef..e8399c9 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainCreateResponse.kt @@ -679,6 +679,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DomainCreateResponse = apply { if (validated) { return@apply @@ -843,6 +851,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReceivingStatus = apply { if (validated) { return@apply @@ -1335,6 +1352,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Record = apply { if (validated) { return@apply @@ -1490,6 +1516,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Group = apply { if (validated) { return@apply @@ -1628,6 +1664,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): RecordType = apply { if (validated) { return@apply @@ -1776,6 +1822,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -1937,6 +1993,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Region = apply { if (validated) { return@apply @@ -2073,6 +2138,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SendingStatus = apply { if (validated) { return@apply @@ -2217,6 +2291,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainDeleteResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainDeleteResponse.kt index 45e8925..87fd700 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainDeleteResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainDeleteResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DomainDeleteResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListPageResponse.kt index b6df5ee..a5e3bd3 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListPageResponse.kt @@ -178,6 +178,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DomainListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListResponse.kt index a45709e..3477b25 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainListResponse.kt @@ -346,6 +346,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DomainListResponse = apply { if (validated) { return@apply @@ -494,6 +502,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReceivingStatus = apply { if (validated) { return@apply @@ -614,6 +631,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Region = apply { if (validated) { return@apply @@ -750,6 +776,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SendingStatus = apply { if (validated) { return@apply @@ -894,6 +929,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainRetrieveResponse.kt index 2c99ce4..f275409 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainRetrieveResponse.kt @@ -679,6 +679,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DomainRetrieveResponse = apply { if (validated) { return@apply @@ -843,6 +851,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReceivingStatus = apply { if (validated) { return@apply @@ -1335,6 +1352,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Record = apply { if (validated) { return@apply @@ -1490,6 +1516,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Group = apply { if (validated) { return@apply @@ -1628,6 +1664,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): RecordType = apply { if (validated) { return@apply @@ -1776,6 +1822,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -1937,6 +1993,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Region = apply { if (validated) { return@apply @@ -2073,6 +2138,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SendingStatus = apply { if (validated) { return@apply @@ -2217,6 +2291,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateParams.kt index 937fee1..6d35ae5 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateParams.kt @@ -549,6 +549,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateResponse.kt index df268ed..eff14a8 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/domains/DomainUpdateResponse.kt @@ -210,6 +210,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DomainUpdateResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailCancelResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailCancelResponse.kt index eaf3e29..4e662b1 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailCancelResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailCancelResponse.kt @@ -164,6 +164,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailCancelResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailContentItem.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailContentItem.kt index 286a1a5..8f7e2be 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailContentItem.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailContentItem.kt @@ -212,6 +212,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailContentItem = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListPageResponse.kt index 682eb8d..c04927b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListPageResponse.kt @@ -177,6 +177,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListResponse.kt index 0f6d113..092e17f 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailListResponse.kt @@ -350,6 +350,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailListResponse = apply { if (validated) { return@apply @@ -412,6 +420,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -421,6 +458,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailRetrieveResponse.kt index 8c15cd6..450fb30 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailRetrieveResponse.kt @@ -775,6 +775,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailRetrieveResponse = apply { if (validated) { return@apply @@ -859,6 +867,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -868,6 +905,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1171,6 +1217,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Attachment = apply { if (validated) { return@apply @@ -1248,6 +1303,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1257,6 +1341,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1415,6 +1508,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1424,6 +1546,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1617,6 +1748,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Headers = apply { if (validated) { return@apply @@ -1685,6 +1825,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1694,6 +1863,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -1891,6 +2069,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StatusReason = apply { if (validated) { return@apply @@ -1991,6 +2178,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Variables = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendParams.kt index c91a60e..caabb17 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendParams.kt @@ -1210,6 +1210,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1332,6 +1341,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1341,6 +1379,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1661,6 +1708,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Attachment = apply { if (validated) { return@apply @@ -1738,6 +1794,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1747,6 +1832,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1905,6 +1999,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1914,6 +2037,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -2107,6 +2239,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Headers = apply { if (validated) { return@apply @@ -2175,6 +2316,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -2184,6 +2354,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2381,6 +2560,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Variables = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendResponse.kt index 6ffea56..30affae 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/EmailSendResponse.kt @@ -164,6 +164,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailSendResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/Status.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/Status.kt index 8fd6196..a9af90b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/Status.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/Status.kt @@ -147,6 +147,14 @@ class Status @JsonCreator private constructor(private val value: JsonField = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1106,6 +1154,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1268,6 +1326,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1277,6 +1365,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1475,6 +1573,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Headers = apply { if (validated) { return@apply @@ -1543,6 +1651,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1552,6 +1690,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -1715,6 +1863,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -1724,6 +1902,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1922,6 +2110,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Variables = apply { if (validated) { return@apply @@ -2527,6 +2725,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Fallback = apply { if (validated) { return@apply @@ -2600,6 +2807,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -2609,6 +2846,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -2771,6 +3018,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -2780,6 +3057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -2978,6 +3265,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Headers = apply { if (validated) { return@apply @@ -3046,6 +3343,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -3055,6 +3382,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -3218,6 +3555,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitStrings(List strings) { + * return Optional.of(strings.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) @@ -3227,6 +3594,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -3425,6 +3802,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Variables = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/bulk/BulkSendResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/bulk/BulkSendResponse.kt index 2c19df0..9612276 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/bulk/BulkSendResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/bulk/BulkSendResponse.kt @@ -178,6 +178,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkSendResponse = apply { if (validated) { return@apply @@ -350,6 +358,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Email = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/content/ContentRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/content/ContentRetrieveResponse.kt index 2226d09..736b1e7 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/content/ContentRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/content/ContentRetrieveResponse.kt @@ -347,6 +347,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ContentRetrieveResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/events/EventListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/events/EventListResponse.kt index 9b7f2e7..2533abc 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/events/EventListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/events/EventListResponse.kt @@ -316,6 +316,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventListResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/stats/StatListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/stats/StatListResponse.kt index 95abd2e..c55de2b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/stats/StatListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/emails/stats/StatListResponse.kt @@ -210,6 +210,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StatListResponse = apply { if (validated) { return@apply @@ -1008,6 +1016,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Stat = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/Inbox.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/Inbox.kt index bb8935c..8aa7702 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/Inbox.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/Inbox.kt @@ -468,6 +468,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Inbox = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxCreateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxCreateParams.kt index 0eae66c..7c9b94e 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxCreateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxCreateParams.kt @@ -606,6 +606,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxDeleteResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxDeleteResponse.kt index 1353c32..8f3e58e 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxDeleteResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxDeleteResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InboxDeleteResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxListPageResponse.kt index 1687db0..ae92378 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxListPageResponse.kt @@ -175,6 +175,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InboxListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendParams.kt index 3bb69bf..d246d3c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendParams.kt @@ -733,6 +733,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendResponse.kt index 2a84170..dbeb9d6 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxSendResponse.kt @@ -230,6 +230,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InboxSendResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateParams.kt index 92314b6..34116a4 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateParams.kt @@ -351,6 +351,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateResponse.kt index 8dfa2d6..890105b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/InboxUpdateResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InboxUpdateResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponse.kt index 70806d7..5b011e2 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/inboxes/threads/ThreadListPageResponse.kt @@ -176,6 +176,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ThreadListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt index 2c88339..1476117 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/Message.kt @@ -706,6 +706,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Message = apply { if (validated) { return@apply @@ -860,6 +868,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageAttachment.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageAttachment.kt index 67bfc01..7c267f3 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageAttachment.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageAttachment.kt @@ -366,6 +366,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageAttachment = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContent.kt index edebecc..a0c27b0 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContent.kt @@ -218,6 +218,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageContent = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContentItem.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContentItem.kt index d2bd934..f523e6b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContentItem.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageContentItem.kt @@ -212,6 +212,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageContentItem = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt index 3c70703..db87a95 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageDetail.kt @@ -743,6 +743,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageDetail = apply { if (validated) { return@apply @@ -858,6 +866,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Headers = apply { if (validated) { return@apply @@ -999,6 +1016,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardParams.kt index 95fd1de..e939415 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardParams.kt @@ -454,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardResponse.kt index 0e78efb..8b636bd 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageForwardResponse.kt @@ -230,6 +230,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageForwardResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageListPageResponse.kt index 5908848..a5490fe 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageListPageResponse.kt @@ -175,6 +175,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyParams.kt index c5ea7c3..3291537 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyParams.kt @@ -464,6 +464,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyResponse.kt index dc5209a..4b896c2 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageReplyResponse.kt @@ -230,6 +230,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageReplyResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt index 25d8e1c..0c6ddf6 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateParams.kt @@ -465,6 +465,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt index dceaabd..47f14ae 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/MessageUpdateResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageUpdateResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/content/ContentRetrieveParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/content/ContentRetrieveParams.kt index 760be4b..9f1030a 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/content/ContentRetrieveParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/messages/content/ContentRetrieveParams.kt @@ -304,6 +304,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Format = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/Namespace.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/Namespace.kt index 43784a7..4ef36bb 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/Namespace.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/Namespace.kt @@ -270,6 +270,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Namespace = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceCreateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceCreateParams.kt index e379615..5cef23d 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceCreateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceCreateParams.kt @@ -418,6 +418,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDeleteResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDeleteResponse.kt index 2fd5122..f2b24bc 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDeleteResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDeleteResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): NamespaceDeleteResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDetail.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDetail.kt index d9b3237..0213959 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDetail.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceDetail.kt @@ -357,6 +357,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): NamespaceDetail = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceListPageResponse.kt index 8fe094a..0cf6c86 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceListPageResponse.kt @@ -175,6 +175,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): NamespaceListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateParams.kt index 315694c..330ceff 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateParams.kt @@ -414,6 +414,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateResponse.kt index 4b27fc1..2e04a7b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/NamespaceUpdateResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): NamespaceUpdateResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/inboxes/InboxListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/inboxes/InboxListPageResponse.kt index ee065e0..e405df1 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/inboxes/InboxListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/namespaces/inboxes/InboxListPageResponse.kt @@ -176,6 +176,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InboxListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListPageResponse.kt index c16564f..ee06a8f 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListPageResponse.kt @@ -179,6 +179,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): OrganizationListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListResponse.kt index 70b0be1..85b213e 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationListResponse.kt @@ -198,6 +198,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): OrganizationListResponse = apply { if (validated) { return@apply @@ -316,6 +324,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationRetrieveResponse.kt index de82948..2a55128 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/OrganizationRetrieveResponse.kt @@ -198,6 +198,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): OrganizationRetrieveResponse = apply { if (validated) { return@apply @@ -316,6 +324,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/usage/UsageRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/usage/UsageRetrieveResponse.kt index 0897413..76195a8 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/usage/UsageRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/organizations/usage/UsageRetrieveResponse.kt @@ -135,6 +135,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UsageRetrieveResponse = apply { if (validated) { return@apply @@ -376,6 +384,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Transactional = apply { if (validated) { return@apply @@ -566,6 +583,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Limits = apply { if (validated) { return@apply @@ -772,6 +799,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Receiving = apply { if (validated) { return@apply @@ -978,6 +1015,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Sending = apply { if (validated) { return@apply @@ -1183,6 +1230,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Usage = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/shared/EventType.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/shared/EventType.kt index fca6e22..914856a 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/shared/EventType.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/shared/EventType.kt @@ -207,6 +207,14 @@ class EventType @JsonCreator private constructor(private val value: JsonField = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2034,6 +2121,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -2193,6 +2290,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2202,6 +2329,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -2363,6 +2500,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2372,6 +2539,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -2657,6 +2834,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -2727,6 +2914,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2736,6 +2953,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2936,6 +3163,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -3113,6 +3350,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailClickedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailClickedEvent.kt index 2a470a1..38d4550 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailClickedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailClickedEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailClickedEvent = apply { if (validated) { return@apply @@ -935,6 +943,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1185,6 +1202,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Click = apply { if (validated) { return@apply @@ -1261,6 +1288,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1270,6 +1327,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1429,6 +1496,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1438,6 +1535,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1599,6 +1706,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1608,6 +1745,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1893,6 +2040,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -1963,6 +2120,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1972,6 +2159,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2172,6 +2369,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -2349,6 +2556,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailComplainedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailComplainedEvent.kt index 5c25b4a..06efbad 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailComplainedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailComplainedEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailComplainedEvent = apply { if (validated) { return@apply @@ -939,6 +947,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1371,6 +1388,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Complaint = apply { if (validated) { return@apply @@ -1533,6 +1560,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ComplainedRecipient = apply { if (validated) { return@apply @@ -1700,6 +1737,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ComplaintFeedbackType = apply { if (validated) { return@apply @@ -1828,6 +1875,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ComplaintSubType = apply { if (validated) { return@apply @@ -1924,6 +1981,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1933,6 +2020,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -2092,6 +2189,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2101,6 +2228,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -2262,6 +2399,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2271,6 +2438,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -2556,6 +2733,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -2626,6 +2813,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2635,6 +2852,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2835,6 +3062,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -3012,6 +3249,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveredEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveredEvent.kt index 882415c..fa08b0b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveredEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveredEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailDeliveredEvent = apply { if (validated) { return@apply @@ -937,6 +945,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1333,6 +1350,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Delivery = apply { if (validated) { return@apply @@ -1426,6 +1453,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1435,6 +1492,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1594,6 +1661,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1603,6 +1700,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1764,6 +1871,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1773,6 +1910,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -2058,6 +2205,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -2128,6 +2285,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2137,6 +2324,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2337,6 +2534,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -2514,6 +2721,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveryDelayedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveryDelayedEvent.kt index 1b262aa..7a47ccf 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveryDelayedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailDeliveryDelayedEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailDeliveryDelayedEvent = apply { if (validated) { return@apply @@ -943,6 +951,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1305,6 +1322,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DeliveryDelay = apply { if (validated) { return@apply @@ -1531,6 +1558,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): DelayedRecipient = apply { if (validated) { return@apply @@ -1729,6 +1766,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): DelayType = apply { if (validated) { return@apply @@ -1821,6 +1868,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1830,6 +1907,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1989,6 +2076,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1998,6 +2115,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -2159,6 +2286,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2168,6 +2325,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -2453,6 +2620,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -2523,6 +2700,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2532,6 +2739,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2732,6 +2949,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -2909,6 +3136,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailFailedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailFailedEvent.kt index 2e34f02..af04f53 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailFailedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailFailedEvent.kt @@ -234,6 +234,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailFailedEvent = apply { if (validated) { return@apply @@ -938,6 +946,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1097,6 +1114,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Failure = apply { if (validated) { return@apply @@ -1162,6 +1189,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1171,6 +1228,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1330,6 +1397,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1339,6 +1436,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1500,6 +1607,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1509,6 +1646,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1794,6 +1941,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -1864,6 +2021,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1873,6 +2060,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2073,6 +2270,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailOpenedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailOpenedEvent.kt index 7bc08bc..fb2f0da 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailOpenedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailOpenedEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailOpenedEvent = apply { if (validated) { return@apply @@ -935,6 +943,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1151,6 +1168,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Open = apply { if (validated) { return@apply @@ -1224,6 +1251,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1233,6 +1290,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1392,6 +1459,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1401,6 +1498,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1562,6 +1669,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1571,6 +1708,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1856,6 +2003,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -1926,6 +2083,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1935,6 +2122,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -2135,6 +2332,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -2312,6 +2519,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailProcessedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailProcessedEvent.kt index a866211..83ac945 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailProcessedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailProcessedEvent.kt @@ -221,6 +221,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailProcessedEvent = apply { if (validated) { return@apply @@ -349,6 +357,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -472,6 +489,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailQueuedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailQueuedEvent.kt index 2b23a2a..cb21854 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailQueuedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailQueuedEvent.kt @@ -221,6 +221,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailQueuedEvent = apply { if (validated) { return@apply @@ -349,6 +357,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -471,6 +488,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailRejectedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailRejectedEvent.kt index 64d5159..5299bfc 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailRejectedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailRejectedEvent.kt @@ -234,6 +234,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailRejectedEvent = apply { if (validated) { return@apply @@ -918,6 +926,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1091,6 +1108,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Reject = apply { if (validated) { return@apply @@ -1157,6 +1184,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1166,6 +1223,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1327,6 +1394,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1336,6 +1433,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1621,6 +1728,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -1691,6 +1808,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1700,6 +1847,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -1900,6 +2057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -1964,6 +2131,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1973,6 +2170,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailScheduledEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailScheduledEvent.kt index 428db72..4a497ac 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailScheduledEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailScheduledEvent.kt @@ -222,6 +222,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailScheduledEvent = apply { if (validated) { return@apply @@ -366,6 +374,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -517,6 +534,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Schedule = apply { if (validated) { return@apply @@ -660,6 +687,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSendingEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSendingEvent.kt index e48aeae..bb52ded 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSendingEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSendingEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailSendingEvent = apply { if (validated) { return@apply @@ -921,6 +929,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1001,6 +1018,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1010,6 +1057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1169,6 +1226,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1178,6 +1265,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1339,6 +1436,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1348,6 +1475,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1633,6 +1770,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -1703,6 +1850,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1712,6 +1889,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -1912,6 +2099,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -2089,6 +2286,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSentEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSentEvent.kt index 03781db..6bc827d 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSentEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/EmailSentEvent.kt @@ -235,6 +235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EmailSentEvent = apply { if (validated) { return@apply @@ -921,6 +929,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1001,6 +1018,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = to.accept(new To.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1010,6 +1057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): To = apply { if (validated) { return@apply @@ -1169,6 +1226,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = bcc.accept(new Bcc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1178,6 +1265,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bcc = apply { if (validated) { return@apply @@ -1339,6 +1436,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = cc.accept(new Cc.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1348,6 +1475,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cc = apply { if (validated) { return@apply @@ -1633,6 +1770,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Header = apply { if (validated) { return@apply @@ -1703,6 +1850,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = replyTo.accept(new ReplyTo.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -1712,6 +1889,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReplyTo = apply { if (validated) { return@apply @@ -1912,6 +2099,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tags = apply { if (validated) { return@apply @@ -2089,6 +2286,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/Event.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/Event.kt index b8afdee..e3c25f0 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/Event.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/Event.kt @@ -215,6 +215,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = event.accept(new Event.Visitor>() { + * @Override + * public Optional visitEmailQueued(EmailQueuedEvent emailQueued) { + * return Optional.of(emailQueued.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { emailQueued != null -> visitor.visitEmailQueued(emailQueued) @@ -242,6 +271,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Event = apply { if (validated) { return@apply @@ -995,6 +1032,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageRejected = apply { if (validated) { return@apply @@ -1357,6 +1403,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1489,6 +1545,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Reason = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageAgentTriggeredEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageAgentTriggeredEvent.kt index b2ef558..5613496 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageAgentTriggeredEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageAgentTriggeredEvent.kt @@ -222,6 +222,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageAgentTriggeredEvent = apply { if (validated) { return@apply @@ -634,6 +642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -797,6 +814,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageReceivedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageReceivedEvent.kt index 63e1932..d687968 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageReceivedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageReceivedEvent.kt @@ -222,6 +222,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageReceivedEvent = apply { if (validated) { return@apply @@ -634,6 +642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -797,6 +814,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSecurityFlaggedEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSecurityFlaggedEvent.kt index 5a7e7ea..db925c3 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSecurityFlaggedEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSecurityFlaggedEvent.kt @@ -222,6 +222,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageSecurityFlaggedEvent = apply { if (validated) { return@apply @@ -634,6 +642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -797,6 +814,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSentEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSentEvent.kt index 6ebb5bd..5f31580 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSentEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/MessageSentEvent.kt @@ -222,6 +222,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageSentEvent = apply { if (validated) { return@apply @@ -634,6 +642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -797,6 +814,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/UnwrapWebhookEvent.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/UnwrapWebhookEvent.kt index d8374d2..1cae2c3 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/UnwrapWebhookEvent.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/UnwrapWebhookEvent.kt @@ -215,6 +215,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.nuntly.core.JsonValue; + * import java.util.Optional; + * + * Optional result = unwrapWebhookEvent.accept(new UnwrapWebhookEvent.Visitor>() { + * @Override + * public Optional visitEmailQueued(EmailQueuedEvent emailQueued) { + * return Optional.of(emailQueued.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws NuntlyInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { emailQueued != null -> visitor.visitEmailQueued(emailQueued) @@ -242,6 +271,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnwrapWebhookEvent = apply { if (validated) { return@apply @@ -1009,6 +1046,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MessageRejected = apply { if (validated) { return@apply @@ -1371,6 +1417,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1503,6 +1559,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Reason = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateParams.kt index 8ea2e69..11c9bd3 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateParams.kt @@ -570,6 +570,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -720,6 +729,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateResponse.kt index b1522a2..ca5e01a 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookCreateResponse.kt @@ -358,6 +358,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): WebhookCreateResponse = apply { if (validated) { return@apply @@ -490,6 +498,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookDeleteResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookDeleteResponse.kt index 2614e11..4066061 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookDeleteResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookDeleteResponse.kt @@ -128,6 +128,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): WebhookDeleteResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListPageResponse.kt index a405ad0..88780dd 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListPageResponse.kt @@ -180,6 +180,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): WebhookListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListResponse.kt index 0151aea..1aef231 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookListResponse.kt @@ -317,6 +317,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): WebhookListResponse = apply { if (validated) { return@apply @@ -447,6 +455,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookRetrieveResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookRetrieveResponse.kt index 5f92139..996db43 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookRetrieveResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookRetrieveResponse.kt @@ -318,6 +318,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): WebhookRetrieveResponse = apply { if (validated) { return@apply @@ -448,6 +456,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateParams.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateParams.kt index ee3b7f3..36f95f6 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateParams.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateParams.kt @@ -626,6 +626,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -779,6 +788,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateResponse.kt index f7322b5..135bcff 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/WebhookUpdateResponse.kt @@ -170,6 +170,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): WebhookUpdateResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventDeliveriesResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventDeliveriesResponse.kt index 988e61e..d1ee34c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventDeliveriesResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventDeliveriesResponse.kt @@ -254,6 +254,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventDeliveriesResponse = apply { if (validated) { return@apply @@ -346,6 +354,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Response = apply { if (validated) { return@apply @@ -480,6 +497,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListPageResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListPageResponse.kt index 10b3637..06d16c4 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListPageResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListPageResponse.kt @@ -180,6 +180,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventListPageResponse = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListResponse.kt index 5fa53a8..0a2dd0c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventListResponse.kt @@ -336,6 +336,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventListResponse = apply { if (validated) { return@apply @@ -432,6 +440,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -567,6 +584,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws NuntlyInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventReplayResponse.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventReplayResponse.kt index 6e6e5aa..e97033b 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventReplayResponse.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/models/webhooks/events/EventReplayResponse.kt @@ -75,6 +75,14 @@ private constructor(private val additionalProperties: MutableMap Date: Tue, 5 May 2026 04:03:32 +0000 Subject: [PATCH 12/16] feat(client): more robust error parsing --- .../main/kotlin/com/nuntly/errors/BadRequestException.kt | 6 +++++- .../kotlin/com/nuntly/errors/InternalServerException.kt | 7 ++++++- .../src/main/kotlin/com/nuntly/errors/NotFoundException.kt | 6 +++++- .../kotlin/com/nuntly/errors/PermissionDeniedException.kt | 6 +++++- .../main/kotlin/com/nuntly/errors/RateLimitException.kt | 6 +++++- .../main/kotlin/com/nuntly/errors/UnauthorizedException.kt | 6 +++++- .../com/nuntly/errors/UnexpectedStatusCodeException.kt | 7 ++++++- .../com/nuntly/errors/UnprocessableEntityException.kt | 6 +++++- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/BadRequestException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/BadRequestException.kt index 06d0d7f..7d658ce 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/BadRequestException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/BadRequestException.kt @@ -5,12 +5,16 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class BadRequestException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - NuntlyServiceException("400: $body", cause) { + NuntlyServiceException( + "400: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 400 diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/InternalServerException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/InternalServerException.kt index 94f2b17..867efee 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/InternalServerException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/InternalServerException.kt @@ -5,6 +5,7 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -14,7 +15,11 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : NuntlyServiceException("$statusCode: $body", cause) { +) : + NuntlyServiceException( + "$statusCode: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = statusCode diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/NotFoundException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/NotFoundException.kt index 9a260fc..5cb8e27 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/NotFoundException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/NotFoundException.kt @@ -5,12 +5,16 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class NotFoundException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - NuntlyServiceException("404: $body", cause) { + NuntlyServiceException( + "404: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 404 diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/PermissionDeniedException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/PermissionDeniedException.kt index 8a6e3a1..4cceef0 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/PermissionDeniedException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/PermissionDeniedException.kt @@ -5,12 +5,16 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class PermissionDeniedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - NuntlyServiceException("403: $body", cause) { + NuntlyServiceException( + "403: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 403 diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/RateLimitException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/RateLimitException.kt index 41ee65b..82f467e 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/RateLimitException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/RateLimitException.kt @@ -5,12 +5,16 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class RateLimitException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - NuntlyServiceException("429: $body", cause) { + NuntlyServiceException( + "429: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 429 diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnauthorizedException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnauthorizedException.kt index 46d6740..f93ca0c 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnauthorizedException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnauthorizedException.kt @@ -5,12 +5,16 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class UnauthorizedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - NuntlyServiceException("401: $body", cause) { + NuntlyServiceException( + "401: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 401 diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnexpectedStatusCodeException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnexpectedStatusCodeException.kt index c2b72ae..26a608e 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnexpectedStatusCodeException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnexpectedStatusCodeException.kt @@ -5,6 +5,7 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -14,7 +15,11 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : NuntlyServiceException("$statusCode: $body", cause) { +) : + NuntlyServiceException( + "$statusCode: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = statusCode diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnprocessableEntityException.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnprocessableEntityException.kt index 3523075..7971988 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnprocessableEntityException.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/errors/UnprocessableEntityException.kt @@ -5,12 +5,16 @@ package com.nuntly.errors import com.nuntly.core.JsonValue import com.nuntly.core.checkRequired import com.nuntly.core.http.Headers +import com.nuntly.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class UnprocessableEntityException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - NuntlyServiceException("422: $body", cause) { + NuntlyServiceException( + "422: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 422 From b90558163d03ec7305341c5929a47a678c6f1889 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 04:07:09 +0000 Subject: [PATCH 13/16] chore: remove duplicated dokka setup --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index a1ce5f5..61198be 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,6 @@ subprojects { group = "Verification" description = "Verifies all source files are formatted." } - apply(plugin = "org.jetbrains.dokka") } subprojects { From f349b91d30687e78cb5f1389fdbb8abb73e6a28c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 04:09:42 +0000 Subject: [PATCH 14/16] perf(client): create one json mapper --- .../src/main/kotlin/com/nuntly/core/ObjectMappers.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/core/ObjectMappers.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/core/ObjectMappers.kt index ab3bad0..5768537 100644 --- a/nuntly-java-core/src/main/kotlin/com/nuntly/core/ObjectMappers.kt +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/core/ObjectMappers.kt @@ -29,7 +29,9 @@ import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField -fun jsonMapper(): JsonMapper = +fun jsonMapper(): JsonMapper = JSON_MAPPER + +private val JSON_MAPPER: JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) From e6e0f3929ae6693a5d300ab4efdbc729819c0182 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 04:30:55 +0000 Subject: [PATCH 15/16] feat(client): support proxy authentication --- README.md | 15 ++ .../client/okhttp/NuntlyOkHttpClient.kt | 17 ++ .../client/okhttp/NuntlyOkHttpClientAsync.kt | 17 ++ .../com/nuntly/client/okhttp/OkHttpClient.kt | 234 +++++++++++------- .../nuntly/core/http/ProxyAuthenticator.kt | 59 +++++ 5 files changed, 257 insertions(+), 85 deletions(-) create mode 100644 nuntly-java-core/src/main/kotlin/com/nuntly/core/http/ProxyAuthenticator.kt diff --git a/README.md b/README.md index 48d7b0a..edab356 100644 --- a/README.md +++ b/README.md @@ -460,6 +460,21 @@ NuntlyClient client = NuntlyOkHttpClient.builder() .build(); ``` +If the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`: + +```java +import com.nuntly.client.NuntlyClient; +import com.nuntly.client.okhttp.NuntlyOkHttpClient; +import com.nuntly.core.http.ProxyAuthenticator; + +NuntlyClient client = NuntlyOkHttpClient.builder() + .fromEnv() + .proxy(...) + // Or a custom implementation of `ProxyAuthenticator`. + .proxyAuthenticator(ProxyAuthenticator.basic("username", "password")) + .build(); +``` + ### Connection pooling To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: diff --git a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt index 7b86bf6..5fde224 100644 --- a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt +++ b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClient.kt @@ -11,6 +11,7 @@ import com.nuntly.core.Timeout import com.nuntly.core.http.AsyncStreamResponse import com.nuntly.core.http.Headers import com.nuntly.core.http.HttpClient +import com.nuntly.core.http.ProxyAuthenticator import com.nuntly.core.http.QueryParams import com.nuntly.core.jsonMapper import java.net.Proxy @@ -49,6 +50,7 @@ class NuntlyOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null @@ -79,6 +81,20 @@ class NuntlyOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + /** * The maximum number of idle connections kept by the underlying OkHttp connection pool. * @@ -379,6 +395,7 @@ class NuntlyOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) .maxIdleConnections(maxIdleConnections) .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) diff --git a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt index ec34703..888eae3 100644 --- a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt +++ b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/NuntlyOkHttpClientAsync.kt @@ -11,6 +11,7 @@ import com.nuntly.core.Timeout import com.nuntly.core.http.AsyncStreamResponse import com.nuntly.core.http.Headers import com.nuntly.core.http.HttpClient +import com.nuntly.core.http.ProxyAuthenticator import com.nuntly.core.http.QueryParams import com.nuntly.core.jsonMapper import java.net.Proxy @@ -49,6 +50,7 @@ class NuntlyOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null @@ -79,6 +81,20 @@ class NuntlyOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + /** * The maximum number of idle connections kept by the underlying OkHttp connection pool. * @@ -379,6 +395,7 @@ class NuntlyOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) .maxIdleConnections(maxIdleConnections) .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) diff --git a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/OkHttpClient.kt b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/OkHttpClient.kt index a8b59b1..ce980a9 100644 --- a/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/OkHttpClient.kt +++ b/nuntly-java-client-okhttp/src/main/kotlin/com/nuntly/client/okhttp/OkHttpClient.kt @@ -8,9 +8,11 @@ import com.nuntly.core.http.HttpMethod import com.nuntly.core.http.HttpRequest import com.nuntly.core.http.HttpRequestBody import com.nuntly.core.http.HttpResponse +import com.nuntly.core.http.ProxyAuthenticator import com.nuntly.errors.NuntlyIoException import java.io.IOException import java.io.InputStream +import java.io.OutputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException @@ -20,10 +22,12 @@ import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull import okhttp3.Call import okhttp3.Callback import okhttp3.ConnectionPool import okhttp3.Dispatcher +import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -33,6 +37,8 @@ import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink +import okio.buffer +import okio.sink class OkHttpClient internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { @@ -41,7 +47,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie val call = newCall(request, requestOptions) return try { - call.execute().toResponse() + call.execute().toHttpResponse() } catch (e: IOException) { throw NuntlyIoException("Request failed", e) } finally { @@ -59,7 +65,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie call.enqueue( object : Callback { override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) + future.complete(response.toHttpResponse()) } override fun onFailure(call: Call, e: IOException) { @@ -111,89 +117,6 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie return client.newCall(request.toRequest(client)) } - private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { - var body: RequestBody? = body?.toRequestBody() - if (body == null && requiresBody(method)) { - body = "".toRequestBody() - } - - val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.names().forEach { name -> - headers.values(name).forEach { builder.addHeader(name, it) } - } - - if ( - !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 - ) { - builder.addHeader( - "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), - ) - } - if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.addHeader( - "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), - ) - } - - return builder.build() - } - - /** `OkHttpClient` always requires a request body for some methods. */ - private fun requiresBody(method: HttpMethod): Boolean = - when (method) { - HttpMethod.POST, - HttpMethod.PUT, - HttpMethod.PATCH -> true - else -> false - } - - private fun HttpRequest.toUrl(): String { - val builder = baseUrl.toHttpUrl().newBuilder() - pathSegments.forEach(builder::addPathSegment) - queryParams.keys().forEach { key -> - queryParams.values(key).forEach { builder.addQueryParameter(key, it) } - } - - return builder.toString() - } - - private fun HttpRequestBody.toRequestBody(): RequestBody { - val mediaType = contentType()?.toMediaType() - val length = contentLength() - - return object : RequestBody() { - override fun contentType(): MediaType? = mediaType - - override fun contentLength(): Long = length - - override fun isOneShot(): Boolean = !repeatable() - - override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) - } - } - - private fun Response.toResponse(): HttpResponse { - val headers = headers.toHeaders() - - return object : HttpResponse { - override fun statusCode(): Int = code - - override fun headers(): Headers = headers - - override fun body(): InputStream = body!!.byteStream() - - override fun close() = body!!.close() - } - } - - private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() - } - companion object { @JvmStatic fun builder() = Builder() } @@ -202,6 +125,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null @@ -215,6 +139,10 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + /** * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. * @@ -264,6 +192,19 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie .callTimeout(timeout.request()) .proxy(proxy) .apply { + proxyAuthenticator?.let { auth -> + proxyAuthenticator { route, response -> + auth + .authenticate( + route?.proxy ?: Proxy.NO_PROXY, + response.request.toHttpRequest(), + response.toHttpResponse(), + ) + .getOrNull() + ?.toRequest(client = null) + } + } + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } val maxIdleConnections = maxIdleConnections @@ -303,3 +244,126 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie ) } } + +private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient?): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> headers.values(name).forEach { builder.addHeader(name, it) } } + + if (client != null) { + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.addHeader( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.addHeader( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + } + + return builder.build() +} + +/** `OkHttpClient` always requires a request body for some methods. */ +private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + +private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() +} + +private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } +} + +private fun Request.toHttpRequest(): HttpRequest { + val builder = HttpRequest.builder().method(HttpMethod.valueOf(method)).baseUrl(url.toBaseUrl()) + url.pathSegments.forEach(builder::addPathSegment) + url.queryParameterNames.forEach { name -> + url.queryParameterValues(name).filterNotNull().forEach { builder.putQueryParam(name, it) } + } + headers.forEach { (name, value) -> builder.putHeader(name, value) } + body?.let { builder.body(it.toHttpRequestBody()) } + return builder.build() +} + +private fun HttpUrl.toBaseUrl(): String = buildString { + append(scheme).append("://").append(host) + if (port != HttpUrl.defaultPort(scheme)) { + append(":").append(port) + } +} + +private fun RequestBody.toHttpRequestBody(): HttpRequestBody { + val mediaType = contentType()?.toString() + val length = contentLength() + val isOneShot = isOneShot() + val source = this + return object : HttpRequestBody { + override fun contentType(): String? = mediaType + + override fun contentLength(): Long = length + + override fun repeatable(): Boolean = !isOneShot + + override fun writeTo(outputStream: OutputStream) { + val sink = outputStream.sink().buffer() + source.writeTo(sink) + sink.flush() + } + + override fun close() {} + } +} + +private fun Response.toHttpResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } +} + +private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() +} diff --git a/nuntly-java-core/src/main/kotlin/com/nuntly/core/http/ProxyAuthenticator.kt b/nuntly-java-core/src/main/kotlin/com/nuntly/core/http/ProxyAuthenticator.kt new file mode 100644 index 0000000..82d6969 --- /dev/null +++ b/nuntly-java-core/src/main/kotlin/com/nuntly/core/http/ProxyAuthenticator.kt @@ -0,0 +1,59 @@ +package com.nuntly.core.http + +import java.net.Proxy +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets +import java.util.Base64 +import java.util.Optional + +/** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication Required`. + * + * Implementations inspect the 407 [response] (typically its `Proxy-Authenticate` header) and return + * the request to retry with a `Proxy-Authorization` header set, or [Optional.empty] to abandon + * authentication and surface the 407 to the caller. + * + * Implementations must be thread-safe; they may be invoked concurrently from multiple HTTP calls. + */ +fun interface ProxyAuthenticator { + + /** + * @param proxy the proxy that produced the challenge, or [Proxy.NO_PROXY] if the route is not + * yet established + * @param request the request that produced [response] + * @param response the 407 challenge response + * @return the retry request to send (typically [request] with a `Proxy-Authorization` header + * added), or [Optional.empty] to abandon authentication + */ + fun authenticate( + proxy: Proxy, + request: HttpRequest, + response: HttpResponse, + ): Optional + + companion object { + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the ISO-8859-1 + * charset. + */ + @JvmStatic + fun basic(username: String, password: String): ProxyAuthenticator = + basic(username, password, StandardCharsets.ISO_8859_1) + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the given [charset]. + */ + @JvmStatic + fun basic(username: String, password: String, charset: Charset): ProxyAuthenticator { + val token = + Base64.getEncoder().encodeToString("$username:$password".toByteArray(charset)) + val headerValue = "Basic $token" + return ProxyAuthenticator { _, request, _ -> + Optional.of( + request.toBuilder().putHeader("Proxy-Authorization", headerValue).build() + ) + } + } + } +} From 44d66a3c0fac480d0691de4faeca65c97de40438 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 04:31:22 +0000 Subject: [PATCH 16/16] release: 0.6.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2aca35a..4208b5c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.0" + ".": "0.6.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a69880..416ad9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.6.0 (2026-05-06) + +Full Changelog: [v0.5.0...v0.6.0](https://github.com/nuntly/nuntly-sdk-java/compare/v0.5.0...v0.6.0) + +### Features + +* **api:** implement label ([9106e39](https://github.com/nuntly/nuntly-sdk-java/commit/9106e39a9f68032114ada016fb3e6d6a1be4cf27)) +* **client:** more robust error parsing ([cc836e0](https://github.com/nuntly/nuntly-sdk-java/commit/cc836e0fed4853538d946b64125c6cc402fcbdbc)) +* **client:** support proxy authentication ([e6e0f39](https://github.com/nuntly/nuntly-sdk-java/commit/e6e0f3929ae6693a5d300ab4efdbc729819c0182)) +* support setting headers via env ([fba15cd](https://github.com/nuntly/nuntly-sdk-java/commit/fba15cddd34b79348161aa1036496e5aeb9e3170)) + + +### Performance Improvements + +* **client:** create one json mapper ([f349b91](https://github.com/nuntly/nuntly-sdk-java/commit/f349b91d30687e78cb5f1389fdbb8abb73e6a28c)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([be6c700](https://github.com/nuntly/nuntly-sdk-java/commit/be6c7000aa0ec54b5abd5acc023c3d2ffd69969a)) +* **internal:** update multipart form array serialization ([7cc35eb](https://github.com/nuntly/nuntly-sdk-java/commit/7cc35eb8ed276450e7fbc1617c32149a12818dd4)) +* remove duplicated dokka setup ([b905581](https://github.com/nuntly/nuntly-sdk-java/commit/b90558163d03ec7305341c5929a47a678c6f1889)) +* **tests:** bump steady to v0.19.7 ([9ad4c85](https://github.com/nuntly/nuntly-sdk-java/commit/9ad4c85cf8e51352f661d7ee640ae1d8dd724a8f)) +* **tests:** bump steady to v0.20.1 ([4ca6c5e](https://github.com/nuntly/nuntly-sdk-java/commit/4ca6c5e8299d69f16020dc83f95452a25e9de016)) +* **tests:** bump steady to v0.20.2 ([f406712](https://github.com/nuntly/nuntly-sdk-java/commit/f406712b2daed702c802028b63b1f97facd75454)) +* **tests:** bump steady to v0.22.1 ([0043aa0](https://github.com/nuntly/nuntly-sdk-java/commit/0043aa083c9f94bd71e9be4552431ffee23c76c9)) + + +### Documentation + +* clarify forwards compat behavior ([3dfae7a](https://github.com/nuntly/nuntly-sdk-java/commit/3dfae7a1b98935aba71e07f06e13f2e68888203d)) + ## 0.5.0 (2026-03-24) Full Changelog: [v0.4.0...v0.5.0](https://github.com/nuntly/nuntly-sdk-java/compare/v0.4.0...v0.5.0) diff --git a/README.md b/README.md index edab356..8a6844a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.nuntly/nuntly-java)](https://central.sonatype.com/artifact/com.nuntly/nuntly-java/0.5.0) -[![javadoc](https://javadoc.io/badge2/com.nuntly/nuntly-java/0.5.0/javadoc.svg)](https://javadoc.io/doc/com.nuntly/nuntly-java/0.5.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.nuntly/nuntly-java)](https://central.sonatype.com/artifact/com.nuntly/nuntly-java/0.6.0) +[![javadoc](https://javadoc.io/badge2/com.nuntly/nuntly-java/0.6.0/javadoc.svg)](https://javadoc.io/doc/com.nuntly/nuntly-java/0.6.0) @@ -22,7 +22,7 @@ Use the Nuntly MCP Server to enable AI assistants to interact with this API, all -The REST API documentation can be found on [developers.nuntly.com](http://developers.nuntly.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.nuntly/nuntly-java/0.5.0). +The REST API documentation can be found on [developers.nuntly.com](http://developers.nuntly.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.nuntly/nuntly-java/0.6.0). @@ -33,7 +33,7 @@ The REST API documentation can be found on [developers.nuntly.com](http://develo ### Gradle ```kotlin -implementation("com.nuntly:nuntly-java:0.5.0") +implementation("com.nuntly:nuntly-java:0.6.0") ``` ### Maven @@ -42,7 +42,7 @@ implementation("com.nuntly:nuntly-java:0.5.0") com.nuntly nuntly-java - 0.5.0 + 0.6.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 61198be..fabc986 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.nuntly" - version = "0.5.0" // x-release-please-version + version = "0.6.0" // x-release-please-version } subprojects {