diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 8f3e0a49..b4e9013b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.15.0" + ".": "0.16.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index da3a67c8..0eb3dc01 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 40 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-a9080c0de1cdfd5f5b355e5267265eba790649d0b002cc98347b6b76e3e8f075.yml -openapi_spec_hash: ea95e4b3ebf37227b1b556f208968f62 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-f35f1b37bbee180194767c8644de479a1ce7166e863c4cc22f76115a7adac08f.yml +openapi_spec_hash: b62ddef06e729720dbae93de3efa0898 config_hash: 405ade725d72d542c60de821a127411b diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d034cd..de00b08b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.16.0 (2026-04-20) + +Full Changelog: [v0.15.0...v0.16.0](https://github.com/sentdm/sent-dm-java/compare/v0.15.0...v0.16.0) + +### Features + +* **api:** api update ([59c4e45](https://github.com/sentdm/sent-dm-java/commit/59c4e45772d5f667a6cc0fdeccbda9e5c7e168fa)) + ## 0.15.0 (2026-04-07) Full Changelog: [v0.14.0...v0.15.0](https://github.com/sentdm/sent-dm-java/compare/v0.14.0...v0.15.0) diff --git a/README.md b/README.md index 29d0cbdf..6f034e4a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/dm.sent/sent-java)](https://central.sonatype.com/artifact/dm.sent/sent-java/0.15.0) -[![javadoc](https://javadoc.io/badge2/dm.sent/sent-java/0.15.0/javadoc.svg)](https://javadoc.io/doc/dm.sent/sent-java/0.15.0) +[![Maven Central](https://img.shields.io/maven-central/v/dm.sent/sent-java)](https://central.sonatype.com/artifact/dm.sent/sent-java/0.16.0) +[![javadoc](https://javadoc.io/badge2/dm.sent/sent-java/0.16.0/javadoc.svg)](https://javadoc.io/doc/dm.sent/sent-java/0.16.0) @@ -22,7 +22,7 @@ Use the Sent MCP Server to enable AI assistants to interact with this API, allow -The REST API documentation can be found on [docs.sent.dm](https://docs.sent.dm). Javadocs are available on [javadoc.io](https://javadoc.io/doc/dm.sent/sent-java/0.15.0). +The REST API documentation can be found on [docs.sent.dm](https://docs.sent.dm). Javadocs are available on [javadoc.io](https://javadoc.io/doc/dm.sent/sent-java/0.16.0). @@ -33,7 +33,7 @@ The REST API documentation can be found on [docs.sent.dm](https://docs.sent.dm). ### Gradle ```kotlin -implementation("dm.sent:sent-java:0.15.0") +implementation("dm.sent:sent-java:0.16.0") ``` ### Maven @@ -42,7 +42,7 @@ implementation("dm.sent:sent-java:0.15.0") dm.sent sent-java - 0.15.0 + 0.16.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 4bd20f37..bcea0015 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "dm.sent" - version = "0.15.0" // x-release-please-version + version = "0.16.0" // x-release-please-version } subprojects { diff --git a/sent-java-core/src/main/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponse.kt b/sent-java-core/src/main/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponse.kt index 1867d8d7..c3c8df1e 100644 --- a/sent-java-core/src/main/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponse.kt +++ b/sent-java-core/src/main/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponse.kt @@ -450,6 +450,7 @@ private constructor( private constructor( private val activeContactPrice: JsonField, private val description: JsonField, + private val from: JsonField, private val price: JsonField, private val status: JsonField, private val timestamp: JsonField, @@ -464,6 +465,7 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing @@ -471,7 +473,15 @@ private constructor( @JsonProperty("timestamp") @ExcludeMissing timestamp: JsonField = JsonMissing.of(), - ) : this(activeContactPrice, description, price, status, timestamp, mutableMapOf()) + ) : this( + activeContactPrice, + description, + from, + price, + status, + timestamp, + mutableMapOf(), + ) /** * Active contact markup applied on top of the channel cost, formatted to 4 decimal @@ -491,6 +501,15 @@ private constructor( */ fun description(): Optional = description.getOptional("description") + /** + * Sender phone number for this activity (the customer's sending number for outbound, + * the external sender for inbound). Null when not reported by the provider. + * + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun from(): Optional = from.getOptional("from") + /** * Channel cost for this activity (e.g., SMS/WhatsApp provider cost), formatted to 4 * decimal places. @@ -536,6 +555,13 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [from]. + * + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from + /** * Returns the raw JSON value of [price]. * @@ -583,6 +609,7 @@ private constructor( private var activeContactPrice: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() + private var from: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var timestamp: JsonField = JsonMissing.of() @@ -592,6 +619,7 @@ private constructor( internal fun from(activity: Activity) = apply { activeContactPrice = activity.activeContactPrice description = activity.description + from = activity.from price = activity.price status = activity.status timestamp = activity.timestamp @@ -637,6 +665,25 @@ private constructor( this.description = description } + /** + * Sender phone number for this activity (the customer's sending number for + * outbound, the external sender for inbound). Null when not reported by the + * provider. + */ + fun from(from: String?) = from(JsonField.ofNullable(from)) + + /** Alias for calling [Builder.from] with `from.orElse(null)`. */ + fun from(from: Optional) = from(from.getOrNull()) + + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun from(from: JsonField) = apply { this.from = from } + /** * Channel cost for this activity (e.g., SMS/WhatsApp provider cost), formatted to 4 * decimal places. @@ -712,6 +759,7 @@ private constructor( Activity( activeContactPrice, description, + from, price, status, timestamp, @@ -728,6 +776,7 @@ private constructor( activeContactPrice() description() + from() price() status() timestamp() @@ -752,6 +801,7 @@ private constructor( internal fun validity(): Int = (if (activeContactPrice.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (if (from.asKnown().isPresent) 1 else 0) + (if (price.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + (if (timestamp.asKnown().isPresent) 1 else 0) @@ -764,6 +814,7 @@ private constructor( return other is Activity && activeContactPrice == other.activeContactPrice && description == other.description && + from == other.from && price == other.price && status == other.status && timestamp == other.timestamp && @@ -774,6 +825,7 @@ private constructor( Objects.hash( activeContactPrice, description, + from, price, status, timestamp, @@ -784,7 +836,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Activity{activeContactPrice=$activeContactPrice, description=$description, price=$price, status=$status, timestamp=$timestamp, additionalProperties=$additionalProperties}" + "Activity{activeContactPrice=$activeContactPrice, description=$description, from=$from, price=$price, status=$status, timestamp=$timestamp, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookCreateParams.kt b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookCreateParams.kt index a5d34db4..ccb25d80 100644 --- a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookCreateParams.kt +++ b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookCreateParams.kt @@ -56,6 +56,12 @@ private constructor( */ fun endpointUrl(): Optional = body.endpointUrl() + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun eventFilters(): Optional = body.eventFilters() + /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -95,6 +101,13 @@ private constructor( */ fun _endpointUrl(): JsonField = body._endpointUrl() + /** + * Returns the raw JSON value of [eventFilters]. + * + * Unlike [eventFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _eventFilters(): JsonField = body._eventFilters() + /** * Returns the raw JSON value of [eventTypes]. * @@ -171,8 +184,8 @@ private constructor( * - [sandbox] * - [displayName] * - [endpointUrl] + * - [eventFilters] * - [eventTypes] - * - [retryCount] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -213,6 +226,23 @@ private constructor( */ fun endpointUrl(endpointUrl: JsonField) = apply { body.endpointUrl(endpointUrl) } + fun eventFilters(eventFilters: EventFilters?) = apply { body.eventFilters(eventFilters) } + + /** Alias for calling [Builder.eventFilters] with `eventFilters.orElse(null)`. */ + fun eventFilters(eventFilters: Optional) = + eventFilters(eventFilters.getOrNull()) + + /** + * Sets [Builder.eventFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.eventFilters] with a well-typed [EventFilters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventFilters(eventFilters: JsonField) = apply { + body.eventFilters(eventFilters) + } + fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -405,6 +435,7 @@ private constructor( private val sandbox: JsonField, private val displayName: JsonField, private val endpointUrl: JsonField, + private val eventFilters: JsonField, private val eventTypes: JsonField>, private val retryCount: JsonField, private val timeoutSeconds: JsonField, @@ -420,6 +451,9 @@ private constructor( @JsonProperty("endpoint_url") @ExcludeMissing endpointUrl: JsonField = JsonMissing.of(), + @JsonProperty("event_filters") + @ExcludeMissing + eventFilters: JsonField = JsonMissing.of(), @JsonProperty("event_types") @ExcludeMissing eventTypes: JsonField> = JsonMissing.of(), @@ -433,6 +467,7 @@ private constructor( sandbox, displayName, endpointUrl, + eventFilters, eventTypes, retryCount, timeoutSeconds, @@ -463,6 +498,12 @@ private constructor( */ fun endpointUrl(): Optional = endpointUrl.getOptional("endpoint_url") + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventFilters(): Optional = eventFilters.getOptional("event_filters") + /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -506,6 +547,16 @@ private constructor( @ExcludeMissing fun _endpointUrl(): JsonField = endpointUrl + /** + * Returns the raw JSON value of [eventFilters]. + * + * Unlike [eventFilters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("event_filters") + @ExcludeMissing + fun _eventFilters(): JsonField = eventFilters + /** * Returns the raw JSON value of [eventTypes]. * @@ -556,6 +607,7 @@ private constructor( private var sandbox: JsonField = JsonMissing.of() private var displayName: JsonField = JsonMissing.of() private var endpointUrl: JsonField = JsonMissing.of() + private var eventFilters: JsonField = JsonMissing.of() private var eventTypes: JsonField>? = null private var retryCount: JsonField = JsonMissing.of() private var timeoutSeconds: JsonField = JsonMissing.of() @@ -566,6 +618,7 @@ private constructor( sandbox = body.sandbox displayName = body.displayName endpointUrl = body.endpointUrl + eventFilters = body.eventFilters eventTypes = body.eventTypes.map { it.toMutableList() } retryCount = body.retryCount timeoutSeconds = body.timeoutSeconds @@ -613,6 +666,24 @@ private constructor( this.endpointUrl = endpointUrl } + fun eventFilters(eventFilters: EventFilters?) = + eventFilters(JsonField.ofNullable(eventFilters)) + + /** Alias for calling [Builder.eventFilters] with `eventFilters.orElse(null)`. */ + fun eventFilters(eventFilters: Optional) = + eventFilters(eventFilters.getOrNull()) + + /** + * Sets [Builder.eventFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.eventFilters] with a well-typed [EventFilters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventFilters(eventFilters: JsonField) = apply { + this.eventFilters = eventFilters + } + fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -691,6 +762,7 @@ private constructor( sandbox, displayName, endpointUrl, + eventFilters, (eventTypes ?: JsonMissing.of()).map { it.toImmutable() }, retryCount, timeoutSeconds, @@ -708,6 +780,7 @@ private constructor( sandbox() displayName() endpointUrl() + eventFilters().ifPresent { it.validate() } eventTypes() retryCount() timeoutSeconds() @@ -733,6 +806,7 @@ private constructor( (if (sandbox.asKnown().isPresent) 1 else 0) + (if (displayName.asKnown().isPresent) 1 else 0) + (if (endpointUrl.asKnown().isPresent) 1 else 0) + + (eventFilters.asKnown().getOrNull()?.validity() ?: 0) + (eventTypes.asKnown().getOrNull()?.size ?: 0) + (if (retryCount.asKnown().isPresent) 1 else 0) + (if (timeoutSeconds.asKnown().isPresent) 1 else 0) @@ -746,6 +820,7 @@ private constructor( sandbox == other.sandbox && displayName == other.displayName && endpointUrl == other.endpointUrl && + eventFilters == other.eventFilters && eventTypes == other.eventTypes && retryCount == other.retryCount && timeoutSeconds == other.timeoutSeconds && @@ -757,6 +832,7 @@ private constructor( sandbox, displayName, endpointUrl, + eventFilters, eventTypes, retryCount, timeoutSeconds, @@ -767,7 +843,106 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{sandbox=$sandbox, displayName=$displayName, endpointUrl=$endpointUrl, eventTypes=$eventTypes, retryCount=$retryCount, timeoutSeconds=$timeoutSeconds, additionalProperties=$additionalProperties}" + "Body{sandbox=$sandbox, displayName=$displayName, endpointUrl=$endpointUrl, eventFilters=$eventFilters, eventTypes=$eventTypes, retryCount=$retryCount, timeoutSeconds=$timeoutSeconds, additionalProperties=$additionalProperties}" + } + + class EventFilters + @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 [EventFilters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventFilters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventFilters: EventFilters) = apply { + additionalProperties = eventFilters.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 [EventFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EventFilters = EventFilters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EventFilters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: SentInvalidDataException) { + 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 EventFilters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EventFilters{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponse.kt b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponse.kt index 52900660..19c045ab 100644 --- a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponse.kt +++ b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponse.kt @@ -405,8 +405,10 @@ private constructor( private constructor( private val description: JsonField, private val displayName: JsonField, + private val eventType: JsonField, private val isActive: JsonField, private val name: JsonField, + private val subTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -418,11 +420,17 @@ private constructor( @JsonProperty("display_name") @ExcludeMissing displayName: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), @JsonProperty("is_active") @ExcludeMissing isActive: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(description, displayName, isActive, name, mutableMapOf()) + @JsonProperty("sub_types") + @ExcludeMissing + subTypes: JsonField> = JsonMissing.of(), + ) : this(description, displayName, eventType, isActive, name, subTypes, mutableMapOf()) /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -436,6 +444,12 @@ private constructor( */ fun displayName(): Optional = displayName.getOptional("display_name") + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -448,6 +462,12 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subTypes(): Optional> = subTypes.getOptional("sub_types") + /** * Returns the raw JSON value of [description]. * @@ -468,6 +488,16 @@ private constructor( @ExcludeMissing fun _displayName(): JsonField = displayName + /** + * Returns the raw JSON value of [eventType]. + * + * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType + /** * Returns the raw JSON value of [isActive]. * @@ -485,6 +515,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [subTypes]. + * + * Unlike [subTypes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sub_types") + @ExcludeMissing + fun _subTypes(): JsonField> = subTypes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -508,16 +548,20 @@ private constructor( private var description: JsonField = JsonMissing.of() private var displayName: JsonField = JsonMissing.of() + private var eventType: JsonField = JsonMissing.of() private var isActive: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var subTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(eventType: EventType) = apply { description = eventType.description displayName = eventType.displayName + this.eventType = eventType.eventType isActive = eventType.isActive name = eventType.name + subTypes = eventType.subTypes.map { it.toMutableList() } additionalProperties = eventType.additionalProperties.toMutableMap() } @@ -552,6 +596,20 @@ private constructor( this.displayName = displayName } + fun eventType(eventType: String?) = eventType(JsonField.ofNullable(eventType)) + + /** Alias for calling [Builder.eventType] with `eventType.orElse(null)`. */ + fun eventType(eventType: Optional) = eventType(eventType.getOrNull()) + + /** + * Sets [Builder.eventType] to an arbitrary JSON value. + * + * You should usually call [Builder.eventType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } + fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) /** @@ -574,6 +632,34 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + fun subTypes(subTypes: List?) = subTypes(JsonField.ofNullable(subTypes)) + + /** Alias for calling [Builder.subTypes] with `subTypes.orElse(null)`. */ + fun subTypes(subTypes: Optional>) = subTypes(subTypes.getOrNull()) + + /** + * Sets [Builder.subTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.subTypes] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun subTypes(subTypes: JsonField>) = apply { + this.subTypes = subTypes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [subTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubType(subType: JsonValue) = apply { + subTypes = + (subTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("subTypes", it).add(subType) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -605,8 +691,10 @@ private constructor( EventType( description, displayName, + eventType, isActive, name, + (subTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -620,8 +708,10 @@ private constructor( description() displayName() + eventType() isActive() name() + subTypes() validated = true } @@ -643,8 +733,10 @@ private constructor( internal fun validity(): Int = (if (description.asKnown().isPresent) 1 else 0) + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (eventType.asKnown().isPresent) 1 else 0) + (if (isActive.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + (subTypes.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -654,19 +746,29 @@ private constructor( return other is EventType && description == other.description && displayName == other.displayName && + eventType == other.eventType && isActive == other.isActive && name == other.name && + subTypes == other.subTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(description, displayName, isActive, name, additionalProperties) + Objects.hash( + description, + displayName, + eventType, + isActive, + name, + subTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventType{description=$description, displayName=$displayName, isActive=$isActive, name=$name, additionalProperties=$additionalProperties}" + "EventType{description=$description, displayName=$displayName, eventType=$eventType, isActive=$isActive, name=$name, subTypes=$subTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookResponse.kt b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookResponse.kt index 63e8472a..e8c1339c 100644 --- a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookResponse.kt +++ b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookResponse.kt @@ -27,6 +27,7 @@ private constructor( private val createdAt: JsonField, private val displayName: JsonField, private val endpointUrl: JsonField, + private val eventFilters: JsonField, private val eventTypes: JsonField>, private val isActive: JsonField, private val lastDeliveryAttemptAt: JsonField, @@ -53,6 +54,9 @@ private constructor( @JsonProperty("endpoint_url") @ExcludeMissing endpointUrl: JsonField = JsonMissing.of(), + @JsonProperty("event_filters") + @ExcludeMissing + eventFilters: JsonField = JsonMissing.of(), @JsonProperty("event_types") @ExcludeMissing eventTypes: JsonField> = JsonMissing.of(), @@ -79,6 +83,7 @@ private constructor( createdAt, displayName, endpointUrl, + eventFilters, eventTypes, isActive, lastDeliveryAttemptAt, @@ -121,6 +126,12 @@ private constructor( */ fun endpointUrl(): Optional = endpointUrl.getOptional("endpoint_url") + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun eventFilters(): Optional = eventFilters.getOptional("event_filters") + /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -215,6 +226,15 @@ private constructor( @ExcludeMissing fun _endpointUrl(): JsonField = endpointUrl + /** + * Returns the raw JSON value of [eventFilters]. + * + * Unlike [eventFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_filters") + @ExcludeMissing + fun _eventFilters(): JsonField = eventFilters + /** * Returns the raw JSON value of [eventTypes]. * @@ -311,6 +331,7 @@ private constructor( private var createdAt: JsonField = JsonMissing.of() private var displayName: JsonField = JsonMissing.of() private var endpointUrl: JsonField = JsonMissing.of() + private var eventFilters: JsonField = JsonMissing.of() private var eventTypes: JsonField>? = null private var isActive: JsonField = JsonMissing.of() private var lastDeliveryAttemptAt: JsonField = JsonMissing.of() @@ -328,6 +349,7 @@ private constructor( createdAt = webhookResponse.createdAt displayName = webhookResponse.displayName endpointUrl = webhookResponse.endpointUrl + eventFilters = webhookResponse.eventFilters eventTypes = webhookResponse.eventTypes.map { it.toMutableList() } isActive = webhookResponse.isActive lastDeliveryAttemptAt = webhookResponse.lastDeliveryAttemptAt @@ -396,6 +418,24 @@ private constructor( */ fun endpointUrl(endpointUrl: JsonField) = apply { this.endpointUrl = endpointUrl } + fun eventFilters(eventFilters: EventFilters?) = + eventFilters(JsonField.ofNullable(eventFilters)) + + /** Alias for calling [Builder.eventFilters] with `eventFilters.orElse(null)`. */ + fun eventFilters(eventFilters: Optional) = + eventFilters(eventFilters.getOrNull()) + + /** + * Sets [Builder.eventFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.eventFilters] with a well-typed [EventFilters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventFilters(eventFilters: JsonField) = apply { + this.eventFilters = eventFilters + } + fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -560,6 +600,7 @@ private constructor( createdAt, displayName, endpointUrl, + eventFilters, (eventTypes ?: JsonMissing.of()).map { it.toImmutable() }, isActive, lastDeliveryAttemptAt, @@ -584,6 +625,7 @@ private constructor( createdAt() displayName() endpointUrl() + eventFilters().ifPresent { it.validate() } eventTypes() isActive() lastDeliveryAttemptAt() @@ -615,6 +657,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (if (displayName.asKnown().isPresent) 1 else 0) + (if (endpointUrl.asKnown().isPresent) 1 else 0) + + (eventFilters.asKnown().getOrNull()?.validity() ?: 0) + (eventTypes.asKnown().getOrNull()?.size ?: 0) + (if (isActive.asKnown().isPresent) 1 else 0) + (if (lastDeliveryAttemptAt.asKnown().isPresent) 1 else 0) + @@ -624,6 +667,105 @@ private constructor( (if (timeoutSeconds.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + class EventFilters + @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 [EventFilters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventFilters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventFilters: EventFilters) = apply { + additionalProperties = eventFilters.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 [EventFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EventFilters = EventFilters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EventFilters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: SentInvalidDataException) { + 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 EventFilters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EventFilters{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -635,6 +777,7 @@ private constructor( createdAt == other.createdAt && displayName == other.displayName && endpointUrl == other.endpointUrl && + eventFilters == other.eventFilters && eventTypes == other.eventTypes && isActive == other.isActive && lastDeliveryAttemptAt == other.lastDeliveryAttemptAt && @@ -653,6 +796,7 @@ private constructor( createdAt, displayName, endpointUrl, + eventFilters, eventTypes, isActive, lastDeliveryAttemptAt, @@ -668,5 +812,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebhookResponse{id=$id, consecutiveFailures=$consecutiveFailures, createdAt=$createdAt, displayName=$displayName, endpointUrl=$endpointUrl, eventTypes=$eventTypes, isActive=$isActive, lastDeliveryAttemptAt=$lastDeliveryAttemptAt, lastSuccessfulDeliveryAt=$lastSuccessfulDeliveryAt, retryCount=$retryCount, signingSecret=$signingSecret, timeoutSeconds=$timeoutSeconds, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "WebhookResponse{id=$id, consecutiveFailures=$consecutiveFailures, createdAt=$createdAt, displayName=$displayName, endpointUrl=$endpointUrl, eventFilters=$eventFilters, eventTypes=$eventTypes, isActive=$isActive, lastDeliveryAttemptAt=$lastDeliveryAttemptAt, lastSuccessfulDeliveryAt=$lastSuccessfulDeliveryAt, retryCount=$retryCount, signingSecret=$signingSecret, timeoutSeconds=$timeoutSeconds, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookUpdateParams.kt b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookUpdateParams.kt index 1cec72ed..bccc7efd 100644 --- a/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookUpdateParams.kt +++ b/sent-java-core/src/main/kotlin/dm/sent/models/webhooks/WebhookUpdateParams.kt @@ -59,6 +59,12 @@ private constructor( */ fun endpointUrl(): Optional = body.endpointUrl() + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun eventFilters(): Optional = body.eventFilters() + /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -98,6 +104,13 @@ private constructor( */ fun _endpointUrl(): JsonField = body._endpointUrl() + /** + * Returns the raw JSON value of [eventFilters]. + * + * Unlike [eventFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _eventFilters(): JsonField = body._eventFilters() + /** * Returns the raw JSON value of [eventTypes]. * @@ -181,8 +194,8 @@ private constructor( * - [sandbox] * - [displayName] * - [endpointUrl] + * - [eventFilters] * - [eventTypes] - * - [retryCount] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -223,6 +236,23 @@ private constructor( */ fun endpointUrl(endpointUrl: JsonField) = apply { body.endpointUrl(endpointUrl) } + fun eventFilters(eventFilters: EventFilters?) = apply { body.eventFilters(eventFilters) } + + /** Alias for calling [Builder.eventFilters] with `eventFilters.orElse(null)`. */ + fun eventFilters(eventFilters: Optional) = + eventFilters(eventFilters.getOrNull()) + + /** + * Sets [Builder.eventFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.eventFilters] with a well-typed [EventFilters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventFilters(eventFilters: JsonField) = apply { + body.eventFilters(eventFilters) + } + fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -422,6 +452,7 @@ private constructor( private val sandbox: JsonField, private val displayName: JsonField, private val endpointUrl: JsonField, + private val eventFilters: JsonField, private val eventTypes: JsonField>, private val retryCount: JsonField, private val timeoutSeconds: JsonField, @@ -437,6 +468,9 @@ private constructor( @JsonProperty("endpoint_url") @ExcludeMissing endpointUrl: JsonField = JsonMissing.of(), + @JsonProperty("event_filters") + @ExcludeMissing + eventFilters: JsonField = JsonMissing.of(), @JsonProperty("event_types") @ExcludeMissing eventTypes: JsonField> = JsonMissing.of(), @@ -450,6 +484,7 @@ private constructor( sandbox, displayName, endpointUrl, + eventFilters, eventTypes, retryCount, timeoutSeconds, @@ -480,6 +515,12 @@ private constructor( */ fun endpointUrl(): Optional = endpointUrl.getOptional("endpoint_url") + /** + * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventFilters(): Optional = eventFilters.getOptional("event_filters") + /** * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -523,6 +564,16 @@ private constructor( @ExcludeMissing fun _endpointUrl(): JsonField = endpointUrl + /** + * Returns the raw JSON value of [eventFilters]. + * + * Unlike [eventFilters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("event_filters") + @ExcludeMissing + fun _eventFilters(): JsonField = eventFilters + /** * Returns the raw JSON value of [eventTypes]. * @@ -573,6 +624,7 @@ private constructor( private var sandbox: JsonField = JsonMissing.of() private var displayName: JsonField = JsonMissing.of() private var endpointUrl: JsonField = JsonMissing.of() + private var eventFilters: JsonField = JsonMissing.of() private var eventTypes: JsonField>? = null private var retryCount: JsonField = JsonMissing.of() private var timeoutSeconds: JsonField = JsonMissing.of() @@ -583,6 +635,7 @@ private constructor( sandbox = body.sandbox displayName = body.displayName endpointUrl = body.endpointUrl + eventFilters = body.eventFilters eventTypes = body.eventTypes.map { it.toMutableList() } retryCount = body.retryCount timeoutSeconds = body.timeoutSeconds @@ -630,6 +683,24 @@ private constructor( this.endpointUrl = endpointUrl } + fun eventFilters(eventFilters: EventFilters?) = + eventFilters(JsonField.ofNullable(eventFilters)) + + /** Alias for calling [Builder.eventFilters] with `eventFilters.orElse(null)`. */ + fun eventFilters(eventFilters: Optional) = + eventFilters(eventFilters.getOrNull()) + + /** + * Sets [Builder.eventFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.eventFilters] with a well-typed [EventFilters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventFilters(eventFilters: JsonField) = apply { + this.eventFilters = eventFilters + } + fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -708,6 +779,7 @@ private constructor( sandbox, displayName, endpointUrl, + eventFilters, (eventTypes ?: JsonMissing.of()).map { it.toImmutable() }, retryCount, timeoutSeconds, @@ -725,6 +797,7 @@ private constructor( sandbox() displayName() endpointUrl() + eventFilters().ifPresent { it.validate() } eventTypes() retryCount() timeoutSeconds() @@ -750,6 +823,7 @@ private constructor( (if (sandbox.asKnown().isPresent) 1 else 0) + (if (displayName.asKnown().isPresent) 1 else 0) + (if (endpointUrl.asKnown().isPresent) 1 else 0) + + (eventFilters.asKnown().getOrNull()?.validity() ?: 0) + (eventTypes.asKnown().getOrNull()?.size ?: 0) + (if (retryCount.asKnown().isPresent) 1 else 0) + (if (timeoutSeconds.asKnown().isPresent) 1 else 0) @@ -763,6 +837,7 @@ private constructor( sandbox == other.sandbox && displayName == other.displayName && endpointUrl == other.endpointUrl && + eventFilters == other.eventFilters && eventTypes == other.eventTypes && retryCount == other.retryCount && timeoutSeconds == other.timeoutSeconds && @@ -774,6 +849,7 @@ private constructor( sandbox, displayName, endpointUrl, + eventFilters, eventTypes, retryCount, timeoutSeconds, @@ -784,7 +860,106 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{sandbox=$sandbox, displayName=$displayName, endpointUrl=$endpointUrl, eventTypes=$eventTypes, retryCount=$retryCount, timeoutSeconds=$timeoutSeconds, additionalProperties=$additionalProperties}" + "Body{sandbox=$sandbox, displayName=$displayName, endpointUrl=$endpointUrl, eventFilters=$eventFilters, eventTypes=$eventTypes, retryCount=$retryCount, timeoutSeconds=$timeoutSeconds, additionalProperties=$additionalProperties}" + } + + class EventFilters + @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 [EventFilters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventFilters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventFilters: EventFilters) = apply { + additionalProperties = eventFilters.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 [EventFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EventFilters = EventFilters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EventFilters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: SentInvalidDataException) { + 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 EventFilters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EventFilters{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponseTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponseTest.kt index e17d8523..9deaca94 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponseTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/messages/MessageRetrieveActivitiesResponseTest.kt @@ -23,6 +23,7 @@ internal class MessageRetrieveActivitiesResponseTest { MessageRetrieveActivitiesResponse.Data.Activity.builder() .activeContactPrice("active_contact_price") .description("description") + .from("from") .price("price") .status("status") .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -60,6 +61,7 @@ internal class MessageRetrieveActivitiesResponseTest { MessageRetrieveActivitiesResponse.Data.Activity.builder() .activeContactPrice("active_contact_price") .description("description") + .from("from") .price("price") .status("status") .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -103,6 +105,7 @@ internal class MessageRetrieveActivitiesResponseTest { MessageRetrieveActivitiesResponse.Data.Activity.builder() .activeContactPrice("active_contact_price") .description("description") + .from("from") .price("price") .status("status") .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/ApiResponseWebhookTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/ApiResponseWebhookTest.kt index baad6ed0..e9ef77ca 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/ApiResponseWebhookTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/ApiResponseWebhookTest.kt @@ -22,6 +22,11 @@ internal class ApiResponseWebhookTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -62,6 +67,11 @@ internal class ApiResponseWebhookTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -108,6 +118,11 @@ internal class ApiResponseWebhookTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookCreateParamsTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookCreateParamsTest.kt index df89b364..b3e6ec11 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookCreateParamsTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookCreateParamsTest.kt @@ -2,6 +2,7 @@ package dm.sent.models.webhooks +import dm.sent.core.JsonValue import dm.sent.core.http.Headers import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -17,7 +18,12 @@ internal class WebhookCreateParamsTest { .sandbox(false) .displayName("Order Notifications") .endpointUrl("https://example.com/webhooks/orders") - .addEventType("messages") + .eventFilters( + WebhookCreateParams.EventFilters.builder() + .putAdditionalProperty("message", JsonValue.from(listOf("delivered", "failed"))) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(3) .timeoutSeconds(30) @@ -33,7 +39,15 @@ internal class WebhookCreateParamsTest { .sandbox(false) .displayName("Order Notifications") .endpointUrl("https://example.com/webhooks/orders") - .addEventType("messages") + .eventFilters( + WebhookCreateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(3) .timeoutSeconds(30) @@ -68,7 +82,15 @@ internal class WebhookCreateParamsTest { .sandbox(false) .displayName("Order Notifications") .endpointUrl("https://example.com/webhooks/orders") - .addEventType("messages") + .eventFilters( + WebhookCreateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(3) .timeoutSeconds(30) @@ -79,7 +101,13 @@ internal class WebhookCreateParamsTest { assertThat(body.sandbox()).contains(false) assertThat(body.displayName()).contains("Order Notifications") assertThat(body.endpointUrl()).contains("https://example.com/webhooks/orders") - assertThat(body.eventTypes().getOrNull()).containsExactly("messages", "templates") + assertThat(body.eventFilters()) + .contains( + WebhookCreateParams.EventFilters.builder() + .putAdditionalProperty("message", JsonValue.from(listOf("delivered", "failed"))) + .build() + ) + assertThat(body.eventTypes().getOrNull()).containsExactly("message", "templates") assertThat(body.retryCount()).contains(3) assertThat(body.timeoutSeconds()).contains(30) } diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponseTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponseTest.kt index 33672741..a262c258 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponseTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListEventTypesResponseTest.kt @@ -21,8 +21,10 @@ internal class WebhookListEventTypesResponseTest { WebhookListEventTypesResponse.Data.EventType.builder() .description("description") .displayName("display_name") + .eventType("event_type") .isActive(true) .name("name") + .addSubType(JsonValue.from(mapOf())) .build() ) .build() @@ -56,8 +58,10 @@ internal class WebhookListEventTypesResponseTest { WebhookListEventTypesResponse.Data.EventType.builder() .description("description") .displayName("display_name") + .eventType("event_type") .isActive(true) .name("name") + .addSubType(JsonValue.from(mapOf())) .build() ) .build() @@ -97,8 +101,10 @@ internal class WebhookListEventTypesResponseTest { WebhookListEventTypesResponse.Data.EventType.builder() .description("description") .displayName("display_name") + .eventType("event_type") .isActive(true) .name("name") + .addSubType(JsonValue.from(mapOf())) .build() ) .build() diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListResponseTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListResponseTest.kt index 651de96a..6e0bd0c5 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListResponseTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookListResponseTest.kt @@ -39,6 +39,14 @@ internal class WebhookListResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(listOf("string")), + ) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt( @@ -102,6 +110,11 @@ internal class WebhookListResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -169,6 +182,14 @@ internal class WebhookListResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(listOf("string")), + ) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt( diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookResponseTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookResponseTest.kt index 428f5f39..cd5010f1 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookResponseTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookResponseTest.kt @@ -3,6 +3,7 @@ package dm.sent.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import dm.sent.core.JsonValue import dm.sent.core.jsonMapper import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull @@ -20,6 +21,11 @@ internal class WebhookResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -36,6 +42,12 @@ internal class WebhookResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(webhookResponse.displayName()).contains("display_name") assertThat(webhookResponse.endpointUrl()).contains("endpoint_url") + assertThat(webhookResponse.eventFilters()) + .contains( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) assertThat(webhookResponse.eventTypes().getOrNull()).containsExactly("string") assertThat(webhookResponse.isActive()).contains(true) assertThat(webhookResponse.lastDeliveryAttemptAt()) @@ -59,6 +71,11 @@ internal class WebhookResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("display_name") .endpointUrl("endpoint_url") + .eventFilters( + WebhookResponse.EventFilters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) .addEventType("string") .isActive(true) .lastDeliveryAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookUpdateParamsTest.kt b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookUpdateParamsTest.kt index 067748e3..9846c0b9 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookUpdateParamsTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/models/webhooks/WebhookUpdateParamsTest.kt @@ -2,6 +2,7 @@ package dm.sent.models.webhooks +import dm.sent.core.JsonValue import dm.sent.core.http.Headers import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -18,7 +19,12 @@ internal class WebhookUpdateParamsTest { .sandbox(false) .displayName("Updated Order Notifications") .endpointUrl("https://example.com/webhooks/orders-v2") - .addEventType("messages") + .eventFilters( + WebhookUpdateParams.EventFilters.builder() + .putAdditionalProperty("message", JsonValue.from(listOf("delivered", "failed"))) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(5) .timeoutSeconds(60) @@ -45,7 +51,15 @@ internal class WebhookUpdateParamsTest { .sandbox(false) .displayName("Updated Order Notifications") .endpointUrl("https://example.com/webhooks/orders-v2") - .addEventType("messages") + .eventFilters( + WebhookUpdateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(5) .timeoutSeconds(60) @@ -82,7 +96,15 @@ internal class WebhookUpdateParamsTest { .sandbox(false) .displayName("Updated Order Notifications") .endpointUrl("https://example.com/webhooks/orders-v2") - .addEventType("messages") + .eventFilters( + WebhookUpdateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(5) .timeoutSeconds(60) @@ -93,7 +115,13 @@ internal class WebhookUpdateParamsTest { assertThat(body.sandbox()).contains(false) assertThat(body.displayName()).contains("Updated Order Notifications") assertThat(body.endpointUrl()).contains("https://example.com/webhooks/orders-v2") - assertThat(body.eventTypes().getOrNull()).containsExactly("messages", "templates") + assertThat(body.eventFilters()) + .contains( + WebhookUpdateParams.EventFilters.builder() + .putAdditionalProperty("message", JsonValue.from(listOf("delivered", "failed"))) + .build() + ) + assertThat(body.eventTypes().getOrNull()).containsExactly("message", "templates") assertThat(body.retryCount()).contains(5) assertThat(body.timeoutSeconds()).contains(60) } diff --git a/sent-java-core/src/test/kotlin/dm/sent/services/async/WebhookServiceAsyncTest.kt b/sent-java-core/src/test/kotlin/dm/sent/services/async/WebhookServiceAsyncTest.kt index c2d2059c..aa9f4bb5 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/services/async/WebhookServiceAsyncTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/services/async/WebhookServiceAsyncTest.kt @@ -3,6 +3,7 @@ package dm.sent.services.async import dm.sent.client.okhttp.SentOkHttpClientAsync +import dm.sent.core.JsonValue import dm.sent.models.webhooks.WebhookCreateParams import dm.sent.models.webhooks.WebhookDeleteParams import dm.sent.models.webhooks.WebhookListEventTypesParams @@ -32,7 +33,15 @@ internal class WebhookServiceAsyncTest { .sandbox(false) .displayName("Order Notifications") .endpointUrl("https://example.com/webhooks/orders") - .addEventType("messages") + .eventFilters( + WebhookCreateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(3) .timeoutSeconds(30) @@ -76,7 +85,15 @@ internal class WebhookServiceAsyncTest { .sandbox(false) .displayName("Updated Order Notifications") .endpointUrl("https://example.com/webhooks/orders-v2") - .addEventType("messages") + .eventFilters( + WebhookUpdateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(5) .timeoutSeconds(60) diff --git a/sent-java-core/src/test/kotlin/dm/sent/services/blocking/WebhookServiceTest.kt b/sent-java-core/src/test/kotlin/dm/sent/services/blocking/WebhookServiceTest.kt index f7ea725c..fa1057d6 100644 --- a/sent-java-core/src/test/kotlin/dm/sent/services/blocking/WebhookServiceTest.kt +++ b/sent-java-core/src/test/kotlin/dm/sent/services/blocking/WebhookServiceTest.kt @@ -3,6 +3,7 @@ package dm.sent.services.blocking import dm.sent.client.okhttp.SentOkHttpClient +import dm.sent.core.JsonValue import dm.sent.models.webhooks.WebhookCreateParams import dm.sent.models.webhooks.WebhookDeleteParams import dm.sent.models.webhooks.WebhookListEventTypesParams @@ -32,7 +33,15 @@ internal class WebhookServiceTest { .sandbox(false) .displayName("Order Notifications") .endpointUrl("https://example.com/webhooks/orders") - .addEventType("messages") + .eventFilters( + WebhookCreateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(3) .timeoutSeconds(30) @@ -74,7 +83,15 @@ internal class WebhookServiceTest { .sandbox(false) .displayName("Updated Order Notifications") .endpointUrl("https://example.com/webhooks/orders-v2") - .addEventType("messages") + .eventFilters( + WebhookUpdateParams.EventFilters.builder() + .putAdditionalProperty( + "message", + JsonValue.from(listOf("delivered", "failed")), + ) + .build() + ) + .addEventType("message") .addEventType("templates") .retryCount(5) .timeoutSeconds(60) diff --git a/sent-java-proguard-test/src/test/kotlin/dm/sent/proguard/ProGuardCompatibilityTest.kt b/sent-java-proguard-test/src/test/kotlin/dm/sent/proguard/ProGuardCompatibilityTest.kt index fd196e5d..9e36340f 100644 --- a/sent-java-proguard-test/src/test/kotlin/dm/sent/proguard/ProGuardCompatibilityTest.kt +++ b/sent-java-proguard-test/src/test/kotlin/dm/sent/proguard/ProGuardCompatibilityTest.kt @@ -73,6 +73,7 @@ internal class ProGuardCompatibilityTest { MessageRetrieveActivitiesResponse.Data.Activity.builder() .activeContactPrice("active_contact_price") .description("description") + .from("from") .price("price") .status("status") .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))