Class: Courier::Send::BrandTemplate

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled:, background_color: nil, blocks_background_color: nil, footer: nil, head: nil, header: nil, width: nil, additional_properties: nil) ⇒ Send::BrandTemplate

Parameters:

  • 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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/trycourier/send/types/brand_template.rb', line 20

def initialize(enabled:, background_color: nil, blocks_background_color: nil, footer: nil, head: nil,
               header: nil, width: nil, additional_properties: nil)
  # @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.



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

def additional_properties
  @additional_properties
end

#background_colorObject (readonly)

Returns the value of attribute background_color.



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

def background_color
  @background_color
end

#blocks_background_colorObject (readonly)

Returns the value of attribute blocks_background_color.



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

def blocks_background_color
  @blocks_background_color
end

#enabledObject (readonly)

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

Returns the value of attribute footer.



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

def footer
  @footer
end

#headObject (readonly)

Returns the value of attribute head.



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

def head
  @head
end

#headerObject (readonly)

Returns the value of attribute header.



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

def header
  @header
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

Class Method Details

.from_json(json_object:) ⇒ Send::BrandTemplate

Deserialize a JSON object to an instance of BrandTemplate

Parameters:

  • json_object (JSON)

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/trycourier/send/types/brand_template.rb', line 44

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  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(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)


77
78
79
80
81
82
83
84
85
# File 'lib/trycourier/send/types/brand_template.rb', line 77

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

Returns:

  • (JSON)


61
62
63
64
65
66
67
68
69
70
71
# File 'lib/trycourier/send/types/brand_template.rb', line 61

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