From 6a400d1483ed43c6fac5976d40789339b55fcccf Mon Sep 17 00:00:00 2001 From: courier-codegen Date: Fri, 4 Sep 2026 16:49:38 +0000 Subject: [PATCH] Document EmailFooter as the API actually behaves --- .../com/courier/models/brands/EmailFooter.kt | 1180 ++++++++++++++++- .../models/brands/BrandCreateParamsTest.kt | 124 +- .../models/brands/BrandListResponseTest.kt | 93 +- .../models/brands/BrandSettingsEmailTest.kt | 52 +- .../models/brands/BrandSettingsTest.kt | 76 +- .../com/courier/models/brands/BrandTest.kt | 93 +- .../models/brands/BrandUpdateParamsTest.kt | 93 +- .../courier/models/brands/EmailFooterTest.kt | 42 +- .../services/async/BrandServiceAsyncTest.kt | 62 +- .../services/blocking/BrandServiceTest.kt | 62 +- 10 files changed, 1821 insertions(+), 56 deletions(-) diff --git a/courier-java-core/src/main/kotlin/com/courier/models/brands/EmailFooter.kt b/courier-java-core/src/main/kotlin/com/courier/models/brands/EmailFooter.kt index 69ea105f..1041ebac 100644 --- a/courier-java-core/src/main/kotlin/com/courier/models/brands/EmailFooter.kt +++ b/courier-java-core/src/main/kotlin/com/courier/models/brands/EmailFooter.kt @@ -19,37 +19,43 @@ import kotlin.jvm.optionals.getOrNull class EmailFooter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val content: JsonField, private val inheritDefault: JsonField, + private val markdown: JsonField, + private val social: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), @JsonProperty("inheritDefault") @ExcludeMissing inheritDefault: JsonField = JsonMissing.of(), - ) : this(content, inheritDefault, mutableMapOf()) + @JsonProperty("markdown") @ExcludeMissing markdown: JsonField = JsonMissing.of(), + @JsonProperty("social") @ExcludeMissing social: JsonField = JsonMissing.of(), + ) : this(inheritDefault, markdown, social, mutableMapOf()) /** * @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") + fun inheritDefault(): Optional = inheritDefault.getOptional("inheritDefault") /** + * The footer body, as markdown. This is the field the API returns and accepts; it is omitted + * entirely when no footer body is set. Sending null is accepted and treated as no footer body. + * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun inheritDefault(): Optional = inheritDefault.getOptional("inheritDefault") + fun markdown(): Optional = markdown.getOptional("markdown") /** - * Returns the raw JSON value of [content]. + * Social links rendered in the email footer. * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + fun social(): Optional = social.getOptional("social") /** * Returns the raw JSON value of [inheritDefault]. @@ -60,6 +66,20 @@ private constructor( @ExcludeMissing fun _inheritDefault(): JsonField = inheritDefault + /** + * Returns the raw JSON value of [markdown]. + * + * Unlike [markdown], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("markdown") @ExcludeMissing fun _markdown(): JsonField = markdown + + /** + * Returns the raw JSON value of [social]. + * + * Unlike [social], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("social") @ExcludeMissing fun _social(): JsonField = social + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -81,30 +101,19 @@ private constructor( /** A builder for [EmailFooter]. */ class Builder internal constructor() { - private var content: JsonField = JsonMissing.of() private var inheritDefault: JsonField = JsonMissing.of() + private var markdown: JsonField = JsonMissing.of() + private var social: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(emailFooter: EmailFooter) = apply { - content = emailFooter.content inheritDefault = emailFooter.inheritDefault + markdown = emailFooter.markdown + social = emailFooter.social additionalProperties = emailFooter.additionalProperties.toMutableMap() } - fun content(content: String?) = 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 [String] 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 } - fun inheritDefault(inheritDefault: Boolean?) = inheritDefault(JsonField.ofNullable(inheritDefault)) @@ -130,6 +139,38 @@ private constructor( this.inheritDefault = inheritDefault } + /** + * The footer body, as markdown. This is the field the API returns and accepts; it is + * omitted entirely when no footer body is set. Sending null is accepted and treated as no + * footer body. + */ + fun markdown(markdown: String?) = markdown(JsonField.ofNullable(markdown)) + + /** Alias for calling [Builder.markdown] with `markdown.orElse(null)`. */ + fun markdown(markdown: Optional) = markdown(markdown.getOrNull()) + + /** + * Sets [Builder.markdown] to an arbitrary JSON value. + * + * You should usually call [Builder.markdown] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun markdown(markdown: JsonField) = apply { this.markdown = markdown } + + /** Social links rendered in the email footer. */ + fun social(social: Social?) = social(JsonField.ofNullable(social)) + + /** Alias for calling [Builder.social] with `social.orElse(null)`. */ + fun social(social: Optional) = social(social.getOrNull()) + + /** + * Sets [Builder.social] to an arbitrary JSON value. + * + * You should usually call [Builder.social] with a well-typed [Social] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun social(social: JsonField) = apply { this.social = social } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -155,7 +196,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): EmailFooter = - EmailFooter(content, inheritDefault, additionalProperties.toMutableMap()) + EmailFooter(inheritDefault, markdown, social, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -173,8 +214,9 @@ private constructor( return@apply } - content() inheritDefault() + markdown() + social().ifPresent { it.validate() } validated = true } @@ -193,8 +235,1085 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (content.asKnown().isPresent) 1 else 0) + - (if (inheritDefault.asKnown().isPresent) 1 else 0) + (if (inheritDefault.asKnown().isPresent) 1 else 0) + + (if (markdown.asKnown().isPresent) 1 else 0) + + (social.asKnown().getOrNull()?.validity() ?: 0) + + /** Social links rendered in the email footer. */ + class Social + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val facebook: JsonField, + private val instagram: JsonField, + private val linkedin: JsonField, + private val medium: JsonField, + private val twitter: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("facebook") + @ExcludeMissing + facebook: JsonField = JsonMissing.of(), + @JsonProperty("instagram") + @ExcludeMissing + instagram: JsonField = JsonMissing.of(), + @JsonProperty("linkedin") + @ExcludeMissing + linkedin: JsonField = JsonMissing.of(), + @JsonProperty("medium") @ExcludeMissing medium: JsonField = JsonMissing.of(), + @JsonProperty("twitter") @ExcludeMissing twitter: JsonField = JsonMissing.of(), + ) : this(facebook, instagram, linkedin, medium, twitter, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun facebook(): Optional = facebook.getOptional("facebook") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun instagram(): Optional = instagram.getOptional("instagram") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun linkedin(): Optional = linkedin.getOptional("linkedin") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun medium(): Optional = medium.getOptional("medium") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun twitter(): Optional = twitter.getOptional("twitter") + + /** + * Returns the raw JSON value of [facebook]. + * + * Unlike [facebook], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("facebook") @ExcludeMissing fun _facebook(): JsonField = facebook + + /** + * Returns the raw JSON value of [instagram]. + * + * Unlike [instagram], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("instagram") + @ExcludeMissing + fun _instagram(): JsonField = instagram + + /** + * Returns the raw JSON value of [linkedin]. + * + * Unlike [linkedin], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("linkedin") @ExcludeMissing fun _linkedin(): JsonField = linkedin + + /** + * Returns the raw JSON value of [medium]. + * + * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium + + /** + * Returns the raw JSON value of [twitter]. + * + * Unlike [twitter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("twitter") @ExcludeMissing fun _twitter(): JsonField = twitter + + @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 [Social]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Social]. */ + class Builder internal constructor() { + + private var facebook: JsonField = JsonMissing.of() + private var instagram: JsonField = JsonMissing.of() + private var linkedin: JsonField = JsonMissing.of() + private var medium: JsonField = JsonMissing.of() + private var twitter: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(social: Social) = apply { + facebook = social.facebook + instagram = social.instagram + linkedin = social.linkedin + medium = social.medium + twitter = social.twitter + additionalProperties = social.additionalProperties.toMutableMap() + } + + fun facebook(facebook: Facebook?) = facebook(JsonField.ofNullable(facebook)) + + /** Alias for calling [Builder.facebook] with `facebook.orElse(null)`. */ + fun facebook(facebook: Optional) = facebook(facebook.getOrNull()) + + /** + * Sets [Builder.facebook] to an arbitrary JSON value. + * + * You should usually call [Builder.facebook] with a well-typed [Facebook] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun facebook(facebook: JsonField) = apply { this.facebook = facebook } + + fun instagram(instagram: Instagram?) = instagram(JsonField.ofNullable(instagram)) + + /** Alias for calling [Builder.instagram] with `instagram.orElse(null)`. */ + fun instagram(instagram: Optional) = instagram(instagram.getOrNull()) + + /** + * Sets [Builder.instagram] to an arbitrary JSON value. + * + * You should usually call [Builder.instagram] with a well-typed [Instagram] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instagram(instagram: JsonField) = apply { this.instagram = instagram } + + fun linkedin(linkedin: Linkedin?) = linkedin(JsonField.ofNullable(linkedin)) + + /** Alias for calling [Builder.linkedin] with `linkedin.orElse(null)`. */ + fun linkedin(linkedin: Optional) = linkedin(linkedin.getOrNull()) + + /** + * Sets [Builder.linkedin] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedin] with a well-typed [Linkedin] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun linkedin(linkedin: JsonField) = apply { this.linkedin = linkedin } + + fun medium(medium: Medium?) = medium(JsonField.ofNullable(medium)) + + /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ + fun medium(medium: Optional) = medium(medium.getOrNull()) + + /** + * Sets [Builder.medium] to an arbitrary JSON value. + * + * You should usually call [Builder.medium] with a well-typed [Medium] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun medium(medium: JsonField) = apply { this.medium = medium } + + fun twitter(twitter: Twitter?) = twitter(JsonField.ofNullable(twitter)) + + /** Alias for calling [Builder.twitter] with `twitter.orElse(null)`. */ + fun twitter(twitter: Optional) = twitter(twitter.getOrNull()) + + /** + * Sets [Builder.twitter] to an arbitrary JSON value. + * + * You should usually call [Builder.twitter] with a well-typed [Twitter] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun twitter(twitter: JsonField) = apply { this.twitter = twitter } + + 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 [Social]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Social = + Social( + facebook, + instagram, + linkedin, + medium, + twitter, + 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(): Social = apply { + if (validated) { + return@apply + } + + facebook().ifPresent { it.validate() } + instagram().ifPresent { it.validate() } + linkedin().ifPresent { it.validate() } + medium().ifPresent { it.validate() } + twitter().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 = + (facebook.asKnown().getOrNull()?.validity() ?: 0) + + (instagram.asKnown().getOrNull()?.validity() ?: 0) + + (linkedin.asKnown().getOrNull()?.validity() ?: 0) + + (medium.asKnown().getOrNull()?.validity() ?: 0) + + (twitter.asKnown().getOrNull()?.validity() ?: 0) + + class Facebook + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Facebook]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Facebook]. */ + class Builder internal constructor() { + + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(facebook: Facebook) = apply { + url = facebook.url + additionalProperties = facebook.additionalProperties.toMutableMap() + } + + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Facebook]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Facebook = Facebook(url, 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(): Facebook = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Facebook && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Facebook{url=$url, additionalProperties=$additionalProperties}" + } + + class Instagram + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Instagram]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Instagram]. */ + class Builder internal constructor() { + + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(instagram: Instagram) = apply { + url = instagram.url + additionalProperties = instagram.additionalProperties.toMutableMap() + } + + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Instagram]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Instagram = Instagram(url, 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(): Instagram = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Instagram && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Instagram{url=$url, additionalProperties=$additionalProperties}" + } + + class Linkedin + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Linkedin]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Linkedin]. */ + class Builder internal constructor() { + + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(linkedin: Linkedin) = apply { + url = linkedin.url + additionalProperties = linkedin.additionalProperties.toMutableMap() + } + + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Linkedin]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Linkedin = Linkedin(url, 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(): Linkedin = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Linkedin && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Linkedin{url=$url, additionalProperties=$additionalProperties}" + } + + class Medium + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Medium]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Medium]. */ + class Builder internal constructor() { + + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(medium: Medium) = apply { + url = medium.url + additionalProperties = medium.additionalProperties.toMutableMap() + } + + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Medium]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Medium = Medium(url, 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(): Medium = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Medium && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Medium{url=$url, additionalProperties=$additionalProperties}" + } + + class Twitter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Twitter]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Twitter]. */ + class Builder internal constructor() { + + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(twitter: Twitter) = apply { + url = twitter.url + additionalProperties = twitter.additionalProperties.toMutableMap() + } + + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Twitter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Twitter = Twitter(url, 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(): Twitter = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Twitter && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Twitter{url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Social && + facebook == other.facebook && + instagram == other.instagram && + linkedin == other.linkedin && + medium == other.medium && + twitter == other.twitter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(facebook, instagram, linkedin, medium, twitter, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Social{facebook=$facebook, instagram=$instagram, linkedin=$linkedin, medium=$medium, twitter=$twitter, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -202,17 +1321,18 @@ private constructor( } return other is EmailFooter && - content == other.content && inheritDefault == other.inheritDefault && + markdown == other.markdown && + social == other.social && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(content, inheritDefault, additionalProperties) + Objects.hash(inheritDefault, markdown, social, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EmailFooter{content=$content, inheritDefault=$inheritDefault, additionalProperties=$additionalProperties}" + "EmailFooter{inheritDefault=$inheritDefault, markdown=$markdown, social=$social, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandCreateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandCreateParamsTest.kt index 5e303868..8c9d837b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandCreateParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandCreateParamsTest.kt @@ -21,8 +21,37 @@ internal class BrandCreateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -109,8 +138,37 @@ internal class BrandCreateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -223,8 +281,37 @@ internal class BrandCreateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -308,8 +395,37 @@ internal class BrandCreateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandListResponseTest.kt index e6020240..f90ac891 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandListResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandListResponseTest.kt @@ -34,8 +34,37 @@ internal class BrandListResponseTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -141,8 +170,37 @@ internal class BrandListResponseTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -244,8 +302,37 @@ internal class BrandListResponseTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsEmailTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsEmailTest.kt index 52573a3e..f140e32f 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsEmailTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsEmailTest.kt @@ -13,7 +13,23 @@ internal class BrandSettingsEmailTest { fun create() { val brandSettingsEmail = BrandSettingsEmail.builder() - .footer(EmailFooter.builder().content("content").inheritDefault(true).build()) + .footer( + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook(EmailFooter.Social.Facebook.builder().url("url").build()) + .instagram( + EmailFooter.Social.Instagram.builder().url("url").build() + ) + .linkedin(EmailFooter.Social.Linkedin.builder().url("url").build()) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter(EmailFooter.Social.Twitter.builder().url("url").build()) + .build() + ) + .build() + ) .head(EmailHead.builder().inheritDefault(true).content("content").build()) .header( EmailHeader.builder() @@ -49,7 +65,21 @@ internal class BrandSettingsEmailTest { .build() assertThat(brandSettingsEmail.footer()) - .contains(EmailFooter.builder().content("content").inheritDefault(true).build()) + .contains( + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook(EmailFooter.Social.Facebook.builder().url("url").build()) + .instagram(EmailFooter.Social.Instagram.builder().url("url").build()) + .linkedin(EmailFooter.Social.Linkedin.builder().url("url").build()) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter(EmailFooter.Social.Twitter.builder().url("url").build()) + .build() + ) + .build() + ) assertThat(brandSettingsEmail.head()) .contains(EmailHead.builder().inheritDefault(true).content("content").build()) assertThat(brandSettingsEmail.header()) @@ -92,7 +122,23 @@ internal class BrandSettingsEmailTest { val jsonMapper = jsonMapper() val brandSettingsEmail = BrandSettingsEmail.builder() - .footer(EmailFooter.builder().content("content").inheritDefault(true).build()) + .footer( + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook(EmailFooter.Social.Facebook.builder().url("url").build()) + .instagram( + EmailFooter.Social.Instagram.builder().url("url").build() + ) + .linkedin(EmailFooter.Social.Linkedin.builder().url("url").build()) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter(EmailFooter.Social.Twitter.builder().url("url").build()) + .build() + ) + .build() + ) .head(EmailHead.builder().inheritDefault(true).content("content").build()) .header( EmailHeader.builder() diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsTest.kt index 16f9ac3d..7bc1ea62 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandSettingsTest.kt @@ -17,7 +17,31 @@ internal class BrandSettingsTest { .email( BrandSettingsEmail.builder() .footer( - EmailFooter.builder().content("content").inheritDefault(true).build() + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder().url("url").build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder().url("url").build() + ) + .medium( + EmailFooter.Social.Medium.builder().url("url").build() + ) + .twitter( + EmailFooter.Social.Twitter.builder().url("url").build() + ) + .build() + ) + .build() ) .head(EmailHead.builder().inheritDefault(true).content("content").build()) .header( @@ -78,7 +102,29 @@ internal class BrandSettingsTest { assertThat(brandSettings.email()) .contains( BrandSettingsEmail.builder() - .footer(EmailFooter.builder().content("content").inheritDefault(true).build()) + .footer( + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder().url("url").build() + ) + .instagram( + EmailFooter.Social.Instagram.builder().url("url").build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder().url("url").build() + ) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter( + EmailFooter.Social.Twitter.builder().url("url").build() + ) + .build() + ) + .build() + ) .head(EmailHead.builder().inheritDefault(true).content("content").build()) .header( EmailHeader.builder() @@ -141,7 +187,31 @@ internal class BrandSettingsTest { .email( BrandSettingsEmail.builder() .footer( - EmailFooter.builder().content("content").inheritDefault(true).build() + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder().url("url").build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder().url("url").build() + ) + .medium( + EmailFooter.Social.Medium.builder().url("url").build() + ) + .twitter( + EmailFooter.Social.Twitter.builder().url("url").build() + ) + .build() + ) + .build() ) .head(EmailHead.builder().inheritDefault(true).content("content").build()) .header( diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandTest.kt index ab71363a..bfd0a13e 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandTest.kt @@ -27,8 +27,37 @@ internal class BrandTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -114,8 +143,37 @@ internal class BrandTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -205,8 +263,37 @@ internal class BrandTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandUpdateParamsTest.kt index c144cb9f..8570b3fd 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandUpdateParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/BrandUpdateParamsTest.kt @@ -19,8 +19,37 @@ internal class BrandUpdateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -114,8 +143,37 @@ internal class BrandUpdateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -198,8 +256,37 @@ internal class BrandUpdateParamsTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( diff --git a/courier-java-core/src/test/kotlin/com/courier/models/brands/EmailFooterTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/brands/EmailFooterTest.kt index 85697f25..ba51d5d1 100644 --- a/courier-java-core/src/test/kotlin/com/courier/models/brands/EmailFooterTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/models/brands/EmailFooterTest.kt @@ -11,16 +11,52 @@ internal class EmailFooterTest { @Test fun create() { - val emailFooter = EmailFooter.builder().content("content").inheritDefault(true).build() + val emailFooter = + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook(EmailFooter.Social.Facebook.builder().url("url").build()) + .instagram(EmailFooter.Social.Instagram.builder().url("url").build()) + .linkedin(EmailFooter.Social.Linkedin.builder().url("url").build()) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter(EmailFooter.Social.Twitter.builder().url("url").build()) + .build() + ) + .build() - assertThat(emailFooter.content()).contains("content") assertThat(emailFooter.inheritDefault()).contains(true) + assertThat(emailFooter.markdown()).contains("markdown") + assertThat(emailFooter.social()) + .contains( + EmailFooter.Social.builder() + .facebook(EmailFooter.Social.Facebook.builder().url("url").build()) + .instagram(EmailFooter.Social.Instagram.builder().url("url").build()) + .linkedin(EmailFooter.Social.Linkedin.builder().url("url").build()) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter(EmailFooter.Social.Twitter.builder().url("url").build()) + .build() + ) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val emailFooter = EmailFooter.builder().content("content").inheritDefault(true).build() + val emailFooter = + EmailFooter.builder() + .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook(EmailFooter.Social.Facebook.builder().url("url").build()) + .instagram(EmailFooter.Social.Instagram.builder().url("url").build()) + .linkedin(EmailFooter.Social.Linkedin.builder().url("url").build()) + .medium(EmailFooter.Social.Medium.builder().url("url").build()) + .twitter(EmailFooter.Social.Twitter.builder().url("url").build()) + .build() + ) + .build() val roundtrippedEmailFooter = jsonMapper.readValue( diff --git a/courier-java-core/src/test/kotlin/com/courier/services/async/BrandServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/services/async/BrandServiceAsyncTest.kt index 08712bb3..5e2fce56 100644 --- a/courier-java-core/src/test/kotlin/com/courier/services/async/BrandServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/services/async/BrandServiceAsyncTest.kt @@ -48,8 +48,37 @@ internal class BrandServiceAsyncTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -164,8 +193,37 @@ internal class BrandServiceAsyncTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( diff --git a/courier-java-core/src/test/kotlin/com/courier/services/blocking/BrandServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/services/blocking/BrandServiceTest.kt index cc8c0e94..fc75aff6 100644 --- a/courier-java-core/src/test/kotlin/com/courier/services/blocking/BrandServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/services/blocking/BrandServiceTest.kt @@ -48,8 +48,37 @@ internal class BrandServiceTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head( @@ -162,8 +191,37 @@ internal class BrandServiceTest { BrandSettingsEmail.builder() .footer( EmailFooter.builder() - .content("content") .inheritDefault(true) + .markdown("markdown") + .social( + EmailFooter.Social.builder() + .facebook( + EmailFooter.Social.Facebook.builder() + .url("url") + .build() + ) + .instagram( + EmailFooter.Social.Instagram.builder() + .url("url") + .build() + ) + .linkedin( + EmailFooter.Social.Linkedin.builder() + .url("url") + .build() + ) + .medium( + EmailFooter.Social.Medium.builder() + .url("url") + .build() + ) + .twitter( + EmailFooter.Social.Twitter.builder() + .url("url") + .build() + ) + .build() + ) .build() ) .head(