Class: Courier::Send::ElementalBaseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/send/types/elemental_base_node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil) ⇒ Send::ElementalBaseNode

Parameters:

  • channels (Array<String>) (defaults to: nil)
  • ref (String) (defaults to: nil)
  • if_ (String) (defaults to: nil)
  • loop (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 16

def initialize(channels: nil, ref: nil, if_: nil, loop: nil, additional_properties: nil)
  # @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_propertiesObject (readonly)

Returns the value of attribute additional_properties.



8
9
10
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 8

def additional_properties
  @additional_properties
end

#channelsObject (readonly)

Returns the value of attribute channels.



8
9
10
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 8

def channels
  @channels
end

#if_Object (readonly)

Returns the value of attribute if_.



8
9
10
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 8

def if_
  @if_
end

#loopObject (readonly)

Returns the value of attribute loop.



8
9
10
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 8

def loop
  @loop
end

#refObject (readonly)

Returns the value of attribute ref.



8
9
10
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 8

def ref
  @ref
end

Class Method Details

.from_json(json_object:) ⇒ Send::ElementalBaseNode

Deserialize a JSON object to an instance of ElementalBaseNode

Parameters:

  • json_object (JSON)

Returns:



33
34
35
36
37
38
39
40
41
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 33

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  channels = struct.channels
  ref = struct.ref
  if_ = struct.if
  loop = struct.loop
  new(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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


54
55
56
57
58
59
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 54

def self.validate_raw(obj:)
  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 ElementalBaseNode to a JSON object

Returns:

  • (JSON)


46
47
48
# File 'lib/trycourier/send/types/elemental_base_node.rb', line 46

def to_json(*_args)
  { "channels": @channels, "ref": @ref, "if": @if_, "loop": @loop }.to_json
end