Class: Courier::Send::ElementalGroupNode
- Inherits:
-
Object
- Object
- Courier::Send::ElementalGroupNode
- Defined in:
- lib/trycourier/send/types/elemental_group_node.rb
Overview
Allows you to group elements together. This can be useful when used in combination with “if” or “loop”. See [control flow docs](www.courier.com/docs/platform/content/elemental/control-flow/) for more details.
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#if_ ⇒ Object
readonly
Returns the value of attribute if_.
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::ElementalGroupNode
Deserialize a JSON object to an instance of ElementalGroupNode.
-
.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(elements:, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalGroupNode constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ElementalGroupNode to a JSON object.
Constructor Details
#initialize(elements:, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalGroupNode
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 19 def initialize(elements:, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) # @type [Array<Send::ElementalNode>] Sub elements to render. @elements = elements # @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.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 10 def additional_properties @additional_properties end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 10 def channels @channels end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 10 def elements @elements end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 10 def if_ @if_ end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 10 def loop @loop end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 10 def ref @ref end |
Class Method Details
.from_json(json_object:) ⇒ Send::ElementalGroupNode
Deserialize a JSON object to an instance of ElementalGroupNode
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 38 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) elements = parsed_json["elements"]&.map do |v| v = v.to_json Send::ElementalNode.from_json(json_object: v) end channels = struct.channels ref = struct.ref if_ = struct.if loop = struct.loop new(elements: elements, 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.
63 64 65 66 67 68 69 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 63 def self.validate_raw(obj:) obj.elements.is_a?(Array) != false || raise("Passed value for field obj.elements 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 ElementalGroupNode to a JSON object
55 56 57 |
# File 'lib/trycourier/send/types/elemental_group_node.rb', line 55 def to_json(*_args) { "elements": @elements, "channels": @channels, "ref": @ref, "if": @if_, "loop": @loop }.to_json end |