diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b9e06599..c032d311 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.21.0" + ".": "4.22.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 44174988..e2794c72 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-b03f5346718dcd7b22f15893445ea593ab87535c90c540fc5a796c6ecd54d779.yml -openapi_spec_hash: 15677d3be4ecd33eab154080b4bc437f -config_hash: dcd58abf1e56b114bdce22336ca3d570 +configured_endpoints: 134 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-b053468fefe6d757f86f3233ebbc52d80329ed2a6e7a6740fee01e4028a4c3b9.yml +openapi_spec_hash: 416835e693de0fe19945be90a787d3f3 +config_hash: 8d28dbeabe9d4dcc7d5b8c021a4cbbd7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 775e71f1..83d3cc41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.22.0 (2026-07-23) + +Full Changelog: [v4.21.0...v4.22.0](https://github.com/trycourier/courier-java/compare/v4.21.0...v4.22.0) + +### Features + +* Remove /bulk endpoints from api-spec (C-19507) ([#171](https://github.com/trycourier/courier-java/issues/171)) ([2a450f6](https://github.com/trycourier/courier-java/commit/2a450f65f702ff5a8899326c40575facbb7690b2)) + ## 4.21.0 (2026-07-20) Full Changelog: [v4.20.2...v4.21.0](https://github.com/trycourier/courier-java/compare/v4.20.2...v4.21.0) diff --git a/build.gradle.kts b/build.gradle.kts index 58362a3f..bb83195c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.courier" - version = "4.21.0" // x-release-please-version + version = "4.22.0" // x-release-please-version } subprojects { diff --git a/courier-java-core/src/main/kotlin/com/courier/client/CourierClient.kt b/courier-java-core/src/main/kotlin/com/courier/client/CourierClient.kt index ac03c4ad..1d5082d7 100644 --- a/courier-java-core/src/main/kotlin/com/courier/client/CourierClient.kt +++ b/courier-java-core/src/main/kotlin/com/courier/client/CourierClient.kt @@ -8,7 +8,6 @@ import com.courier.services.blocking.AuditEventService import com.courier.services.blocking.AuthService import com.courier.services.blocking.AutomationService import com.courier.services.blocking.BrandService -import com.courier.services.blocking.BulkService import com.courier.services.blocking.DigestService import com.courier.services.blocking.InboundService import com.courier.services.blocking.JourneyService @@ -78,8 +77,6 @@ interface CourierClient { fun brands(): BrandService - fun bulk(): BulkService - fun digests(): DigestService fun inbound(): InboundService @@ -143,8 +140,6 @@ interface CourierClient { fun brands(): BrandService.WithRawResponse - fun bulk(): BulkService.WithRawResponse - fun digests(): DigestService.WithRawResponse fun inbound(): InboundService.WithRawResponse diff --git a/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsync.kt b/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsync.kt index 49c95d69..4ac223e6 100644 --- a/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsync.kt @@ -8,7 +8,6 @@ import com.courier.services.async.AuditEventServiceAsync import com.courier.services.async.AuthServiceAsync import com.courier.services.async.AutomationServiceAsync import com.courier.services.async.BrandServiceAsync -import com.courier.services.async.BulkServiceAsync import com.courier.services.async.DigestServiceAsync import com.courier.services.async.InboundServiceAsync import com.courier.services.async.JourneyServiceAsync @@ -78,8 +77,6 @@ interface CourierClientAsync { fun brands(): BrandServiceAsync - fun bulk(): BulkServiceAsync - fun digests(): DigestServiceAsync fun inbound(): InboundServiceAsync @@ -147,8 +144,6 @@ interface CourierClientAsync { fun brands(): BrandServiceAsync.WithRawResponse - fun bulk(): BulkServiceAsync.WithRawResponse - fun digests(): DigestServiceAsync.WithRawResponse fun inbound(): InboundServiceAsync.WithRawResponse diff --git a/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsyncImpl.kt index 7ed9cb07..9f04092a 100644 --- a/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/client/CourierClientAsyncImpl.kt @@ -14,8 +14,6 @@ import com.courier.services.async.AutomationServiceAsync import com.courier.services.async.AutomationServiceAsyncImpl import com.courier.services.async.BrandServiceAsync import com.courier.services.async.BrandServiceAsyncImpl -import com.courier.services.async.BulkServiceAsync -import com.courier.services.async.BulkServiceAsyncImpl import com.courier.services.async.DigestServiceAsync import com.courier.services.async.DigestServiceAsyncImpl import com.courier.services.async.InboundServiceAsync @@ -93,8 +91,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier BrandServiceAsyncImpl(clientOptionsWithUserAgent) } - private val bulk: BulkServiceAsync by lazy { BulkServiceAsyncImpl(clientOptionsWithUserAgent) } - private val digests: DigestServiceAsync by lazy { DigestServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -162,8 +158,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier override fun brands(): BrandServiceAsync = brands - override fun bulk(): BulkServiceAsync = bulk - override fun digests(): DigestServiceAsync = digests override fun inbound(): InboundServiceAsync = inbound @@ -225,10 +219,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier BrandServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val bulk: BulkServiceAsync.WithRawResponse by lazy { - BulkServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - private val digests: DigestServiceAsync.WithRawResponse by lazy { DigestServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -300,8 +290,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier override fun brands(): BrandServiceAsync.WithRawResponse = brands - override fun bulk(): BulkServiceAsync.WithRawResponse = bulk - override fun digests(): DigestServiceAsync.WithRawResponse = digests override fun inbound(): InboundServiceAsync.WithRawResponse = inbound diff --git a/courier-java-core/src/main/kotlin/com/courier/client/CourierClientImpl.kt b/courier-java-core/src/main/kotlin/com/courier/client/CourierClientImpl.kt index 235fe763..d3f901e8 100644 --- a/courier-java-core/src/main/kotlin/com/courier/client/CourierClientImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/client/CourierClientImpl.kt @@ -14,8 +14,6 @@ import com.courier.services.blocking.AutomationService import com.courier.services.blocking.AutomationServiceImpl import com.courier.services.blocking.BrandService import com.courier.services.blocking.BrandServiceImpl -import com.courier.services.blocking.BulkService -import com.courier.services.blocking.BulkServiceImpl import com.courier.services.blocking.DigestService import com.courier.services.blocking.DigestServiceImpl import com.courier.services.blocking.InboundService @@ -89,8 +87,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien private val brands: BrandService by lazy { BrandServiceImpl(clientOptionsWithUserAgent) } - private val bulk: BulkService by lazy { BulkServiceImpl(clientOptionsWithUserAgent) } - private val digests: DigestService by lazy { DigestServiceImpl(clientOptionsWithUserAgent) } private val inbound: InboundService by lazy { InboundServiceImpl(clientOptionsWithUserAgent) } @@ -146,8 +142,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien override fun brands(): BrandService = brands - override fun bulk(): BulkService = bulk - override fun digests(): DigestService = digests override fun inbound(): InboundService = inbound @@ -209,10 +203,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien BrandServiceImpl.WithRawResponseImpl(clientOptions) } - private val bulk: BulkService.WithRawResponse by lazy { - BulkServiceImpl.WithRawResponseImpl(clientOptions) - } - private val digests: DigestService.WithRawResponse by lazy { DigestServiceImpl.WithRawResponseImpl(clientOptions) } @@ -284,8 +274,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien override fun brands(): BrandService.WithRawResponse = brands - override fun bulk(): BulkService.WithRawResponse = bulk - override fun digests(): DigestService.WithRawResponse = digests override fun inbound(): InboundService.WithRawResponse = inbound diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkAddUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkAddUsersParams.kt deleted file mode 100644 index 65800113..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkAddUsersParams.kt +++ /dev/null @@ -1,476 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.Params -import com.courier.core.checkKnown -import com.courier.core.checkRequired -import com.courier.core.http.Headers -import com.courier.core.http.QueryParams -import com.courier.core.toImmutable -import com.courier.errors.CourierInvalidDataException -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 java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Ingest user data into a Bulk Job. - * - * **Important**: For email-based bulk jobs, each user must include `profile.email` for provider - * routing to work correctly. The `to.email` field is not sufficient for email provider routing. - */ -class BulkAddUsersParams -private constructor( - private val jobId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** - * @throws CourierInvalidDataException 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 users(): List = body.users() - - /** - * Returns the raw JSON value of [users]. - * - * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _users(): JsonField> = body._users() - - 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 { - - /** - * Returns a mutable builder for constructing an instance of [BulkAddUsersParams]. - * - * The following fields are required: - * ```java - * .users() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkAddUsersParams]. */ - class Builder internal constructor() { - - private var jobId: 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(bulkAddUsersParams: BulkAddUsersParams) = apply { - jobId = bulkAddUsersParams.jobId - body = bulkAddUsersParams.body.toBuilder() - additionalHeaders = bulkAddUsersParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkAddUsersParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.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: - * - [users] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun users(users: List) = apply { body.users(users) } - - /** - * Sets [Builder.users] to an arbitrary JSON value. - * - * You should usually call [Builder.users] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun users(users: JsonField>) = apply { body.users(users) } - - /** - * Adds a single [InboundBulkMessageUser] to [users]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addUser(user: InboundBulkMessageUser) = apply { body.addUser(user) } - - 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 [BulkAddUsersParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .users() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkAddUsersParams = - BulkAddUsersParams( - jobId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val users: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("users") - @ExcludeMissing - users: JsonField> = JsonMissing.of() - ) : this(users, mutableMapOf()) - - /** - * @throws CourierInvalidDataException 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 users(): List = users.getRequired("users") - - /** - * Returns the raw JSON value of [users]. - * - * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("users") - @ExcludeMissing - fun _users(): JsonField> = users - - @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]. - * - * The following fields are required: - * ```java - * .users() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var users: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - users = body.users.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun users(users: List) = users(JsonField.of(users)) - - /** - * Sets [Builder.users] to an arbitrary JSON value. - * - * You should usually call [Builder.users] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun users(users: JsonField>) = apply { - this.users = users.map { it.toMutableList() } - } - - /** - * Adds a single [InboundBulkMessageUser] to [users]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addUser(user: InboundBulkMessageUser) = apply { - users = - (users ?: JsonField.of(mutableListOf())).also { - checkKnown("users", it).add(user) - } - } - - 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. - * - * The following fields are required: - * ```java - * .users() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("users", users).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Body = apply { - if (validated) { - return@apply - } - - users().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - users == other.users && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(users, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{users=$users, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkAddUsersParams && - jobId == other.jobId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(jobId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkAddUsersParams{jobId=$jobId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkCreateJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkCreateJobParams.kt deleted file mode 100644 index 3af5ff9b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkCreateJobParams.kt +++ /dev/null @@ -1,454 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.Params -import com.courier.core.checkRequired -import com.courier.core.http.Headers -import com.courier.core.http.QueryParams -import com.courier.errors.CourierInvalidDataException -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 java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -/** - * Creates a new bulk job for sending messages to multiple recipients. - * - * **Required**: `message.event` (event ID or notification ID) - * - * **Optional (V2 format)**: `message.template` (notification ID) or `message.content` (Elemental - * content) can be provided to override the notification associated with the event. - */ -class BulkCreateJobParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental content) in - * addition to `event` - * - * @throws CourierInvalidDataException 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 message(): InboundBulkMessage = body.message() - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _message(): JsonField = body._message() - - 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 { - - /** - * Returns a mutable builder for constructing an instance of [BulkCreateJobParams]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkCreateJobParams]. */ - class Builder internal constructor() { - - 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(bulkCreateJobParams: BulkCreateJobParams) = apply { - body = bulkCreateJobParams.body.toBuilder() - additionalHeaders = bulkCreateJobParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkCreateJobParams.additionalQueryParams.toBuilder() - } - - /** - * 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: - * - [message] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental content) - * in addition to `event` - */ - fun message(message: InboundBulkMessage) = apply { body.message(message) } - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [InboundBulkMessage] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun message(message: JsonField) = apply { body.message(message) } - - 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 [BulkCreateJobParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkCreateJobParams = - BulkCreateJobParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val message: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("message") - @ExcludeMissing - message: JsonField = JsonMissing.of() - ) : this(message, mutableMapOf()) - - /** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental content) - * in addition to `event` - * - * @throws CourierInvalidDataException 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 message(): InboundBulkMessage = message.getRequired("message") - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") - @ExcludeMissing - fun _message(): JsonField = message - - @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]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var message: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - message = body.message - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental - * content) in addition to `event` - */ - fun message(message: InboundBulkMessage) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [InboundBulkMessage] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - 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. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("message", message), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Body = apply { - if (validated) { - return@apply - } - - message().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = (message.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - message == other.message && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{message=$message, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkCreateJobParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkCreateJobParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkCreateJobResponse.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkCreateJobResponse.kt deleted file mode 100644 index 02b06eb5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkCreateJobResponse.kt +++ /dev/null @@ -1,178 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.checkRequired -import com.courier.errors.CourierInvalidDataException -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 java.util.Collections -import java.util.Objects - -class BulkCreateJobResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val jobId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of() - ) : this(jobId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException 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 jobId(): String = jobId.getRequired("jobId") - - /** - * Returns the raw JSON value of [jobId]. - * - * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId - - @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 [BulkCreateJobResponse]. - * - * The following fields are required: - * ```java - * .jobId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkCreateJobResponse]. */ - class Builder internal constructor() { - - private var jobId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkCreateJobResponse: BulkCreateJobResponse) = apply { - jobId = bulkCreateJobResponse.jobId - additionalProperties = bulkCreateJobResponse.additionalProperties.toMutableMap() - } - - fun jobId(jobId: String) = jobId(JsonField.of(jobId)) - - /** - * Sets [Builder.jobId] to an arbitrary JSON value. - * - * You should usually call [Builder.jobId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun jobId(jobId: JsonField) = apply { this.jobId = jobId } - - 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 [BulkCreateJobResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .jobId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkCreateJobResponse = - BulkCreateJobResponse( - checkRequired("jobId", jobId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): BulkCreateJobResponse = apply { - if (validated) { - return@apply - } - - jobId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 (jobId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkCreateJobResponse && - jobId == other.jobId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkCreateJobResponse{jobId=$jobId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkListUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkListUsersParams.kt deleted file mode 100644 index fbc28862..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkListUsersParams.kt +++ /dev/null @@ -1,216 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.Params -import com.courier.core.http.Headers -import com.courier.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get Bulk Job Users */ -class BulkListUsersParams -private constructor( - private val jobId: String?, - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** A unique identifier that allows for fetching the next set of users added to the bulk job */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** 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(): BulkListUsersParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BulkListUsersParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkListUsersParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(bulkListUsersParams: BulkListUsersParams) = apply { - jobId = bulkListUsersParams.jobId - cursor = bulkListUsersParams.cursor - additionalHeaders = bulkListUsersParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkListUsersParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - /** - * A unique identifier that allows for fetching the next set of users added to the bulk job - */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - 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 [BulkListUsersParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkListUsersParams = - BulkListUsersParams( - jobId, - cursor, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkListUsersParams && - jobId == other.jobId && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(jobId, cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkListUsersParams{jobId=$jobId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkListUsersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkListUsersResponse.kt deleted file mode 100644 index 2023b33d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkListUsersResponse.kt +++ /dev/null @@ -1,801 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.Enum -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.checkKnown -import com.courier.core.checkRequired -import com.courier.core.toImmutable -import com.courier.errors.CourierInvalidDataException -import com.courier.models.Paging -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -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 java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BulkListUsersResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * @throws CourierInvalidDataException 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 items(): List = items.getRequired("items") - - /** - * @throws CourierInvalidDataException 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 paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @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 [BulkListUsersResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkListUsersResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkListUsersResponse: BulkListUsersResponse) = apply { - items = bulkListUsersResponse.items.map { it.toMutableList() } - paging = bulkListUsersResponse.paging - additionalProperties = bulkListUsersResponse.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Item] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Item) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - 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 [BulkListUsersResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkListUsersResponse = - BulkListUsersResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): BulkListUsersResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonValue, - private val preferences: JsonField, - private val profile: JsonField, - private val recipient: JsonField, - private val to: JsonField, - private val status: JsonField, - private val messageId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("profile") - @ExcludeMissing - profile: JsonField = JsonMissing.of(), - @JsonProperty("recipient") - @ExcludeMissing - recipient: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("messageId") - @ExcludeMissing - messageId: JsonField = JsonMissing.of(), - ) : this(data, preferences, profile, recipient, to, status, messageId, mutableMapOf()) - - fun toInboundBulkMessageUser(): InboundBulkMessageUser = - InboundBulkMessageUser.builder() - .data(data) - .preferences(preferences) - .profile(profile) - .recipient(recipient) - .to(to) - .build() - - /** - * User-specific data that will be merged with message.data - * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = item.data().convert(MyClass.class); - * ``` - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * User profile information. For email-based bulk jobs, `profile.email` is required for - * provider routing to determine if the message can be delivered. The email address should - * be provided here rather than in `to.email`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun profile(): Optional = profile.getOptional("profile") - - /** - * User ID (legacy field, use profile or to.user_id instead) - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * Optional recipient information. Note: For email provider routing, use `profile.email` - * instead of `to.email`. The `to` field is primarily used for recipient identification and - * data merging. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * @throws CourierInvalidDataException 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 status(): Status = status.getRequired("status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun messageId(): Optional = messageId.getOptional("messageId") - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") - @ExcludeMissing - fun _profile(): JsonField = profile - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [messageId]. - * - * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId - - @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 [Item]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var data: JsonValue = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var profile: JsonField = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var status: JsonField? = null - private var messageId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - data = item.data - preferences = item.preferences - profile = item.profile - recipient = item.recipient - to = item.to - status = item.status - messageId = item.messageId - additionalProperties = item.additionalProperties.toMutableMap() - } - - /** User-specific data that will be merged with message.data */ - fun data(data: JsonValue) = apply { this.data = data } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** - * User profile information. For email-based bulk jobs, `profile.email` is required for - * provider routing to determine if the message can be delivered. The email address - * should be provided here rather than in `to.email`. - */ - fun profile(profile: InboundBulkMessageUser.Profile?) = - profile(JsonField.ofNullable(profile)) - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = - profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed - * [InboundBulkMessageUser.Profile] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { - this.profile = profile - } - - /** User ID (legacy field, use profile or to.user_id instead) */ - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - /** - * Optional recipient information. Note: For email provider routing, use `profile.email` - * instead of `to.email`. The `to` field is primarily used for recipient identification - * and data merging. - */ - fun to(to: UserRecipient?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [UserRecipient] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun to(to: JsonField) = apply { this.to = to } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun messageId(messageId: String?) = messageId(JsonField.ofNullable(messageId)) - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - /** - * Sets [Builder.messageId] to an arbitrary JSON value. - * - * You should usually call [Builder.messageId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageId(messageId: JsonField) = apply { this.messageId = messageId } - - 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 [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - data, - preferences, - profile, - recipient, - to, - checkRequired("status", status), - messageId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Item = apply { - if (validated) { - return@apply - } - - preferences().ifPresent { it.validate() } - profile().ifPresent { it.validate() } - recipient() - to().ifPresent { it.validate() } - status().validate() - messageId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (profile.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (to.asKnown().getOrNull()?.validity() ?: 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (messageId.asKnown().isPresent) 1 else 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PENDING = of("PENDING") - - @JvmField val ENQUEUED = of("ENQUEUED") - - @JvmField val ERROR = of("ERROR") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - PENDING, - ENQUEUED, - ERROR, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PENDING, - ENQUEUED, - ERROR, - /** - * An enum member indicating that [Status] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PENDING -> Value.PENDING - ENQUEUED -> Value.ENQUEUED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - ENQUEUED -> Known.ENQUEUED - ERROR -> Known.ERROR - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - data == other.data && - preferences == other.preferences && - profile == other.profile && - recipient == other.recipient && - to == other.to && - status == other.status && - messageId == other.messageId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - data, - preferences, - profile, - recipient, - to, - status, - messageId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{data=$data, preferences=$preferences, profile=$profile, recipient=$recipient, to=$to, status=$status, messageId=$messageId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkListUsersResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkListUsersResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRetrieveJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRetrieveJobParams.kt deleted file mode 100644 index d0ba647c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRetrieveJobParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.Params -import com.courier.core.http.Headers -import com.courier.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get a bulk job */ -class BulkRetrieveJobParams -private constructor( - private val jobId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** 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(): BulkRetrieveJobParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BulkRetrieveJobParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkRetrieveJobParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(bulkRetrieveJobParams: BulkRetrieveJobParams) = apply { - jobId = bulkRetrieveJobParams.jobId - additionalHeaders = bulkRetrieveJobParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkRetrieveJobParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - 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 [BulkRetrieveJobParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkRetrieveJobParams = - BulkRetrieveJobParams(jobId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkRetrieveJobParams && - jobId == other.jobId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkRetrieveJobParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRetrieveJobResponse.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRetrieveJobResponse.kt deleted file mode 100644 index dc7e61b8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRetrieveJobResponse.kt +++ /dev/null @@ -1,650 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.Enum -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.checkRequired -import com.courier.errors.CourierInvalidDataException -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 java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class BulkRetrieveJobResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val job: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() - ) : this(job, mutableMapOf()) - - /** - * @throws CourierInvalidDataException 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 job(): Job = job.getRequired("job") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - @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 [BulkRetrieveJobResponse]. - * - * The following fields are required: - * ```java - * .job() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkRetrieveJobResponse]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkRetrieveJobResponse: BulkRetrieveJobResponse) = apply { - job = bulkRetrieveJobResponse.job - additionalProperties = bulkRetrieveJobResponse.additionalProperties.toMutableMap() - } - - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. - */ - fun job(job: JsonField) = apply { this.job = job } - - 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 [BulkRetrieveJobResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .job() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkRetrieveJobResponse = - BulkRetrieveJobResponse(checkRequired("job", job), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): BulkRetrieveJobResponse = apply { - if (validated) { - return@apply - } - - job().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = (job.asKnown().getOrNull()?.validity() ?: 0) - - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val definition: JsonField, - private val enqueued: JsonField, - private val failures: JsonField, - private val received: JsonField, - private val status: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("definition") - @ExcludeMissing - definition: JsonField = JsonMissing.of(), - @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), - @JsonProperty("failures") @ExcludeMissing failures: JsonField = JsonMissing.of(), - @JsonProperty("received") @ExcludeMissing received: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(definition, enqueued, failures, received, status, mutableMapOf()) - - /** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental content) - * in addition to `event` - * - * @throws CourierInvalidDataException 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 definition(): InboundBulkMessage = definition.getRequired("definition") - - /** - * @throws CourierInvalidDataException 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 enqueued(): Long = enqueued.getRequired("enqueued") - - /** - * @throws CourierInvalidDataException 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 failures(): Long = failures.getRequired("failures") - - /** - * @throws CourierInvalidDataException 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 received(): Long = received.getRequired("received") - - /** - * @throws CourierInvalidDataException 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 status(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [definition]. - * - * Unlike [definition], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("definition") - @ExcludeMissing - fun _definition(): JsonField = definition - - /** - * Returns the raw JSON value of [enqueued]. - * - * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued - - /** - * Returns the raw JSON value of [failures]. - * - * Unlike [failures], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("failures") @ExcludeMissing fun _failures(): JsonField = failures - - /** - * Returns the raw JSON value of [received]. - * - * Unlike [received], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("received") @ExcludeMissing fun _received(): JsonField = received - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @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 [Job]. - * - * The following fields are required: - * ```java - * .definition() - * .enqueued() - * .failures() - * .received() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var definition: JsonField? = null - private var enqueued: JsonField? = null - private var failures: JsonField? = null - private var received: JsonField? = null - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - definition = job.definition - enqueued = job.enqueued - failures = job.failures - received = job.received - status = job.status - additionalProperties = job.additionalProperties.toMutableMap() - } - - /** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental - * content) in addition to `event` - */ - fun definition(definition: InboundBulkMessage) = definition(JsonField.of(definition)) - - /** - * Sets [Builder.definition] to an arbitrary JSON value. - * - * You should usually call [Builder.definition] with a well-typed [InboundBulkMessage] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun definition(definition: JsonField) = apply { - this.definition = definition - } - - fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) - - /** - * Sets [Builder.enqueued] to an arbitrary JSON value. - * - * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } - - fun failures(failures: Long) = failures(JsonField.of(failures)) - - /** - * Sets [Builder.failures] to an arbitrary JSON value. - * - * You should usually call [Builder.failures] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun failures(failures: JsonField) = apply { this.failures = failures } - - fun received(received: Long) = received(JsonField.of(received)) - - /** - * Sets [Builder.received] to an arbitrary JSON value. - * - * You should usually call [Builder.received] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun received(received: JsonField) = apply { this.received = received } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - 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 [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .definition() - * .enqueued() - * .failures() - * .received() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("definition", definition), - checkRequired("enqueued", enqueued), - checkRequired("failures", failures), - checkRequired("received", received), - checkRequired("status", status), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Job = apply { - if (validated) { - return@apply - } - - definition().validate() - enqueued() - failures() - received() - status().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - (definition.asKnown().getOrNull()?.validity() ?: 0) + - (if (enqueued.asKnown().isPresent) 1 else 0) + - (if (failures.asKnown().isPresent) 1 else 0) + - (if (received.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREATED = of("CREATED") - - @JvmField val PROCESSING = of("PROCESSING") - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val ERROR = of("ERROR") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CREATED, - PROCESSING, - COMPLETED, - ERROR, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREATED, - PROCESSING, - COMPLETED, - ERROR, - /** - * An enum member indicating that [Status] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREATED -> Value.CREATED - PROCESSING -> Value.PROCESSING - COMPLETED -> Value.COMPLETED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREATED -> Known.CREATED - PROCESSING -> Known.PROCESSING - COMPLETED -> Known.COMPLETED - ERROR -> Known.ERROR - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Job && - definition == other.definition && - enqueued == other.enqueued && - failures == other.failures && - received == other.received && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(definition, enqueued, failures, received, status, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{definition=$definition, enqueued=$enqueued, failures=$failures, received=$received, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkRetrieveJobResponse && - job == other.job && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkRetrieveJobResponse{job=$job, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRunJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRunJobParams.kt deleted file mode 100644 index a92accb8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/BulkRunJobParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.core.Params -import com.courier.core.http.Headers -import com.courier.core.http.QueryParams -import com.courier.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Run a bulk job */ -class BulkRunJobParams -private constructor( - private val jobId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** 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(): BulkRunJobParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BulkRunJobParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkRunJobParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkRunJobParams: BulkRunJobParams) = apply { - jobId = bulkRunJobParams.jobId - additionalHeaders = bulkRunJobParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkRunJobParams.additionalQueryParams.toBuilder() - additionalBodyProperties = bulkRunJobParams.additionalBodyProperties.toMutableMap() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - 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) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [BulkRunJobParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkRunJobParams = - BulkRunJobParams( - jobId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkRunJobParams && - jobId == other.jobId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(jobId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "BulkRunJobParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/InboundBulkMessage.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/InboundBulkMessage.kt deleted file mode 100644 index 6eaba94f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/InboundBulkMessage.kt +++ /dev/null @@ -1,998 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.BaseDeserializer -import com.courier.core.BaseSerializer -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.allMaxBy -import com.courier.core.checkRequired -import com.courier.core.getOrThrow -import com.courier.core.toImmutable -import com.courier.errors.CourierInvalidDataException -import com.courier.models.ElementalContent -import com.courier.models.ElementalContentSugar -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.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Bulk message definition. Supports two formats: - * - V1 format: Requires `event` field (event ID or notification ID) - * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental content) in - * addition to `event` - */ -class InboundBulkMessage -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val event: JsonField, - private val brand: JsonField, - private val content: JsonField, - private val data: JsonField, - private val locale: JsonField, - private val override: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("locale") @ExcludeMissing locale: JsonField = JsonMissing.of(), - @JsonProperty("override") @ExcludeMissing override: JsonField = JsonMissing.of(), - @JsonProperty("template") @ExcludeMissing template: JsonField = JsonMissing.of(), - ) : this(event, brand, content, data, locale, override, template, mutableMapOf()) - - /** - * Event ID or Notification ID (required). Can be either a Notification ID (e.g., - * "FRH3QXM9E34W4RKP7MRC8NZ1T8V8") or a custom Event ID (e.g., "welcome-email") mapped to a - * notification. - * - * @throws CourierInvalidDataException 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 event(): String = event.getRequired("event") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brand(): Optional = brand.getOptional("brand") - - /** - * Elemental content (optional, for V2 format). When provided, this will be used instead of the - * notification associated with the `event` field. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun locale(): Optional = locale.getOptional("locale") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun override(): Optional = override.getOptional("override") - - /** - * Notification ID or template ID (optional, for V2 format). When provided, this will be used - * instead of the notification associated with the `event` field. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun template(): Optional = template.getOptional("template") - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [locale]. - * - * Unlike [locale], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale - - /** - * Returns the raw JSON value of [override]. - * - * Unlike [override], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("override") @ExcludeMissing fun _override(): JsonField = override - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template - - @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 [InboundBulkMessage]. - * - * The following fields are required: - * ```java - * .event() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundBulkMessage]. */ - class Builder internal constructor() { - - private var event: JsonField? = null - private var brand: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var locale: JsonField = JsonMissing.of() - private var override: JsonField = JsonMissing.of() - private var template: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundBulkMessage: InboundBulkMessage) = apply { - event = inboundBulkMessage.event - brand = inboundBulkMessage.brand - content = inboundBulkMessage.content - data = inboundBulkMessage.data - locale = inboundBulkMessage.locale - override = inboundBulkMessage.override - template = inboundBulkMessage.template - additionalProperties = inboundBulkMessage.additionalProperties.toMutableMap() - } - - /** - * Event ID or Notification ID (required). Can be either a Notification ID (e.g., - * "FRH3QXM9E34W4RKP7MRC8NZ1T8V8") or a custom Event ID (e.g., "welcome-email") mapped to a - * notification. - */ - fun event(event: String) = event(JsonField.of(event)) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brand(brand: JsonField) = apply { this.brand = brand } - - /** - * Elemental content (optional, for V2 format). When provided, this will be used instead of - * the notification associated with the `event` field. - */ - fun content(content: Content?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [Content] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - /** - * Alias for calling [content] with - * `Content.ofElementalContentSugar(elementalContentSugar)`. - */ - fun content(elementalContentSugar: ElementalContentSugar) = - content(Content.ofElementalContentSugar(elementalContentSugar)) - - /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun locale(locale: Locale?) = locale(JsonField.ofNullable(locale)) - - /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ - fun locale(locale: Optional) = locale(locale.getOrNull()) - - /** - * Sets [Builder.locale] to an arbitrary JSON value. - * - * You should usually call [Builder.locale] with a well-typed [Locale] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun locale(locale: JsonField) = apply { this.locale = locale } - - fun override(override: Override?) = override(JsonField.ofNullable(override)) - - /** Alias for calling [Builder.override] with `override.orElse(null)`. */ - fun override(override: Optional) = override(override.getOrNull()) - - /** - * Sets [Builder.override] to an arbitrary JSON value. - * - * You should usually call [Builder.override] with a well-typed [Override] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun override(override: JsonField) = apply { this.override = override } - - /** - * Notification ID or template ID (optional, for V2 format). When provided, this will be - * used instead of the notification associated with the `event` field. - */ - fun template(template: String?) = template(JsonField.ofNullable(template)) - - /** Alias for calling [Builder.template] with `template.orElse(null)`. */ - fun template(template: Optional) = template(template.getOrNull()) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - 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 [InboundBulkMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .event() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InboundBulkMessage = - InboundBulkMessage( - checkRequired("event", event), - brand, - content, - data, - locale, - override, - template, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): InboundBulkMessage = apply { - if (validated) { - return@apply - } - - event() - brand() - content().ifPresent { it.validate() } - data().ifPresent { it.validate() } - locale().ifPresent { it.validate() } - override().ifPresent { it.validate() } - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 (event.asKnown().isPresent) 1 else 0) + - (if (brand.asKnown().isPresent) 1 else 0) + - (content.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (locale.asKnown().getOrNull()?.validity() ?: 0) + - (override.asKnown().getOrNull()?.validity() ?: 0) + - (if (template.asKnown().isPresent) 1 else 0) - - /** - * Elemental content (optional, for V2 format). When provided, this will be used instead of the - * notification associated with the `event` field. - */ - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val elementalContentSugar: ElementalContentSugar? = null, - private val elemental: ElementalContent? = null, - private val _json: JsonValue? = null, - ) { - - /** Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. */ - fun elementalContentSugar(): Optional = - Optional.ofNullable(elementalContentSugar) - - fun elemental(): Optional = Optional.ofNullable(elemental) - - fun isElementalContentSugar(): Boolean = elementalContentSugar != null - - fun isElemental(): Boolean = elemental != null - - /** Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. */ - fun asElementalContentSugar(): ElementalContentSugar = - elementalContentSugar.getOrThrow("elementalContentSugar") - - fun asElemental(): ElementalContent = elemental.getOrThrow("elemental") - - 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.courier.core.JsonValue; - * import java.util.Optional; - * - * Optional result = content.accept(new Content.Visitor>() { - * @Override - * public Optional visitElementalContentSugar(ElementalContentSugar elementalContentSugar) { - * return Optional.of(elementalContentSugar.toString()); - * } - * - * // ... - * - * @Override - * public Optional unknown(JsonValue json) { - * // Or inspect the `json`. - * return Optional.empty(); - * } - * }); - * ``` - * - * @throws CourierInvalidDataException if [Visitor.unknown] is not overridden in [visitor] - * and the current variant is unknown. - */ - fun accept(visitor: Visitor): T = - when { - elementalContentSugar != null -> - visitor.visitElementalContentSugar(elementalContentSugar) - elemental != null -> visitor.visitElemental(elemental) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Content = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitElementalContentSugar( - elementalContentSugar: ElementalContentSugar - ) { - elementalContentSugar.validate() - } - - override fun visitElemental(elemental: ElementalContent) { - elemental.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - accept( - object : Visitor { - override fun visitElementalContentSugar( - elementalContentSugar: ElementalContentSugar - ) = elementalContentSugar.validity() - - override fun visitElemental(elemental: ElementalContent) = elemental.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - elementalContentSugar == other.elementalContentSugar && - elemental == other.elemental - } - - override fun hashCode(): Int = Objects.hash(elementalContentSugar, elemental) - - override fun toString(): String = - when { - elementalContentSugar != null -> - "Content{elementalContentSugar=$elementalContentSugar}" - elemental != null -> "Content{elemental=$elemental}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - - companion object { - - /** Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. */ - @JvmStatic - fun ofElementalContentSugar(elementalContentSugar: ElementalContentSugar) = - Content(elementalContentSugar = elementalContentSugar) - - @JvmStatic fun ofElemental(elemental: ElementalContent) = Content(elemental = elemental) - } - - /** - * An interface that defines how to map each variant of [Content] to a value of type [T]. - */ - interface Visitor { - - /** Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. */ - fun visitElementalContentSugar(elementalContentSugar: ElementalContentSugar): T - - fun visitElemental(elemental: ElementalContent): T - - /** - * Maps an unknown variant of [Content] to a value of type [T]. - * - * An instance of [Content] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Content: $json") - } - } - - internal class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Content(elementalContentSugar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(elemental = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Content(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.elementalContentSugar != null -> - generator.writeObject(value.elementalContentSugar) - value.elemental != null -> generator.writeObject(value.elemental) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - } - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - 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 [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Locale - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Locale]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Locale]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(locale: Locale) = apply { - additionalProperties = locale.additionalProperties.toMutableMap() - } - - 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 [Locale]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Locale = Locale(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Locale = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Locale && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Locale{additionalProperties=$additionalProperties}" - } - - class Override - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Override]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Override]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(override: Override) = apply { - additionalProperties = override.additionalProperties.toMutableMap() - } - - 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 [Override]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Override = Override(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Override = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Override && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Override{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundBulkMessage && - event == other.event && - brand == other.brand && - content == other.content && - data == other.data && - locale == other.locale && - override == other.override && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(event, brand, content, data, locale, override, template, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundBulkMessage{event=$event, brand=$brand, content=$content, data=$data, locale=$locale, override=$override, template=$template, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/bulk/InboundBulkMessageUser.kt b/courier-java-core/src/main/kotlin/com/courier/models/bulk/InboundBulkMessageUser.kt deleted file mode 100644 index 26a116b7..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/bulk/InboundBulkMessageUser.kt +++ /dev/null @@ -1,441 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.ExcludeMissing -import com.courier.core.JsonField -import com.courier.core.JsonMissing -import com.courier.core.JsonValue -import com.courier.core.toImmutable -import com.courier.errors.CourierInvalidDataException -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -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 java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class InboundBulkMessageUser -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val data: JsonValue, - private val preferences: JsonField, - private val profile: JsonField, - private val recipient: JsonField, - private val to: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of(), - @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), - ) : this(data, preferences, profile, recipient, to, mutableMapOf()) - - /** - * User-specific data that will be merged with message.data - * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = inboundBulkMessageUser.data().convert(MyClass.class); - * ``` - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * User profile information. For email-based bulk jobs, `profile.email` is required for provider - * routing to determine if the message can be delivered. The email address should be provided - * here rather than in `to.email`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun profile(): Optional = profile.getOptional("profile") - - /** - * User ID (legacy field, use profile or to.user_id instead) - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * Optional recipient information. Note: For email provider routing, use `profile.email` instead - * of `to.email`. The `to` field is primarily used for recipient identification and data - * merging. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - @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 [InboundBulkMessageUser]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundBulkMessageUser]. */ - class Builder internal constructor() { - - private var data: JsonValue = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var profile: JsonField = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundBulkMessageUser: InboundBulkMessageUser) = apply { - data = inboundBulkMessageUser.data - preferences = inboundBulkMessageUser.preferences - profile = inboundBulkMessageUser.profile - recipient = inboundBulkMessageUser.recipient - to = inboundBulkMessageUser.to - additionalProperties = inboundBulkMessageUser.additionalProperties.toMutableMap() - } - - /** User-specific data that will be merged with message.data */ - fun data(data: JsonValue) = apply { this.data = data } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** - * User profile information. For email-based bulk jobs, `profile.email` is required for - * provider routing to determine if the message can be delivered. The email address should - * be provided here rather than in `to.email`. - */ - fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - /** User ID (legacy field, use profile or to.user_id instead) */ - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - /** - * Optional recipient information. Note: For email provider routing, use `profile.email` - * instead of `to.email`. The `to` field is primarily used for recipient identification and - * data merging. - */ - fun to(to: UserRecipient?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [UserRecipient] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun to(to: JsonField) = apply { this.to = to } - - 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 [InboundBulkMessageUser]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InboundBulkMessageUser = - InboundBulkMessageUser( - data, - preferences, - profile, - recipient, - to, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): InboundBulkMessageUser = apply { - if (validated) { - return@apply - } - - preferences().ifPresent { it.validate() } - profile().ifPresent { it.validate() } - recipient() - to().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (profile.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (to.asKnown().getOrNull()?.validity() ?: 0) - - /** - * User profile information. For email-based bulk jobs, `profile.email` is required for provider - * routing to determine if the message can be delivered. The email address should be provided - * here rather than in `to.email`. - */ - class Profile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Profile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Profile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profile: Profile) = apply { - additionalProperties = profile.additionalProperties.toMutableMap() - } - - 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 [Profile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Profile = Profile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws CourierInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - 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 = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Profile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundBulkMessageUser && - data == other.data && - preferences == other.preferences && - profile == other.profile && - recipient == other.recipient && - to == other.to && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, preferences, profile, recipient, to, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundBulkMessageUser{data=$data, preferences=$preferences, profile=$profile, recipient=$recipient, to=$to, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/services/async/BulkServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/services/async/BulkServiceAsync.kt deleted file mode 100644 index 5b82508a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/services/async/BulkServiceAsync.kt +++ /dev/null @@ -1,347 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.services.async - -import com.courier.core.ClientOptions -import com.courier.core.RequestOptions -import com.courier.core.http.HttpResponse -import com.courier.core.http.HttpResponseFor -import com.courier.models.bulk.BulkAddUsersParams -import com.courier.models.bulk.BulkCreateJobParams -import com.courier.models.bulk.BulkCreateJobResponse -import com.courier.models.bulk.BulkListUsersParams -import com.courier.models.bulk.BulkListUsersResponse -import com.courier.models.bulk.BulkRetrieveJobParams -import com.courier.models.bulk.BulkRetrieveJobResponse -import com.courier.models.bulk.BulkRunJobParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BulkServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkServiceAsync - - /** - * Ingest user data into a Bulk Job. - * - * **Important**: For email-based bulk jobs, each user must include `profile.email` for provider - * routing to work correctly. The `to.email` field is not sufficient for email provider routing. - */ - fun addUsers(jobId: String, params: BulkAddUsersParams): CompletableFuture = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams): CompletableFuture = - addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Creates a new bulk job for sending messages to multiple recipients. - * - * **Required**: `message.event` (event ID or notification ID) - * - * **Optional (V2 format)**: `message.template` (notification ID) or `message.content` - * (Elemental content) can be provided to override the notification associated with the event. - */ - fun createJob(params: BulkCreateJobParams): CompletableFuture = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Get Bulk Job Users */ - fun listUsers(jobId: String): CompletableFuture = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): CompletableFuture = listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see listUsers */ - fun listUsers(params: BulkListUsersParams): CompletableFuture = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** Get a bulk job */ - fun retrieveJob(jobId: String): CompletableFuture = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): CompletableFuture = - retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieveJob */ - fun retrieveJob(params: BulkRetrieveJobParams): CompletableFuture = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** Run a bulk job */ - fun runJob(jobId: String): CompletableFuture = runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - ): CompletableFuture = runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see runJob */ - fun runJob(params: BulkRunJobParams): CompletableFuture = - runJob(params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(jobId: String, requestOptions: RequestOptions): CompletableFuture = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - - /** A view of [BulkServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}`, but is otherwise the same as - * [BulkServiceAsync.addUsers]. - */ - fun addUsers(jobId: String, params: BulkAddUsersParams): CompletableFuture = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams): CompletableFuture = - addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `post /bulk`, but is otherwise the same as - * [BulkServiceAsync.createJob]. - */ - fun createJob( - params: BulkCreateJobParams - ): CompletableFuture> = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}/users`, but is otherwise the same as - * [BulkServiceAsync.listUsers]. - */ - fun listUsers(jobId: String): CompletableFuture> = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): CompletableFuture> = - listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams - ): CompletableFuture> = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}`, but is otherwise the same as - * [BulkServiceAsync.retrieveJob]. - */ - fun retrieveJob( - jobId: String - ): CompletableFuture> = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): CompletableFuture> = - retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams - ): CompletableFuture> = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}/run`, but is otherwise the same as - * [BulkServiceAsync.runJob]. - */ - fun runJob(jobId: String): CompletableFuture = - runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - ): CompletableFuture = runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see runJob */ - fun runJob(params: BulkRunJobParams): CompletableFuture = - runJob(params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(jobId: String, requestOptions: RequestOptions): CompletableFuture = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/services/async/BulkServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/services/async/BulkServiceAsyncImpl.kt deleted file mode 100644 index 1b13733f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/services/async/BulkServiceAsyncImpl.kt +++ /dev/null @@ -1,243 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.services.async - -import com.courier.core.ClientOptions -import com.courier.core.RequestOptions -import com.courier.core.checkRequired -import com.courier.core.handlers.emptyHandler -import com.courier.core.handlers.errorBodyHandler -import com.courier.core.handlers.errorHandler -import com.courier.core.handlers.jsonHandler -import com.courier.core.http.HttpMethod -import com.courier.core.http.HttpRequest -import com.courier.core.http.HttpResponse -import com.courier.core.http.HttpResponse.Handler -import com.courier.core.http.HttpResponseFor -import com.courier.core.http.json -import com.courier.core.http.parseable -import com.courier.core.prepareAsync -import com.courier.models.bulk.BulkAddUsersParams -import com.courier.models.bulk.BulkCreateJobParams -import com.courier.models.bulk.BulkCreateJobResponse -import com.courier.models.bulk.BulkListUsersParams -import com.courier.models.bulk.BulkListUsersResponse -import com.courier.models.bulk.BulkRetrieveJobParams -import com.courier.models.bulk.BulkRetrieveJobResponse -import com.courier.models.bulk.BulkRunJobParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BulkServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BulkServiceAsync { - - private val withRawResponse: BulkServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BulkServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BulkServiceAsync = - BulkServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /bulk/{job_id} - withRawResponse().addUsers(params, requestOptions).thenAccept {} - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /bulk - withRawResponse().createJob(params, requestOptions).thenApply { it.parse() } - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /bulk/{job_id}/users - withRawResponse().listUsers(params, requestOptions).thenApply { it.parse() } - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /bulk/{job_id} - withRawResponse().retrieveJob(params, requestOptions).thenApply { it.parse() } - - override fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /bulk/{job_id}/run - withRawResponse().runJob(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BulkServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BulkServiceAsync.WithRawResponse = - BulkServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val addUsersHandler: Handler = emptyHandler() - - override fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", 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 { addUsersHandler.handle(it) } - } - } - } - - private val createJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk") - .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 { createJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listUsersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "users") - .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 { listUsersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0)) - .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 { retrieveJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val runJobHandler: Handler = emptyHandler() - - override fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "run") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .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 { runJobHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/services/blocking/BulkService.kt b/courier-java-core/src/main/kotlin/com/courier/services/blocking/BulkService.kt deleted file mode 100644 index 25143807..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/services/blocking/BulkService.kt +++ /dev/null @@ -1,340 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.services.blocking - -import com.courier.core.ClientOptions -import com.courier.core.RequestOptions -import com.courier.core.http.HttpResponse -import com.courier.core.http.HttpResponseFor -import com.courier.models.bulk.BulkAddUsersParams -import com.courier.models.bulk.BulkCreateJobParams -import com.courier.models.bulk.BulkCreateJobResponse -import com.courier.models.bulk.BulkListUsersParams -import com.courier.models.bulk.BulkListUsersResponse -import com.courier.models.bulk.BulkRetrieveJobParams -import com.courier.models.bulk.BulkRetrieveJobResponse -import com.courier.models.bulk.BulkRunJobParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface BulkService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkService - - /** - * Ingest user data into a Bulk Job. - * - * **Important**: For email-based bulk jobs, each user must include `profile.email` for provider - * routing to work correctly. The `to.email` field is not sufficient for email provider routing. - */ - fun addUsers(jobId: String, params: BulkAddUsersParams) = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams) = addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** - * Creates a new bulk job for sending messages to multiple recipients. - * - * **Required**: `message.event` (event ID or notification ID) - * - * **Optional (V2 format)**: `message.template` (notification ID) or `message.content` - * (Elemental content) can be provided to override the notification associated with the event. - */ - fun createJob(params: BulkCreateJobParams): BulkCreateJobResponse = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkCreateJobResponse - - /** Get Bulk Job Users */ - fun listUsers(jobId: String): BulkListUsersResponse = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkListUsersResponse = listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): BulkListUsersResponse = listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkListUsersResponse - - /** @see listUsers */ - fun listUsers(params: BulkListUsersParams): BulkListUsersResponse = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers(jobId: String, requestOptions: RequestOptions): BulkListUsersResponse = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** Get a bulk job */ - fun retrieveJob(jobId: String): BulkRetrieveJobResponse = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkRetrieveJobResponse = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): BulkRetrieveJobResponse = retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkRetrieveJobResponse - - /** @see retrieveJob */ - fun retrieveJob(params: BulkRetrieveJobParams): BulkRetrieveJobResponse = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob(jobId: String, requestOptions: RequestOptions): BulkRetrieveJobResponse = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** Run a bulk job */ - fun runJob(jobId: String) = runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - fun runJob(jobId: String, params: BulkRunJobParams = BulkRunJobParams.none()) = - runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(params: BulkRunJobParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see runJob */ - fun runJob(params: BulkRunJobParams) = runJob(params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(jobId: String, requestOptions: RequestOptions) = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - - /** A view of [BulkService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}`, but is otherwise the same as - * [BulkService.addUsers]. - */ - @MustBeClosed - fun addUsers(jobId: String, params: BulkAddUsersParams): HttpResponse = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - @MustBeClosed - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - @MustBeClosed - fun addUsers(params: BulkAddUsersParams): HttpResponse = - addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - @MustBeClosed - fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `post /bulk`, but is otherwise the same as - * [BulkService.createJob]. - */ - @MustBeClosed - fun createJob(params: BulkCreateJobParams): HttpResponseFor = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - @MustBeClosed - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}/users`, but is otherwise the same as - * [BulkService.listUsers]. - */ - @MustBeClosed - fun listUsers(jobId: String): HttpResponseFor = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): HttpResponseFor = listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see listUsers */ - @MustBeClosed - fun listUsers(params: BulkListUsersParams): HttpResponseFor = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}`, but is otherwise the same as - * [BulkService.retrieveJob]. - */ - @MustBeClosed - fun retrieveJob(jobId: String): HttpResponseFor = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): HttpResponseFor = - retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob(params: BulkRetrieveJobParams): HttpResponseFor = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}/run`, but is otherwise the same as - * [BulkService.runJob]. - */ - @MustBeClosed - fun runJob(jobId: String): HttpResponse = runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - @MustBeClosed - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - @MustBeClosed - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - ): HttpResponse = runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - @MustBeClosed - fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see runJob */ - @MustBeClosed - fun runJob(params: BulkRunJobParams): HttpResponse = runJob(params, RequestOptions.none()) - - /** @see runJob */ - @MustBeClosed - fun runJob(jobId: String, requestOptions: RequestOptions): HttpResponse = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/services/blocking/BulkServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/services/blocking/BulkServiceImpl.kt deleted file mode 100644 index 7f50398d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/services/blocking/BulkServiceImpl.kt +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.services.blocking - -import com.courier.core.ClientOptions -import com.courier.core.RequestOptions -import com.courier.core.checkRequired -import com.courier.core.handlers.emptyHandler -import com.courier.core.handlers.errorBodyHandler -import com.courier.core.handlers.errorHandler -import com.courier.core.handlers.jsonHandler -import com.courier.core.http.HttpMethod -import com.courier.core.http.HttpRequest -import com.courier.core.http.HttpResponse -import com.courier.core.http.HttpResponse.Handler -import com.courier.core.http.HttpResponseFor -import com.courier.core.http.json -import com.courier.core.http.parseable -import com.courier.core.prepare -import com.courier.models.bulk.BulkAddUsersParams -import com.courier.models.bulk.BulkCreateJobParams -import com.courier.models.bulk.BulkCreateJobResponse -import com.courier.models.bulk.BulkListUsersParams -import com.courier.models.bulk.BulkListUsersResponse -import com.courier.models.bulk.BulkRetrieveJobParams -import com.courier.models.bulk.BulkRetrieveJobResponse -import com.courier.models.bulk.BulkRunJobParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { - - private val withRawResponse: BulkService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BulkService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BulkService = - BulkServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun addUsers(params: BulkAddUsersParams, requestOptions: RequestOptions) { - // post /bulk/{job_id} - withRawResponse().addUsers(params, requestOptions) - } - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): BulkCreateJobResponse = - // post /bulk - withRawResponse().createJob(params, requestOptions).parse() - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): BulkListUsersResponse = - // get /bulk/{job_id}/users - withRawResponse().listUsers(params, requestOptions).parse() - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): BulkRetrieveJobResponse = - // get /bulk/{job_id} - withRawResponse().retrieveJob(params, requestOptions).parse() - - override fun runJob(params: BulkRunJobParams, requestOptions: RequestOptions) { - // post /bulk/{job_id}/run - withRawResponse().runJob(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BulkService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BulkService.WithRawResponse = - BulkServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val addUsersHandler: Handler = emptyHandler() - - override fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", 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 { addUsersHandler.handle(it) } - } - } - - private val createJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk") - .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 { createJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listUsersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "users") - .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 { listUsersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0)) - .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 { retrieveJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val runJobHandler: Handler = emptyHandler() - - override fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "run") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .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 { runJobHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkAddUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkAddUsersParamsTest.kt deleted file mode 100644 index d552754c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkAddUsersParamsTest.kt +++ /dev/null @@ -1,449 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.models.MessageContext -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkAddUsersParamsTest { - - @Test - fun create() { - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser(InboundBulkMessageUser.builder().build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.users()) - .containsExactly( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser(InboundBulkMessageUser.builder().build()) - .build() - - val body = params._body() - - assertThat(body.users()).containsExactly(InboundBulkMessageUser.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkCreateJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkCreateJobParamsTest.kt deleted file mode 100644 index 4e379328..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkCreateJobParamsTest.kt +++ /dev/null @@ -1,111 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.models.ElementalContentSugar -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkCreateJobParamsTest { - - @Test - fun create() { - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content(ElementalContentSugar.builder().body("body").title("title").build()) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .build() - } - - @Test - fun body() { - val params = - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content( - ElementalContentSugar.builder().body("body").title("title").build() - ) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .build() - - val body = params._body() - - assertThat(body.message()) - .isEqualTo( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content(ElementalContentSugar.builder().body("body").title("title").build()) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BulkCreateJobParams.builder() - .message(InboundBulkMessage.builder().event("event").build()) - .build() - - val body = params._body() - - assertThat(body.message()).isEqualTo(InboundBulkMessage.builder().event("event").build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkCreateJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkCreateJobResponseTest.kt deleted file mode 100644 index 286e8fb2..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkCreateJobResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkCreateJobResponseTest { - - @Test - fun create() { - val bulkCreateJobResponse = BulkCreateJobResponse.builder().jobId("jobId").build() - - assertThat(bulkCreateJobResponse.jobId()).isEqualTo("jobId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkCreateJobResponse = BulkCreateJobResponse.builder().jobId("jobId").build() - - val roundtrippedBulkCreateJobResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkCreateJobResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkCreateJobResponse).isEqualTo(bulkCreateJobResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkListUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkListUsersParamsTest.kt deleted file mode 100644 index a496918d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkListUsersParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkListUsersParamsTest { - - @Test - fun create() { - BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - } - - @Test - fun pathParams() { - val params = BulkListUsersParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BulkListUsersParams.builder().jobId("job_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkListUsersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkListUsersResponseTest.kt deleted file mode 100644 index 08c5c44f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkListUsersResponseTest.kt +++ /dev/null @@ -1,452 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.core.jsonMapper -import com.courier.models.MessageContext -import com.courier.models.Paging -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkListUsersResponseTest { - - @Test - fun create() { - val bulkListUsersResponse = - BulkListUsersResponse.builder() - .addItem( - BulkListUsersResponse.Item.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .status(BulkListUsersResponse.Item.Status.PENDING) - .messageId("messageId") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(bulkListUsersResponse.items()) - .containsExactly( - BulkListUsersResponse.Item.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .status(BulkListUsersResponse.Item.Status.PENDING) - .messageId("messageId") - .build() - ) - assertThat(bulkListUsersResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkListUsersResponse = - BulkListUsersResponse.builder() - .addItem( - BulkListUsersResponse.Item.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .status(BulkListUsersResponse.Item.Status.PENDING) - .messageId("messageId") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedBulkListUsersResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkListUsersResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkListUsersResponse).isEqualTo(bulkListUsersResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRetrieveJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRetrieveJobParamsTest.kt deleted file mode 100644 index c3f3889f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRetrieveJobParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkRetrieveJobParamsTest { - - @Test - fun create() { - BulkRetrieveJobParams.builder().jobId("job_id").build() - } - - @Test - fun pathParams() { - val params = BulkRetrieveJobParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRetrieveJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRetrieveJobResponseTest.kt deleted file mode 100644 index 8f3c66c8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRetrieveJobResponseTest.kt +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.core.jsonMapper -import com.courier.models.ElementalContentSugar -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkRetrieveJobResponseTest { - - @Test - fun create() { - val bulkRetrieveJobResponse = - BulkRetrieveJobResponse.builder() - .job( - BulkRetrieveJobResponse.Job.builder() - .definition( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content( - ElementalContentSugar.builder() - .body("body") - .title("title") - .build() - ) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .enqueued(0L) - .failures(0L) - .received(0L) - .status(BulkRetrieveJobResponse.Job.Status.CREATED) - .build() - ) - .build() - - assertThat(bulkRetrieveJobResponse.job()) - .isEqualTo( - BulkRetrieveJobResponse.Job.builder() - .definition( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content( - ElementalContentSugar.builder().body("body").title("title").build() - ) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .enqueued(0L) - .failures(0L) - .received(0L) - .status(BulkRetrieveJobResponse.Job.Status.CREATED) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkRetrieveJobResponse = - BulkRetrieveJobResponse.builder() - .job( - BulkRetrieveJobResponse.Job.builder() - .definition( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content( - ElementalContentSugar.builder() - .body("body") - .title("title") - .build() - ) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .enqueued(0L) - .failures(0L) - .received(0L) - .status(BulkRetrieveJobResponse.Job.Status.CREATED) - .build() - ) - .build() - - val roundtrippedBulkRetrieveJobResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkRetrieveJobResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkRetrieveJobResponse).isEqualTo(bulkRetrieveJobResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRunJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRunJobParamsTest.kt deleted file mode 100644 index 30c6a4a1..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/BulkRunJobParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkRunJobParamsTest { - - @Test - fun create() { - BulkRunJobParams.builder().jobId("job_id").build() - } - - @Test - fun pathParams() { - val params = BulkRunJobParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/InboundBulkMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/InboundBulkMessageTest.kt deleted file mode 100644 index 9dce5d30..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/InboundBulkMessageTest.kt +++ /dev/null @@ -1,102 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.core.jsonMapper -import com.courier.models.ElementalContentSugar -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InboundBulkMessageTest { - - @Test - fun create() { - val inboundBulkMessage = - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content(ElementalContentSugar.builder().body("body").title("title").build()) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - - assertThat(inboundBulkMessage.event()).isEqualTo("event") - assertThat(inboundBulkMessage.brand()).contains("brand") - assertThat(inboundBulkMessage.content()) - .contains( - InboundBulkMessage.Content.ofElementalContentSugar( - ElementalContentSugar.builder().body("body").title("title").build() - ) - ) - assertThat(inboundBulkMessage.data()) - .contains( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(inboundBulkMessage.locale()) - .contains( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - assertThat(inboundBulkMessage.override()) - .contains( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(inboundBulkMessage.template()).contains("template") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val inboundBulkMessage = - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content(ElementalContentSugar.builder().body("body").title("title").build()) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - - val roundtrippedInboundBulkMessage = - jsonMapper.readValue( - jsonMapper.writeValueAsString(inboundBulkMessage), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInboundBulkMessage).isEqualTo(inboundBulkMessage) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/bulk/InboundBulkMessageUserTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/bulk/InboundBulkMessageUserTest.kt deleted file mode 100644 index 9757c99c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/bulk/InboundBulkMessageUserTest.kt +++ /dev/null @@ -1,385 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.bulk - -import com.courier.core.JsonValue -import com.courier.core.jsonMapper -import com.courier.models.MessageContext -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InboundBulkMessageUserTest { - - @Test - fun create() { - val inboundBulkMessageUser = - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - - assertThat(inboundBulkMessageUser._data()).isEqualTo(JsonValue.from(mapOf())) - assertThat(inboundBulkMessageUser.preferences()) - .contains( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - assertThat(inboundBulkMessageUser.profile()) - .contains( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(inboundBulkMessageUser.recipient()).contains("recipient") - assertThat(inboundBulkMessageUser.to()) - .contains( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val inboundBulkMessageUser = - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - - val roundtrippedInboundBulkMessageUser = - jsonMapper.readValue( - jsonMapper.writeValueAsString(inboundBulkMessageUser), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInboundBulkMessageUser).isEqualTo(inboundBulkMessageUser) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/services/async/BulkServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/services/async/BulkServiceAsyncTest.kt deleted file mode 100644 index 6e2efb75..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/services/async/BulkServiceAsyncTest.kt +++ /dev/null @@ -1,255 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.services.async - -import com.courier.client.okhttp.CourierOkHttpClientAsync -import com.courier.core.JsonValue -import com.courier.models.ElementalContentSugar -import com.courier.models.MessageContext -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -import com.courier.models.bulk.BulkAddUsersParams -import com.courier.models.bulk.BulkCreateJobParams -import com.courier.models.bulk.BulkListUsersParams -import com.courier.models.bulk.InboundBulkMessage -import com.courier.models.bulk.InboundBulkMessageUser -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BulkServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun addUsers() { - val client = CourierOkHttpClientAsync.builder().apiKey("My API Key").build() - val bulkServiceAsync = client.bulk() - - val future = - bulkServiceAsync.addUsers( - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Mock server tests are disabled") - @Test - fun createJob() { - val client = CourierOkHttpClientAsync.builder().apiKey("My API Key").build() - val bulkServiceAsync = client.bulk() - - val responseFuture = - bulkServiceAsync.createJob( - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content( - ElementalContentSugar.builder().body("body").title("title").build() - ) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun listUsers() { - val client = CourierOkHttpClientAsync.builder().apiKey("My API Key").build() - val bulkServiceAsync = client.bulk() - - val responseFuture = - bulkServiceAsync.listUsers( - BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun retrieveJob() { - val client = CourierOkHttpClientAsync.builder().apiKey("My API Key").build() - val bulkServiceAsync = client.bulk() - - val responseFuture = bulkServiceAsync.retrieveJob("job_id") - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun runJob() { - val client = CourierOkHttpClientAsync.builder().apiKey("My API Key").build() - val bulkServiceAsync = client.bulk() - - val future = bulkServiceAsync.runJob("job_id") - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/services/blocking/BulkServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/services/blocking/BulkServiceTest.kt deleted file mode 100644 index 93ecfc69..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/services/blocking/BulkServiceTest.kt +++ /dev/null @@ -1,247 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.services.blocking - -import com.courier.client.okhttp.CourierOkHttpClient -import com.courier.core.JsonValue -import com.courier.models.ElementalContentSugar -import com.courier.models.MessageContext -import com.courier.models.RecipientPreferences -import com.courier.models.UserRecipient -import com.courier.models.bulk.BulkAddUsersParams -import com.courier.models.bulk.BulkCreateJobParams -import com.courier.models.bulk.BulkListUsersParams -import com.courier.models.bulk.InboundBulkMessage -import com.courier.models.bulk.InboundBulkMessageUser -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BulkServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun addUsers() { - val client = CourierOkHttpClient.builder().apiKey("My API Key").build() - val bulkService = client.bulk() - - bulkService.addUsers( - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile( - InboundBulkMessageUser.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .listId("list_id") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - ) - } - - @Disabled("Mock server tests are disabled") - @Test - fun createJob() { - val client = CourierOkHttpClient.builder().apiKey("My API Key").build() - val bulkService = client.bulk() - - val response = - bulkService.createJob( - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .event("event") - .brand("brand") - .content( - ElementalContentSugar.builder().body("body").title("title").build() - ) - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .override( - InboundBulkMessage.Override.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .template("template") - .build() - ) - .build() - ) - - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun listUsers() { - val client = CourierOkHttpClient.builder().apiKey("My API Key").build() - val bulkService = client.bulk() - - val response = - bulkService.listUsers( - BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - ) - - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun retrieveJob() { - val client = CourierOkHttpClient.builder().apiKey("My API Key").build() - val bulkService = client.bulk() - - val response = bulkService.retrieveJob("job_id") - - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun runJob() { - val client = CourierOkHttpClient.builder().apiKey("My API Key").build() - val bulkService = client.bulk() - - bulkService.runJob("job_id") - } -} diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/proguard/ProGuardCompatibilityTest.kt index 2783a45a..1f9b81c5 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/proguard/ProGuardCompatibilityTest.kt @@ -58,7 +58,6 @@ internal class ProGuardCompatibilityTest { assertThat(client.automations()).isNotNull() assertThat(client.journeys()).isNotNull() assertThat(client.brands()).isNotNull() - assertThat(client.bulk()).isNotNull() assertThat(client.digests()).isNotNull() assertThat(client.inbound()).isNotNull() assertThat(client.lists()).isNotNull()