Class: Courier::Send::ElementalActionNode
- Inherits:
-
Object
- Object
- Courier::Send::ElementalActionNode
- Defined in:
- lib/trycourier/send/types/elemental_action_node.rb
Overview
Allows the user to execute an action. Can be a button or a link.
Instance Attribute Summary collapse
-
#action_id ⇒ Object
readonly
Returns the value of attribute action_id.
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#background_color ⇒ Object
readonly
Returns the value of attribute background_color.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#if_ ⇒ Object
readonly
Returns the value of attribute if_.
-
#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.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::ElementalActionNode
Deserialize a JSON object to an instance of ElementalActionNode.
-
.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:, href:, locales:, action_id: nil, align: nil, background_color: nil, style: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalActionNode constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ElementalActionNode to a JSON object.
Constructor Details
#initialize(content:, href:, locales:, action_id: nil, align: nil, background_color: nil, style: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalActionNode
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 28 def initialize(content:, href:, locales:, action_id: nil, align: nil, background_color: nil, style: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) # @type [String] The text content of the action shown to the user. @content = content # @type [String] The target URL of the action. @href = href # @type [String] A unique id used to identify the action when it is executed. @action_id = action_id # @type [Send::IAlignment] The alignment of the action button. Defaults to "center". @align = align # @type [String] The background color of the action button. @background_color = background_color # @type [Send::IActionButtonStyle] Defaults to `button`. @style = style # @type [Send::LOCALES] Region specific content. See [locales docs](https://www.courier.com/docs/platform/content/elemental/locales/) for more details. @locales = locales # @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
#action_id ⇒ Object (readonly)
Returns the value of attribute action_id.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def action_id @action_id end |
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_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_action_node.rb', line 12 def align @align end |
#background_color ⇒ Object (readonly)
Returns the value of attribute background_color.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def background_color @background_color end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def channels @channels end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def content @content end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def href @href end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def if_ @if_ end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_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_action_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_action_node.rb', line 12 def ref @ref end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
12 13 14 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 12 def style @style end |
Class Method Details
.from_json(json_object:) ⇒ Send::ElementalActionNode
Deserialize a JSON object to an instance of ElementalActionNode
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 60 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) content = struct.content href = struct.href action_id = struct.action_id align = struct.align background_color = struct.background_color style = struct.style locales = struct.locales channels = struct.channels ref = struct.ref if_ = struct.if loop = struct.loop new(content: content, href: href, action_id: action_id, align: align, background_color: background_color, style: style, locales: locales, 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.
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 101 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.href.is_a?(String) != false || raise("Passed value for field obj.href is not the expected type, validation failed.") obj.action_id&.is_a?(String) != false || raise("Passed value for field obj.action_id is not the expected type, validation failed.") obj.align&.is_a?(Send::IAlignment) != false || raise("Passed value for field obj.align is not the expected type, validation failed.") obj.background_color&.is_a?(String) != false || raise("Passed value for field obj.background_color is not the expected type, validation failed.") obj.style&.is_a?(Send::IActionButtonStyle) != false || raise("Passed value for field obj.style 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.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 ElementalActionNode to a JSON object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/trycourier/send/types/elemental_action_node.rb', line 81 def to_json(*_args) { "content": @content, "href": @href, "action_id": @action_id, "align": @align, "background_color": @background_color, "style": @style, "locales": @locales, "channels": @channels, "ref": @ref, "if": @if_, "loop": @loop }.to_json end |