Class: Courier::Send::BrandTemplateOverride

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mjml:, enabled:, footer_background_color: nil, footer_full_width: nil, background_color: nil, blocks_background_color: nil, footer: nil, head: nil, header: nil, width: nil, additional_properties: nil) ⇒ Send::BrandTemplateOverride

Parameters:

  • mjml (Send::BrandTemplate)
  • footer_background_color (String) (defaults to: nil)
  • footer_full_width (Boolean) (defaults to: nil)
  • background_color (String) (defaults to: nil)
  • blocks_background_color (String) (defaults to: nil)
  • enabled (Boolean)
  • footer (String) (defaults to: nil)
  • head (String) (defaults to: nil)
  • header (String) (defaults to: nil)
  • width (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trycourier/send/types/brand_template_override.rb', line 24

def initialize(mjml:, enabled:, footer_background_color: nil, footer_full_width: nil, background_color: nil,
               blocks_background_color: nil, footer: nil, head: nil, header: nil, width: nil, additional_properties: nil)
  # @type [Send::BrandTemplate]
  @mjml = mjml
  # @type [String]
  @footer_background_color = footer_background_color
  # @type [Boolean]
  @footer_full_width = footer_full_width
  # @type [String]
  @background_color = background_color
  # @type [String]
  @blocks_background_color = blocks_background_color
  # @type [Boolean]
  @enabled = enabled
  # @type [String]
  @footer = footer
  # @type [String]
  @head = head
  # @type [String]
  @header = header
  # @type [String]
  @width = width
  # @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/send/types/brand_template_override.rb', line 9

def additional_properties
  @additional_properties
end

#background_colorObject (readonly)

Returns the value of attribute background_color.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def background_color
  @background_color
end

#blocks_background_colorObject (readonly)

Returns the value of attribute blocks_background_color.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def blocks_background_color
  @blocks_background_color
end

#enabledObject (readonly)

Returns the value of attribute enabled.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def enabled
  @enabled
end

Returns the value of attribute footer.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def footer
  @footer
end

Returns the value of attribute footer_background_color.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def footer_background_color
  @footer_background_color
end

Returns the value of attribute footer_full_width.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def footer_full_width
  @footer_full_width
end

#headObject (readonly)

Returns the value of attribute head.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def head
  @head
end

#headerObject (readonly)

Returns the value of attribute header.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def header
  @header
end

#mjmlObject (readonly)

Returns the value of attribute mjml.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def mjml
  @mjml
end

#widthObject (readonly)

Returns the value of attribute width.



9
10
11
# File 'lib/trycourier/send/types/brand_template_override.rb', line 9

def width
  @width
end

Class Method Details

.from_json(json_object:) ⇒ Send::BrandTemplateOverride

Deserialize a JSON object to an instance of BrandTemplateOverride

Parameters:

  • json_object (JSON)

Returns:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/trycourier/send/types/brand_template_override.rb', line 54

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["mjml"].nil?
    mjml = nil
  else
    mjml = parsed_json["mjml"].to_json
    mjml = Send::BrandTemplate.from_json(json_object: mjml)
  end
  footer_background_color = struct.footerBackgroundColor
  footer_full_width = struct.footerFullWidth
  background_color = struct.backgroundColor
  blocks_background_color = struct.blocksBackgroundColor
  enabled = struct.enabled
  footer = struct.footer
  head = struct.head
  header = struct.header
  width = struct.width
  new(mjml: mjml, footer_background_color: footer_background_color, footer_full_width: footer_full_width,
      background_color: background_color, blocks_background_color: blocks_background_color, enabled: enabled, footer: footer, head: head, header: header, width: width, 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)


98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/trycourier/send/types/brand_template_override.rb', line 98

def self.validate_raw(obj:)
  Send::BrandTemplate.validate_raw(obj: obj.mjml)
  obj.footer_background_color&.is_a?(String) != false || raise("Passed value for field obj.footer_background_color is not the expected type, validation failed.")
  obj.footer_full_width&.is_a?(Boolean) != false || raise("Passed value for field obj.footer_full_width is not the expected type, validation failed.")
  obj.background_color&.is_a?(String) != false || raise("Passed value for field obj.background_color is not the expected type, validation failed.")
  obj.blocks_background_color&.is_a?(String) != false || raise("Passed value for field obj.blocks_background_color is not the expected type, validation failed.")
  obj.enabled.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.")
  obj.footer&.is_a?(String) != false || raise("Passed value for field obj.footer is not the expected type, validation failed.")
  obj.head&.is_a?(String) != false || raise("Passed value for field obj.head is not the expected type, validation failed.")
  obj.header&.is_a?(String) != false || raise("Passed value for field obj.header 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.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of BrandTemplateOverride to a JSON object

Returns:

  • (JSON)


79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/trycourier/send/types/brand_template_override.rb', line 79

def to_json(*_args)
  {
    "mjml": @mjml,
    "footerBackgroundColor": @footer_background_color,
    "footerFullWidth": @footer_full_width,
    "backgroundColor": @background_color,
    "blocksBackgroundColor": @blocks_background_color,
    "enabled": @enabled,
    "footer": @footer,
    "head": @head,
    "header": @header,
    "width": @width
  }.to_json
end