Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.courier.core.JsonField
import com.courier.core.JsonMissing
import com.courier.core.JsonValue
import com.courier.core.checkKnown
import com.courier.core.checkRequired
import com.courier.core.toImmutable
import com.courier.errors.CourierInvalidDataException
import com.fasterxml.jackson.annotation.JsonAnyGetter
Expand All @@ -28,10 +27,10 @@ private constructor(
private val if_: JsonField<String>,
private val loop: JsonField<String>,
private val ref: JsonField<String>,
private val content: JsonField<String>,
private val align: JsonField<Align>,
private val bold: JsonField<String>,
private val color: JsonField<String>,
private val content: JsonField<String>,
private val fontSize: JsonField<String>,
private val format: JsonField<Format>,
private val italic: JsonField<String>,
Expand All @@ -51,10 +50,10 @@ private constructor(
@JsonProperty("if") @ExcludeMissing if_: JsonField<String> = JsonMissing.of(),
@JsonProperty("loop") @ExcludeMissing loop: JsonField<String> = JsonMissing.of(),
@JsonProperty("ref") @ExcludeMissing ref: JsonField<String> = JsonMissing.of(),
@JsonProperty("content") @ExcludeMissing content: JsonField<String> = JsonMissing.of(),
@JsonProperty("align") @ExcludeMissing align: JsonField<Align> = JsonMissing.of(),
@JsonProperty("bold") @ExcludeMissing bold: JsonField<String> = JsonMissing.of(),
@JsonProperty("color") @ExcludeMissing color: JsonField<String> = JsonMissing.of(),
@JsonProperty("content") @ExcludeMissing content: JsonField<String> = JsonMissing.of(),
@JsonProperty("font_size") @ExcludeMissing fontSize: JsonField<String> = JsonMissing.of(),
@JsonProperty("format") @ExcludeMissing format: JsonField<Format> = JsonMissing.of(),
@JsonProperty("italic") @ExcludeMissing italic: JsonField<String> = JsonMissing.of(),
Expand All @@ -74,10 +73,10 @@ private constructor(
if_,
loop,
ref,
content,
align,
bold,
color,
content,
fontSize,
format,
italic,
Expand Down Expand Up @@ -116,15 +115,6 @@ private constructor(
*/
fun ref(): Optional<String> = ref.getOptional("ref")

/**
* The text content displayed in the notification. Either this field must be specified, or the
* elements field
*
* @throws CourierInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
fun content(): String = content.getRequired("content")

/**
* Text alignment.
*
Expand All @@ -149,6 +139,15 @@ private constructor(
*/
fun color(): Optional<String> = color.getOptional("color")

/**
* The text content displayed in the notification. Either this field must be specified, or the
* elements field
*
* @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun content(): Optional<String> = content.getOptional("content")

/**
* CSS px font size for this text block, e.g. `16px`. Overrides the size of the `text_style`
* preset. Email only.
Expand Down Expand Up @@ -243,13 +242,6 @@ private constructor(
*/
@JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField<String> = ref

/**
* Returns the raw JSON value of [content].
*
* Unlike [content], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("content") @ExcludeMissing fun _content(): JsonField<String> = content

/**
* Returns the raw JSON value of [align].
*
Expand All @@ -271,6 +263,13 @@ private constructor(
*/
@JsonProperty("color") @ExcludeMissing fun _color(): JsonField<String> = color

/**
* Returns the raw JSON value of [content].
*
* Unlike [content], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("content") @ExcludeMissing fun _content(): JsonField<String> = content

/**
* Returns the raw JSON value of [fontSize].
*
Expand Down Expand Up @@ -343,14 +342,7 @@ private constructor(

companion object {

/**
* Returns a mutable builder for constructing an instance of [ElementalTextNode].
*
* The following fields are required:
* ```java
* .content()
* ```
*/
/** Returns a mutable builder for constructing an instance of [ElementalTextNode]. */
@JvmStatic fun builder() = Builder()
}

Expand All @@ -361,10 +353,10 @@ private constructor(
private var if_: JsonField<String> = JsonMissing.of()
private var loop: JsonField<String> = JsonMissing.of()
private var ref: JsonField<String> = JsonMissing.of()
private var content: JsonField<String>? = null
private var align: JsonField<Align> = JsonMissing.of()
private var bold: JsonField<String> = JsonMissing.of()
private var color: JsonField<String> = JsonMissing.of()
private var content: JsonField<String> = JsonMissing.of()
private var fontSize: JsonField<String> = JsonMissing.of()
private var format: JsonField<Format> = JsonMissing.of()
private var italic: JsonField<String> = JsonMissing.of()
Expand All @@ -381,10 +373,10 @@ private constructor(
if_ = elementalTextNode.if_
loop = elementalTextNode.loop
ref = elementalTextNode.ref
content = elementalTextNode.content
align = elementalTextNode.align
bold = elementalTextNode.bold
color = elementalTextNode.color
content = elementalTextNode.content
fontSize = elementalTextNode.fontSize
format = elementalTextNode.format
italic = elementalTextNode.italic
Expand Down Expand Up @@ -463,20 +455,6 @@ private constructor(
*/
fun ref(ref: JsonField<String>) = apply { this.ref = ref }

/**
* The text content displayed in the notification. Either this field must be specified, or
* the elements field
*/
fun content(content: String) = content(JsonField.of(content))

/**
* 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<String>) = apply { this.content = content }

/** Text alignment. */
fun align(align: Align) = align(JsonField.of(align))

Expand Down Expand Up @@ -516,6 +494,20 @@ private constructor(
*/
fun color(color: JsonField<String>) = apply { this.color = color }

/**
* The text content displayed in the notification. Either this field must be specified, or
* the elements field
*/
fun content(content: String) = content(JsonField.of(content))

/**
* 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<String>) = apply { this.content = content }

/**
* CSS px font size for this text block, e.g. `16px`. Overrides the size of the `text_style`
* preset. Email only.
Expand Down Expand Up @@ -668,24 +660,17 @@ private constructor(
* Returns an immutable instance of [ElementalTextNode].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .content()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): ElementalTextNode =
ElementalTextNode(
(channels ?: JsonMissing.of()).map { it.toImmutable() },
if_,
loop,
ref,
checkRequired("content", content),
align,
bold,
color,
content,
fontSize,
format,
italic,
Expand Down Expand Up @@ -717,10 +702,10 @@ private constructor(
if_()
loop()
ref()
content()
align().ifPresent { it.validate() }
bold()
color()
content()
fontSize()
format().ifPresent { it.validate() }
italic()
Expand Down Expand Up @@ -751,10 +736,10 @@ private constructor(
(if (if_.asKnown().isPresent) 1 else 0) +
(if (loop.asKnown().isPresent) 1 else 0) +
(if (ref.asKnown().isPresent) 1 else 0) +
(if (content.asKnown().isPresent) 1 else 0) +
(align.asKnown().getOrNull()?.validity() ?: 0) +
(if (bold.asKnown().isPresent) 1 else 0) +
(if (color.asKnown().isPresent) 1 else 0) +
(if (content.asKnown().isPresent) 1 else 0) +
(if (fontSize.asKnown().isPresent) 1 else 0) +
(format.asKnown().getOrNull()?.validity() ?: 0) +
(if (italic.asKnown().isPresent) 1 else 0) +
Expand Down Expand Up @@ -1043,10 +1028,10 @@ private constructor(
if_ == other.if_ &&
loop == other.loop &&
ref == other.ref &&
content == other.content &&
align == other.align &&
bold == other.bold &&
color == other.color &&
content == other.content &&
fontSize == other.fontSize &&
format == other.format &&
italic == other.italic &&
Expand All @@ -1064,10 +1049,10 @@ private constructor(
if_,
loop,
ref,
content,
align,
bold,
color,
content,
fontSize,
format,
italic,
Expand All @@ -1083,5 +1068,5 @@ private constructor(
override fun hashCode(): Int = hashCode

override fun toString() =
"ElementalTextNode{channels=$channels, if_=$if_, loop=$loop, ref=$ref, content=$content, align=$align, bold=$bold, color=$color, fontSize=$fontSize, format=$format, italic=$italic, lineHeight=$lineHeight, locales=$locales, strikethrough=$strikethrough, textStyle=$textStyle, underline=$underline, additionalProperties=$additionalProperties}"
"ElementalTextNode{channels=$channels, if_=$if_, loop=$loop, ref=$ref, align=$align, bold=$bold, color=$color, content=$content, fontSize=$fontSize, format=$format, italic=$italic, lineHeight=$lineHeight, locales=$locales, strikethrough=$strikethrough, textStyle=$textStyle, underline=$underline, additionalProperties=$additionalProperties}"
}
Loading
Loading