Class: Courier::Brands::BrandParameters
- Inherits:
-
Object
- Object
- Courier::Brands::BrandParameters
- Defined in:
- lib/trycourier/brands/types/brand_parameters.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#snippets ⇒ Object
readonly
Returns the value of attribute snippets.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Brands::BrandParameters
Deserialize a JSON object to an instance of BrandParameters.
-
.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(name:, settings:, id: nil, snippets: nil, additional_properties: nil) ⇒ Brands::BrandParameters constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of BrandParameters to a JSON object.
Constructor Details
#initialize(name:, settings:, id: nil, snippets: nil, additional_properties: nil) ⇒ Brands::BrandParameters
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 18 def initialize(name:, settings:, id: nil, snippets: nil, additional_properties: nil) # @type [String] @id = id # @type [String] The name of the brand. @name = name # @type [Brands::BrandSettings] @settings = settings # @type [Brands::BrandSnippets] @snippets = snippets # @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_parameters.rb', line 10 def additional_properties @additional_properties end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 10 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 10 def name @name end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
10 11 12 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 10 def settings @settings end |
#snippets ⇒ Object (readonly)
Returns the value of attribute snippets.
10 11 12 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 10 def snippets @snippets end |
Class Method Details
.from_json(json_object:) ⇒ Brands::BrandParameters
Deserialize a JSON object to an instance of BrandParameters
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 35 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct.id name = struct.name if parsed_json["settings"].nil? settings = nil else settings = parsed_json["settings"].to_json settings = Brands::BrandSettings.from_json(json_object: settings) end if parsed_json["snippets"].nil? snippets = nil else snippets = parsed_json["snippets"].to_json snippets = Brands::BrandSnippets.from_json(json_object: snippets) end new(id: id, name: name, settings: settings, snippets: snippets, 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.
66 67 68 69 70 71 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 66 def self.validate_raw(obj:) obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") Brands::BrandSettings.validate_raw(obj: obj.settings) obj.snippets.nil? || Brands::BrandSnippets.validate_raw(obj: obj.snippets) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of BrandParameters to a JSON object
58 59 60 |
# File 'lib/trycourier/brands/types/brand_parameters.rb', line 58 def to_json(*_args) { "id": @id, "name": @name, "settings": @settings, "snippets": @snippets }.to_json end |