Class: Courier::Brands::BrandSettings
- Inherits:
-
Object
- Object
- Courier::Brands::BrandSettings
- Defined in:
- lib/trycourier/brands/types/brand_settings.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#inapp ⇒ Object
readonly
Returns the value of attribute inapp.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Brands::BrandSettings
Deserialize a JSON object to an instance of BrandSettings.
-
.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.
Instance Method Summary collapse
- #initialize(colors: nil, inapp: nil, email: nil, additional_properties: nil) ⇒ Brands::BrandSettings constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of BrandSettings to a JSON object.
Constructor Details
#initialize(colors: nil, inapp: nil, email: nil, additional_properties: nil) ⇒ Brands::BrandSettings
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_properties ⇒ Object (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 |
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
10 11 12 |
# File 'lib/trycourier/brands/types/brand_settings.rb', line 10 def colors @colors end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
10 11 12 |
# File 'lib/trycourier/brands/types/brand_settings.rb', line 10 def email @email end |
#inapp ⇒ Object (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
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.
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
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 |