Class: Courier::Brands::BrandSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/brands/types/brand_settings.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(colors: nil, inapp: nil, email: nil, additional_properties: nil) ⇒ Brands::BrandSettings

Parameters:

  • colors (Brands::BrandColors) (defaults to: nil)
  • inapp (Object) (defaults to: nil)
  • email (Commons::Email) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



17
18
19
20
21
22
23
24
25
26
# File 'lib/trycourier/brands/types/brand_settings.rb', line 17

def initialize(colors: nil, inapp: nil, email: nil, additional_properties: nil)
  # @type [Brands::BrandColors]
  @colors = colors
  # @type [Object]
  @inapp = inapp
  # @type [Commons::Email]
  @email = email
  # @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.



10
11
12
# File 'lib/trycourier/brands/types/brand_settings.rb', line 10

def additional_properties
  @additional_properties
end

#colorsObject (readonly)

Returns the value of attribute colors.



10
11
12
# File 'lib/trycourier/brands/types/brand_settings.rb', line 10

def colors
  @colors
end

#emailObject (readonly)

Returns the value of attribute email.



10
11
12
# File 'lib/trycourier/brands/types/brand_settings.rb', line 10

def email
  @email
end

#inappObject (readonly)

Returns the value of attribute inapp.



10
11
12
# File 'lib/trycourier/brands/types/brand_settings.rb', line 10

def inapp
  @inapp
end

Class Method Details

.from_json(json_object:) ⇒ Brands::BrandSettings

Deserialize a JSON object to an instance of BrandSettings

Parameters:

  • json_object (JSON)

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/trycourier/brands/types/brand_settings.rb', line 32

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["colors"].nil?
    colors = nil
  else
    colors = parsed_json["colors"].to_json
    colors = Brands::BrandColors.from_json(json_object: colors)
  end
  inapp = struct.inapp
  if parsed_json["email"].nil?
    email = nil
  else
    email = parsed_json["email"].to_json
    email = Commons::Email.from_json(json_object: email)
  end
  new(colors: colors, inapp: inapp, email: email, 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)


62
63
64
65
66
# File 'lib/trycourier/brands/types/brand_settings.rb', line 62

def self.validate_raw(obj:)
  obj.colors.nil? || Brands::BrandColors.validate_raw(obj: obj.colors)
  obj.inapp&.is_a?(Object) != false || raise("Passed value for field obj.inapp is not the expected type, validation failed.")
  obj.email.nil? || Commons::Email.validate_raw(obj: obj.email)
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of BrandSettings to a JSON object

Returns:

  • (JSON)


54
55
56
# File 'lib/trycourier/brands/types/brand_settings.rb', line 54

def to_json(*_args)
  { "colors": @colors, "inapp": @inapp, "email": @email }.to_json
end