Class: Courier::Automations::AutomationInvokeTemplateParams

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_id:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil, additional_properties: nil) ⇒ Automations::AutomationInvokeTemplateParams

Parameters:

  • template_id (String)
  • brand (String) (defaults to: nil)
  • data (Hash{String => String}) (defaults to: nil)
  • profile (Automations::PROFILE) (defaults to: nil)
  • recipient (String) (defaults to: nil)
  • template (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/trycourier/automations/types/automation_invoke_template_params.rb', line 19

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



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

def additional_properties
  @additional_properties
end

#brandObject (readonly)

Returns the value of attribute brand.



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

def brand
  @brand
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#profileObject (readonly)

Returns the value of attribute profile.



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

def profile
  @profile
end

#recipientObject (readonly)

Returns the value of attribute recipient.



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

def recipient
  @recipient
end

#templateObject (readonly)

Returns the value of attribute template.



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

def template
  @template
end

#template_idObject (readonly)

Returns the value of attribute template_id.



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

def template_id
  @template_id
end

Class Method Details

.from_json(json_object:) ⇒ Automations::AutomationInvokeTemplateParams

Deserialize a JSON object to an instance of AutomationInvokeTemplateParams

Parameters:

  • json_object (JSON)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/trycourier/automations/types/automation_invoke_template_params.rb', line 41

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


72
73
74
75
76
77
78
79
# File 'lib/trycourier/automations/types/automation_invoke_template_params.rb', line 72

def self.validate_raw(obj:)
  obj.template_id.is_a?(String) != false || raise("Passed value for field obj.template_id 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.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.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of AutomationInvokeTemplateParams to a JSON object

Returns:

  • (JSON)


57
58
59
60
61
62
63
64
65
66
# File 'lib/trycourier/automations/types/automation_invoke_template_params.rb', line 57

def to_json(*_args)
  {
    "templateId": @template_id,
    "brand": @brand,
    "data": @data,
    "profile": @profile,
    "recipient": @recipient,
    "template": @template
  }.to_json
end