Class: Courier::Send::BrandSettingsInApp

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(widget_background:, colors:, icons:, preferences:, border_radius: nil, disable_message_icon: nil, font_family: nil, placement: nil, additional_properties: nil) ⇒ Send::BrandSettingsInApp

Parameters:



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

def initialize(widget_background:, colors:, icons:, preferences:, border_radius: nil, disable_message_icon: nil,
               font_family: nil, placement: nil, additional_properties: nil)
  # @type [String]
  @border_radius = border_radius
  # @type [Boolean]
  @disable_message_icon = disable_message_icon
  # @type [String]
  @font_family = font_family
  # @type [Send::InAppPlacement]
  @placement = placement
  # @type [Send::WidgetBackground]
  @widget_background = widget_background
  # @type [Brands::BrandColors]
  @colors = colors
  # @type [Send::Icons]
  @icons = icons
  # @type [Send::Preferences]
  @preferences = preferences
  # @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.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def additional_properties
  @additional_properties
end

#border_radiusObject (readonly)

Returns the value of attribute border_radius.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def border_radius
  @border_radius
end

#colorsObject (readonly)

Returns the value of attribute colors.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def colors
  @colors
end

#disable_message_iconObject (readonly)

Returns the value of attribute disable_message_icon.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def disable_message_icon
  @disable_message_icon
end

#font_familyObject (readonly)

Returns the value of attribute font_family.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def font_family
  @font_family
end

#iconsObject (readonly)

Returns the value of attribute icons.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def icons
  @icons
end

#placementObject (readonly)

Returns the value of attribute placement.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def placement
  @placement
end

#preferencesObject (readonly)

Returns the value of attribute preferences.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def preferences
  @preferences
end

#widget_backgroundObject (readonly)

Returns the value of attribute widget_background.



13
14
15
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 13

def widget_background
  @widget_background
end

Class Method Details

.from_json(json_object:) ⇒ Send::BrandSettingsInApp

Deserialize a JSON object to an instance of BrandSettingsInApp

Parameters:

  • json_object (JSON)

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 52

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  border_radius = struct.borderRadius
  disable_message_icon = struct.disableMessageIcon
  font_family = struct.fontFamily
  placement = struct.placement
  if parsed_json["widgetBackground"].nil?
    widget_background = nil
  else
    widget_background = parsed_json["widgetBackground"].to_json
    widget_background = Send::WidgetBackground.from_json(json_object: widget_background)
  end
  if parsed_json["colors"].nil?
    colors = nil
  else
    colors = parsed_json["colors"].to_json
    colors = Brands::BrandColors.from_json(json_object: colors)
  end
  if parsed_json["icons"].nil?
    icons = nil
  else
    icons = parsed_json["icons"].to_json
    icons = Send::Icons.from_json(json_object: icons)
  end
  if parsed_json["preferences"].nil?
    preferences = nil
  else
    preferences = parsed_json["preferences"].to_json
    preferences = Send::Preferences.from_json(json_object: preferences)
  end
  new(border_radius: border_radius, disable_message_icon: disable_message_icon, font_family: font_family,
      placement: placement, widget_background: widget_background, colors: colors, icons: icons, preferences: preferences, 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)


107
108
109
110
111
112
113
114
115
116
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 107

def self.validate_raw(obj:)
  obj.border_radius&.is_a?(String) != false || raise("Passed value for field obj.border_radius is not the expected type, validation failed.")
  obj.disable_message_icon&.is_a?(Boolean) != false || raise("Passed value for field obj.disable_message_icon is not the expected type, validation failed.")
  obj.font_family&.is_a?(String) != false || raise("Passed value for field obj.font_family is not the expected type, validation failed.")
  obj.placement&.is_a?(Send::InAppPlacement) != false || raise("Passed value for field obj.placement is not the expected type, validation failed.")
  Send::WidgetBackground.validate_raw(obj: obj.widget_background)
  Brands::BrandColors.validate_raw(obj: obj.colors)
  Send::Icons.validate_raw(obj: obj.icons)
  Send::Preferences.validate_raw(obj: obj.preferences)
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of BrandSettingsInApp to a JSON object

Returns:

  • (JSON)


90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/trycourier/send/types/brand_settings_in_app.rb', line 90

def to_json(*_args)
  {
    "borderRadius": @border_radius,
    "disableMessageIcon": @disable_message_icon,
    "fontFamily": @font_family,
    "placement": @placement,
    "widgetBackground": @widget_background,
    "colors": @colors,
    "icons": @icons,
    "preferences": @preferences
  }.to_json
end