Class: Courier::Automations::AutomationV2SendStep

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/automations/types/automation_v_2_send_step.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, message:, if_: nil, ref: nil, additional_properties: nil) ⇒ Automations::AutomationV2SendStep

Parameters:

  • action (String)
  • message (Send::Message)
  • if_ (String) (defaults to: nil)
  • ref (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 17

def initialize(action:, message:, if_: nil, ref: nil, additional_properties: nil)
  # @type [String]
  @action = action
  # @type [Send::Message]
  @message = message
  # @type [String]
  @if_ = if_
  # @type [String]
  @ref = ref
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



9
10
11
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 9

def action
  @action
end

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



9
10
11
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 9

def additional_properties
  @additional_properties
end

#if_Object (readonly)

Returns the value of attribute if_.



9
10
11
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 9

def if_
  @if_
end

#messageObject (readonly)

Returns the value of attribute message.



9
10
11
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 9

def message
  @message
end

#refObject (readonly)

Returns the value of attribute ref.



9
10
11
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 9

def ref
  @ref
end

Class Method Details

.from_json(json_object:) ⇒ Automations::AutomationV2SendStep

Deserialize a JSON object to an instance of AutomationV2SendStep

Parameters:

  • json_object (JSON)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 34

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  action = struct.action
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Send::Message.from_json(json_object: message)
  end
  if_ = struct.if
  ref = struct.ref
  new(action: action, message: message, if_: if_, ref: ref, 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)


60
61
62
63
64
65
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 60

def self.validate_raw(obj:)
  obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.")
  Send::Message.validate_raw(obj: obj.message)
  obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ 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.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of AutomationV2SendStep to a JSON object

Returns:

  • (JSON)


52
53
54
# File 'lib/trycourier/automations/types/automation_v_2_send_step.rb', line 52

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