Class: Courier::Send::ElementalTextNode
- Inherits:
-
Object
- Object
- Courier::Send::ElementalTextNode
- Defined in:
- lib/trycourier/send/types/elemental_text_node.rb
Overview
Represents a body of text to be rendered inside of the notification.
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#bold ⇒ Object
readonly
Returns the value of attribute bold.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#if_ ⇒ Object
readonly
Returns the value of attribute if_.
-
#italic ⇒ Object
readonly
Returns the value of attribute italic.
-
#locales ⇒ Object
readonly
Returns the value of attribute locales.
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#strikethrough ⇒ Object
readonly
Returns the value of attribute strikethrough.
-
#text_style ⇒ Object
readonly
Returns the value of attribute text_style.
-
#underline ⇒ Object
readonly
Returns the value of attribute underline.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::ElementalTextNode
Deserialize a JSON object to an instance of ElementalTextNode.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(content:, align:, text_style: nil, color: nil, bold: nil, italic: nil, strikethrough: nil, underline: nil, locales: nil, format: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalTextNode constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ElementalTextNode to a JSON object.
Constructor Details
#initialize(content:, align:, text_style: nil, color: nil, bold: nil, italic: nil, strikethrough: nil, underline: nil, locales: nil, format: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalTextNode
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 32 def initialize(content:, align:, text_style: nil, color: nil, bold: nil, italic: nil, strikethrough: nil, underline: nil, locales: nil, format: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) # @type [String] The text content displayed in the notification. Either this # field must be specified, or the elements field @content = content # @type [Send::TextAlign] Text alignment. @align = align # @type [Send::TextStyle] Allows the text to be rendered as a heading level. @text_style = text_style # @type [String] Specifies the color of text. Can be any valid css color value @color = color # @type [String] Apply bold to the text @bold = bold # @type [String] Apply italics to the text @italic = italic # @type [String] Apply a strike through the text @strikethrough = strikethrough # @type [String] Apply an underline to the text @underline = underline # @type [Send::LOCALES] Region specific content. See [locales docs](https://www.courier.com/docs/platform/content/elemental/locales/) for more details. @locales = locales # @type [String] @format = format # @type [Array<String>] @channels = channels # @type [String] @ref = ref # @type [String] @if_ = if_ # @type [String] @loop = loop # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def additional_properties @additional_properties end |
#align ⇒ Object (readonly)
Returns the value of attribute align.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def align @align end |
#bold ⇒ Object (readonly)
Returns the value of attribute bold.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def bold @bold end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def channels @channels end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def color @color end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def content @content end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def format @format end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def if_ @if_ end |
#italic ⇒ Object (readonly)
Returns the value of attribute italic.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def italic @italic end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def locales @locales end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def loop @loop end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def ref @ref end |
#strikethrough ⇒ Object (readonly)
Returns the value of attribute strikethrough.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def strikethrough @strikethrough end |
#text_style ⇒ Object (readonly)
Returns the value of attribute text_style.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def text_style @text_style end |
#underline ⇒ Object (readonly)
Returns the value of attribute underline.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 12 def underline @underline end |
Class Method Details
.from_json(json_object:) ⇒ Send::ElementalTextNode
Deserialize a JSON object to an instance of ElementalTextNode
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 71 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) content = struct.content align = struct.align text_style = struct.text_style color = struct.color bold = struct.bold italic = struct.italic strikethrough = struct.strikethrough underline = struct.underline locales = struct.locales format = struct.format channels = struct.channels ref = struct.ref if_ = struct.if loop = struct.loop new(content: content, align: align, text_style: text_style, color: color, bold: bold, italic: italic, strikethrough: strikethrough, underline: underline, locales: locales, format: format, channels: channels, ref: ref, if_: if_, loop: loop, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 118 def self.validate_raw(obj:) obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.align.is_a?(Send::TextAlign) != false || raise("Passed value for field obj.align is not the expected type, validation failed.") obj.text_style&.is_a?(Send::TextStyle) != false || raise("Passed value for field obj.text_style is not the expected type, validation failed.") obj.color&.is_a?(String) != false || raise("Passed value for field obj.color is not the expected type, validation failed.") obj.bold&.is_a?(String) != false || raise("Passed value for field obj.bold is not the expected type, validation failed.") obj.italic&.is_a?(String) != false || raise("Passed value for field obj.italic is not the expected type, validation failed.") obj.strikethrough&.is_a?(String) != false || raise("Passed value for field obj.strikethrough is not the expected type, validation failed.") obj.underline&.is_a?(String) != false || raise("Passed value for field obj.underline is not the expected type, validation failed.") obj.locales&.is_a?(Hash) != false || raise("Passed value for field obj.locales is not the expected type, validation failed.") obj.format&.is_a?(String) != false || raise("Passed value for field obj.format is not the expected type, validation failed.") obj.channels&.is_a?(Array) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.ref&.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") obj.loop&.is_a?(String) != false || raise("Passed value for field obj.loop is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of ElementalTextNode to a JSON object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/trycourier/send/types/elemental_text_node.rb', line 95 def to_json(*_args) { "content": @content, "align": @align, "text_style": @text_style, "color": @color, "bold": @bold, "italic": @italic, "strikethrough": @strikethrough, "underline": @underline, "locales": @locales, "format": @format, "channels": @channels, "ref": @ref, "if": @if_, "loop": @loop }.to_json end |