diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1269f909..1eec10e9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.6.0" + ".": "4.7.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 4fa8359d..647de165 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 78 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-e3c16e3181f58323091b425c9ca546efdefbe4681255d611ff21de9050c249ee.yml -openapi_spec_hash: 9cc15d56d3c522db4dce917cec791142 -config_hash: b8333ea2756bea772420159bf539b168 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-b79e0eb1ab06f4076c48fa519e2b2ad792a0c483a5d017e43c938ca4c4be6988.yml +openapi_spec_hash: cb3cc2c1145503e5737a880326857aa4 +config_hash: ff903e824043dc81aca51a0ce21896d6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 24c59261..6b1c3f1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 4.7.0 (2026-01-12) + +Full Changelog: [v4.6.0...v4.7.0](https://github.com/trycourier/courier-java/compare/v4.6.0...v4.7.0) + +### Features + +* **client:** allow configuring dispatcher executor service ([86008d9](https://github.com/trycourier/courier-java/commit/86008d9281207c5dff33942f841fcf57fe9ac543)) + + +### Bug Fixes + +* **types:** change rules type from FilterConfig to Filter in NestedFilterConfig ([49ad2a8](https://github.com/trycourier/courier-java/commit/49ad2a877f281961289abaa1a00e38e52921a825)) + + +### Chores + +* **internal:** regenerate SDK with no functional changes ([1267b56](https://github.com/trycourier/courier-java/commit/1267b5646869806f1df16eb24b19ad1c988a0be6)) + ## 4.6.0 (2026-01-08) Full Changelog: [v4.5.0...v4.6.0](https://github.com/trycourier/courier-java/compare/v4.5.0...v4.6.0) diff --git a/README.md b/README.md index 9982213d..c8a8b3ed 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.courier/courier-java)](https://central.sonatype.com/artifact/com.courier/courier-java/4.6.0) -[![javadoc](https://javadoc.io/badge2/com.courier/courier-java/4.6.0/javadoc.svg)](https://javadoc.io/doc/com.courier/courier-java/4.6.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.courier/courier-java)](https://central.sonatype.com/artifact/com.courier/courier-java/4.7.0) +[![javadoc](https://javadoc.io/badge2/com.courier/courier-java/4.7.0/javadoc.svg)](https://javadoc.io/doc/com.courier/courier-java/4.7.0) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [www.courier.com](https://www.courier.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.courier/courier-java/4.6.0). +The REST API documentation can be found on [www.courier.com](https://www.courier.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.courier/courier-java/4.7.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [www.courier.com](https://www.courier ### Gradle ```kotlin -implementation("com.courier:courier-java:4.6.0") +implementation("com.courier:courier-java:4.7.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.courier:courier-java:4.6.0") com.courier courier-java - 4.6.0 + 4.7.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 8b0397c6..d206be55 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.courier" - version = "4.6.0" // x-release-please-version + version = "4.7.0" // x-release-please-version } subprojects { diff --git a/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClient.kt b/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClient.kt index 3ed8f6ab..429e095e 100644 --- a/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClient.kt +++ b/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClient.kt @@ -16,6 +16,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -44,11 +45,31 @@ class CourierOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -296,6 +317,7 @@ class CourierOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClientAsync.kt b/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClientAsync.kt index 692185c4..2e2adb16 100644 --- a/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClientAsync.kt +++ b/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/CourierOkHttpClientAsync.kt @@ -16,6 +16,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -44,11 +45,31 @@ class CourierOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -296,6 +317,7 @@ class CourierOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/OkHttpClient.kt b/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/OkHttpClient.kt index f1c31cc4..79595a1b 100644 --- a/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/OkHttpClient.kt +++ b/courier-java-client-okhttp/src/main/kotlin/com/courier/client/okhttp/OkHttpClient.kt @@ -15,11 +15,13 @@ import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -198,6 +200,7 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -208,6 +211,10 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { this.sslSocketFactory = sslSocketFactory } @@ -229,6 +236,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .callTimeout(timeout.request()) .proxy(proxy) .apply { + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { diff --git a/courier-java-core/src/main/kotlin/com/courier/models/audiences/FilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/models/audiences/FilterConfig.kt deleted file mode 100644 index 8893376e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/models/audiences/FilterConfig.kt +++ /dev/null @@ -1,198 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.audiences - -import com.courier.core.BaseDeserializer -import com.courier.core.BaseSerializer -import com.courier.core.JsonValue -import com.courier.core.allMaxBy -import com.courier.core.getOrThrow -import com.courier.errors.CourierInvalidDataException -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.Objects -import java.util.Optional - -/** A single filter to use for filtering */ -@JsonDeserialize(using = FilterConfig.Deserializer::class) -@JsonSerialize(using = FilterConfig.Serializer::class) -class FilterConfig -private constructor( - private val single: SingleFilterConfig? = null, - private val nested: NestedFilterConfig? = null, - private val _json: JsonValue? = null, -) { - - /** A single filter to use for filtering */ - fun single(): Optional = Optional.ofNullable(single) - - /** The operator to use for filtering */ - fun nested(): Optional = Optional.ofNullable(nested) - - fun isSingle(): Boolean = single != null - - fun isNested(): Boolean = nested != null - - /** A single filter to use for filtering */ - fun asSingle(): SingleFilterConfig = single.getOrThrow("single") - - /** The operator to use for filtering */ - fun asNested(): NestedFilterConfig = nested.getOrThrow("nested") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - single != null -> visitor.visitSingle(single) - nested != null -> visitor.visitNested(nested) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): FilterConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSingle(single: SingleFilterConfig) { - single.validate() - } - - override fun visitNested(nested: NestedFilterConfig) { - nested.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 visitSingle(single: SingleFilterConfig) = single.validity() - - override fun visitNested(nested: NestedFilterConfig) = nested.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FilterConfig && single == other.single && nested == other.nested - } - - override fun hashCode(): Int = Objects.hash(single, nested) - - override fun toString(): String = - when { - single != null -> "FilterConfig{single=$single}" - nested != null -> "FilterConfig{nested=$nested}" - _json != null -> "FilterConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FilterConfig") - } - - companion object { - - /** A single filter to use for filtering */ - @JvmStatic fun ofSingle(single: SingleFilterConfig) = FilterConfig(single = single) - - /** The operator to use for filtering */ - @JvmStatic fun ofNested(nested: NestedFilterConfig) = FilterConfig(nested = nested) - } - - /** - * An interface that defines how to map each variant of [FilterConfig] to a value of type [T]. - */ - interface Visitor { - - /** A single filter to use for filtering */ - fun visitSingle(single: SingleFilterConfig): T - - /** The operator to use for filtering */ - fun visitNested(nested: NestedFilterConfig): T - - /** - * Maps an unknown variant of [FilterConfig] to a value of type [T]. - * - * An instance of [FilterConfig] 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 FilterConfig: $json") - } - } - - internal class Deserializer : BaseDeserializer(FilterConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FilterConfig { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - FilterConfig(single = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - FilterConfig(nested = 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 -> FilterConfig(_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(FilterConfig::class) { - - override fun serialize( - value: FilterConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.single != null -> generator.writeObject(value.single) - value.nested != null -> generator.writeObject(value.nested) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FilterConfig") - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/audiences/NestedFilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/models/audiences/NestedFilterConfig.kt index 2f691053..e4518b44 100644 --- a/courier-java-core/src/main/kotlin/com/courier/models/audiences/NestedFilterConfig.kt +++ b/courier-java-core/src/main/kotlin/com/courier/models/audiences/NestedFilterConfig.kt @@ -23,16 +23,14 @@ class NestedFilterConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val operator: JsonField, - private val rules: JsonField>, + private val rules: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("operator") @ExcludeMissing operator: JsonField = JsonMissing.of(), - @JsonProperty("rules") - @ExcludeMissing - rules: JsonField> = JsonMissing.of(), + @JsonProperty("rules") @ExcludeMissing rules: JsonField> = JsonMissing.of(), ) : this(operator, rules, mutableMapOf()) /** @@ -47,7 +45,7 @@ private constructor( * @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 rules(): List = rules.getRequired("rules") + fun rules(): List = rules.getRequired("rules") /** * Returns the raw JSON value of [operator]. @@ -61,7 +59,7 @@ private constructor( * * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules + @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -93,7 +91,7 @@ private constructor( class Builder internal constructor() { private var operator: JsonField? = null - private var rules: JsonField>? = null + private var rules: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -115,34 +113,36 @@ private constructor( */ fun operator(operator: JsonField) = apply { this.operator = operator } - fun rules(rules: List) = rules(JsonField.of(rules)) + fun rules(rules: List) = rules(JsonField.of(rules)) /** * Sets [Builder.rules] to an arbitrary JSON value. * - * You should usually call [Builder.rules] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.rules] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun rules(rules: JsonField>) = apply { + fun rules(rules: JsonField>) = apply { this.rules = rules.map { it.toMutableList() } } /** - * Adds a single [FilterConfig] to [rules]. + * Adds a single [Filter] to [rules]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addRule(rule: FilterConfig) = apply { + fun addRule(rule: Filter) = apply { rules = (rules ?: JsonField.of(mutableListOf())).also { checkKnown("rules", it).add(rule) } } - /** Alias for calling [addRule] with `FilterConfig.ofSingle(single)`. */ - fun addRule(single: SingleFilterConfig) = addRule(FilterConfig.ofSingle(single)) + /** Alias for calling [addRule] with `Filter.ofSingleFilterConfig(singleFilterConfig)`. */ + fun addRule(singleFilterConfig: SingleFilterConfig) = + addRule(Filter.ofSingleFilterConfig(singleFilterConfig)) - /** Alias for calling [addRule] with `FilterConfig.ofNested(nested)`. */ - fun addRule(nested: NestedFilterConfig) = addRule(FilterConfig.ofNested(nested)) + /** Alias for calling [addRule] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. */ + fun addRule(nestedFilterConfig: NestedFilterConfig) = + addRule(Filter.ofNestedFilterConfig(nestedFilterConfig)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/courier-java-core/src/main/kotlin/com/courier/models/audiences/SingleFilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/models/audiences/SingleFilterConfig.kt index 8b5c7a19..f23a3c02 100644 --- a/courier-java-core/src/main/kotlin/com/courier/models/audiences/SingleFilterConfig.kt +++ b/courier-java-core/src/main/kotlin/com/courier/models/audiences/SingleFilterConfig.kt @@ -42,7 +42,7 @@ private constructor( fun operator(): Operator = operator.getRequired("operator") /** - * The attribe name from profile whose value will be operated against the filter value + * The attribute name from profile whose value will be operated against the filter value * * @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). @@ -133,7 +133,7 @@ private constructor( */ fun operator(operator: JsonField) = apply { this.operator = operator } - /** The attribe name from profile whose value will be operated against the filter value */ + /** The attribute name from profile whose value will be operated against the filter value */ fun path(path: String) = path(JsonField.of(path)) /** diff --git a/courier-java-core/src/main/kotlin/com/courier/models/inbound/InboundTrackEventParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/inbound/InboundTrackEventParams.kt index 1318652f..65d6dac3 100644 --- a/courier-java-core/src/main/kotlin/com/courier/models/inbound/InboundTrackEventParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/models/inbound/InboundTrackEventParams.kt @@ -61,7 +61,7 @@ private constructor( fun type(): Type = body.type() /** - * The user id associatiated with the track + * The user id associated with the track * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -207,7 +207,7 @@ private constructor( */ fun type(type: JsonField) = apply { body.type(type) } - /** The user id associatiated with the track */ + /** The user id associated with the track */ fun userId(userId: String?) = apply { body.userId(userId) } /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -422,7 +422,7 @@ private constructor( fun type(): Type = type.getRequired("type") /** - * The user id associatiated with the track + * The user id associated with the track * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -568,7 +568,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } - /** The user id associatiated with the track */ + /** The user id associated with the track */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ diff --git a/courier-java-core/src/main/kotlin/com/courier/models/tenants/DefaultPreferences.kt b/courier-java-core/src/main/kotlin/com/courier/models/tenants/DefaultPreferences.kt index 6b7d7112..b69fe6da 100644 --- a/courier-java-core/src/main/kotlin/com/courier/models/tenants/DefaultPreferences.kt +++ b/courier-java-core/src/main/kotlin/com/courier/models/tenants/DefaultPreferences.kt @@ -208,7 +208,7 @@ private constructor( /** * Override channel routing with custom preferences. This will override any template - * prefernces that are set, but a user can still customize their preferences + * preferences that are set, but a user can still customize their preferences * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -350,7 +350,7 @@ private constructor( /** * Override channel routing with custom preferences. This will override any template - * prefernces that are set, but a user can still customize their preferences + * preferences that are set, but a user can still customize their preferences */ fun hasCustomRouting(hasCustomRouting: Boolean?) = hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) diff --git a/courier-java-core/src/main/kotlin/com/courier/models/tenants/SubscriptionTopicNew.kt b/courier-java-core/src/main/kotlin/com/courier/models/tenants/SubscriptionTopicNew.kt index b9973d1f..d737125f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/models/tenants/SubscriptionTopicNew.kt +++ b/courier-java-core/src/main/kotlin/com/courier/models/tenants/SubscriptionTopicNew.kt @@ -57,7 +57,7 @@ private constructor( customRouting.getOptional("custom_routing") /** - * Override channel routing with custom preferences. This will override any template prefernces + * Override channel routing with custom preferences. This will override any template preferences * that are set, but a user can still customize their preferences * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -175,7 +175,7 @@ private constructor( /** * Override channel routing with custom preferences. This will override any template - * prefernces that are set, but a user can still customize their preferences + * preferences that are set, but a user can still customize their preferences */ fun hasCustomRouting(hasCustomRouting: Boolean?) = hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) diff --git a/courier-java-core/src/test/kotlin/com/courier/models/audiences/FilterConfigTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/audiences/FilterConfigTest.kt deleted file mode 100644 index ce0081c0..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/models/audiences/FilterConfigTest.kt +++ /dev/null @@ -1,115 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.models.audiences - -import com.courier.core.JsonValue -import com.courier.core.jsonMapper -import com.courier.errors.CourierInvalidDataException -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class FilterConfigTest { - - @Test - fun ofSingle() { - val single = - SingleFilterConfig.builder() - .operator(SingleFilterConfig.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - - val filterConfig = FilterConfig.ofSingle(single) - - assertThat(filterConfig.single()).contains(single) - assertThat(filterConfig.nested()).isEmpty - } - - @Test - fun ofSingleRoundtrip() { - val jsonMapper = jsonMapper() - val filterConfig = - FilterConfig.ofSingle( - SingleFilterConfig.builder() - .operator(SingleFilterConfig.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - - val roundtrippedFilterConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(filterConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFilterConfig).isEqualTo(filterConfig) - } - - @Test - fun ofNested() { - val nested = - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - SingleFilterConfig.builder() - .operator(SingleFilterConfig.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - - val filterConfig = FilterConfig.ofNested(nested) - - assertThat(filterConfig.single()).isEmpty - assertThat(filterConfig.nested()).contains(nested) - } - - @Test - fun ofNestedRoundtrip() { - val jsonMapper = jsonMapper() - val filterConfig = - FilterConfig.ofNested( - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - SingleFilterConfig.builder() - .operator(SingleFilterConfig.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - ) - - val roundtrippedFilterConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(filterConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFilterConfig).isEqualTo(filterConfig) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val filterConfig = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { filterConfig.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/audiences/NestedFilterConfigTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/audiences/NestedFilterConfigTest.kt index 11642222..943f4e35 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/audiences/NestedFilterConfigTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/audiences/NestedFilterConfigTest.kt @@ -26,7 +26,7 @@ internal class NestedFilterConfigTest { assertThat(nestedFilterConfig.operator()).isEqualTo(NestedFilterConfig.Operator.ENDS_WITH) assertThat(nestedFilterConfig.rules()) .containsExactly( - FilterConfig.ofSingle( + Filter.ofSingleFilterConfig( SingleFilterConfig.builder() .operator(SingleFilterConfig.Operator.ENDS_WITH) .path("path")