Class: Courier::Send::ElementalImageNode
- Inherits:
-
Object
- Object
- Courier::Send::ElementalImageNode
- Defined in:
- lib/trycourier/send/types/elemental_image_node.rb
Overview
Used to embed an image into 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.
-
#alt_text ⇒ Object
readonly
Returns the value of attribute alt_text.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#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.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::ElementalImageNode
Deserialize a JSON object to an instance of ElementalImageNode.
-
.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(src:, href: nil, align: nil, alt_text: nil, width: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalImageNode constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ElementalImageNode to a JSON object.
Constructor Details
#initialize(src:, href: nil, align: nil, alt_text: nil, width: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalImageNode
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 23 def initialize(src:, href: nil, align: nil, alt_text: nil, width: nil, channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) # @type [String] The source of the image. @src = src # @type [String] A URL to link to when the image is clicked. @href = href # @type [Send::IAlignment] The alignment of the image. @align = align # @type [String] Alternate text for the image. @alt_text = alt_text # @type [String] CSS width properties to apply to the image. For example, 50px @width = width # @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_image_node.rb', line 10 def additional_properties @additional_properties end |
#align ⇒ Object (readonly)
Returns the value of attribute align.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 10 def align @align end |
#alt_text ⇒ Object (readonly)
Returns the value of attribute alt_text.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 10 def alt_text @alt_text end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 10 def channels @channels end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 10 def href @href end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_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_image_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_image_node.rb', line 10 def ref @ref end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 10 def src @src end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
10 11 12 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 10 def width @width end |
Class Method Details
.from_json(json_object:) ⇒ Send::ElementalImageNode
Deserialize a JSON object to an instance of ElementalImageNode
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 51 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) src = struct.src href = struct.href align = struct.align alt_text = struct.altText width = struct.width channels = struct.channels ref = struct.ref if_ = struct.if loop = struct.loop new(src: src, href: href, align: align, alt_text: alt_text, width: width, 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.
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 88 def self.validate_raw(obj:) obj.src.is_a?(String) != false || raise("Passed value for field obj.src 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.align&.is_a?(Send::IAlignment) != false || raise("Passed value for field obj.align is not the expected type, validation failed.") obj.alt_text&.is_a?(String) != false || raise("Passed value for field obj.alt_text is not the expected type, validation failed.") obj.width&.is_a?(String) != false || raise("Passed value for field obj.width 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 ElementalImageNode to a JSON object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/trycourier/send/types/elemental_image_node.rb', line 70 def to_json(*_args) { "src": @src, "href": @href, "align": @align, "altText": @alt_text, "width": @width, "channels": @channels, "ref": @ref, "if": @if_, "loop": @loop }.to_json end |