Class: Courier::Automations::AutomationSendStep

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, brand: nil, data: nil, override: nil, profile: nil, recipient: nil, template: nil, if_: nil, ref: nil, additional_properties: nil) ⇒ Automations::AutomationSendStep

Parameters:

  • action (String)
  • brand (String) (defaults to: nil)
  • data (Hash{String => String}) (defaults to: nil)
  • override (Hash{String => String}) (defaults to: nil)
  • profile (Object) (defaults to: nil)
  • recipient (String) (defaults to: nil)
  • template (String) (defaults to: nil)
  • if_ (String) (defaults to: nil)
  • ref (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 21

def initialize(action:, brand: nil, data: nil, override: nil, profile: nil, recipient: nil, template: nil,
               if_: nil, ref: nil, additional_properties: nil)
  # @type [String]
  @action = action
  # @type [String]
  @brand = brand
  # @type [Hash{String => String}]
  @data = data
  # @type [Hash{String => String}]
  @override = override
  # @type [Object]
  @profile = profile
  # @type [String]
  @recipient = recipient
  # @type [String]
  @template = template
  # @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.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def action
  @action
end

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def additional_properties
  @additional_properties
end

#brandObject (readonly)

Returns the value of attribute brand.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def brand
  @brand
end

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def data
  @data
end

#if_Object (readonly)

Returns the value of attribute if_.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def if_
  @if_
end

#overrideObject (readonly)

Returns the value of attribute override.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def override
  @override
end

#profileObject (readonly)

Returns the value of attribute profile.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def profile
  @profile
end

#recipientObject (readonly)

Returns the value of attribute recipient.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def recipient
  @recipient
end

#refObject (readonly)

Returns the value of attribute ref.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def ref
  @ref
end

#templateObject (readonly)

Returns the value of attribute template.



8
9
10
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 8

def template
  @template
end

Class Method Details

.from_json(json_object:) ⇒ Automations::AutomationSendStep

Deserialize a JSON object to an instance of AutomationSendStep

Parameters:

  • json_object (JSON)

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 49

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  action = struct.action
  brand = struct.brand
  data = struct.data
  override = struct.override
  profile = struct.profile
  recipient = struct.recipient
  template = struct.template
  if_ = struct.if
  ref = struct.ref
  new(action: action, brand: brand, data: data, override: override, profile: profile, recipient: recipient,
      template: template, 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)


86
87
88
89
90
91
92
93
94
95
96
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 86

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.")
  obj.brand&.is_a?(String) != false || raise("Passed value for field obj.brand is not the expected type, validation failed.")
  obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
  obj.override&.is_a?(Hash) != false || raise("Passed value for field obj.override is not the expected type, validation failed.")
  obj.profile&.is_a?(Object) != false || raise("Passed value for field obj.profile is not the expected type, validation failed.")
  obj.recipient&.is_a?(String) != false || raise("Passed value for field obj.recipient is not the expected type, validation failed.")
  obj.template&.is_a?(String) != false || raise("Passed value for field obj.template 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.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 AutomationSendStep to a JSON object

Returns:

  • (JSON)


68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/trycourier/automations/types/automation_send_step.rb', line 68

def to_json(*_args)
  {
    "action": @action,
    "brand": @brand,
    "data": @data,
    "override": @override,
    "profile": @profile,
    "recipient": @recipient,
    "template": @template,
    "if": @if_,
    "ref": @ref
  }.to_json
end