Class: Courier::Send::ElementalMetaNode
- Inherits:
-
Object
- Object
- Courier::Send::ElementalMetaNode
- Defined in:
- lib/trycourier/send/types/elemental_meta_node.rb
Overview
The meta element contains information describing the notification that may be used by a particular channel or provider. One important field is the title field which will be used as the title for channels that support it.
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#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.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::ElementalMetaNode
Deserialize a JSON object to an instance of ElementalMetaNode.
-
.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(title: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalMetaNode constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ElementalMetaNode to a JSON object.
Constructor Details
#initialize(title: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalMetaNode
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 20 def initialize(title: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) # @type [String] The title to be displayed by supported channels. For example, the email subject. @title = title # @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.
11 12 13 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 11 def additional_properties @additional_properties end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
11 12 13 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 11 def channels @channels end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
11 12 13 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 11 def if_ @if_ end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
11 12 13 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 11 def loop @loop end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
11 12 13 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 11 def ref @ref end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 11 def title @title end |
Class Method Details
.from_json(json_object:) ⇒ Send::ElementalMetaNode
Deserialize a JSON object to an instance of ElementalMetaNode
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 39 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) title = struct.title channels = struct.channels ref = struct.ref if_ = struct.if loop = struct.loop new(title: title, 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.
61 62 63 64 65 66 67 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 61 def self.validate_raw(obj:) obj.title&.is_a?(String) != false || raise("Passed value for field obj.title 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 ElementalMetaNode to a JSON object
53 54 55 |
# File 'lib/trycourier/send/types/elemental_meta_node.rb', line 53 def to_json(*_args) { "title": @title, "channels": @channels, "ref": @ref, "if": @if_, "loop": @loop }.to_json end |