Class: Courier::Brands::Brand
- Inherits:
-
Object
- Object
- Courier::Brands::Brand
- Defined in:
- lib/trycourier/brands/types/brand.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#published ⇒ Object
readonly
Returns the value of attribute published.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#snippets ⇒ Object
readonly
Returns the value of attribute snippets.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Brands::Brand
Deserialize a JSON object to an instance of Brand.
-
.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(created:, name:, published:, settings:, updated:, version:, id: nil, snippets: nil, additional_properties: nil) ⇒ Brands::Brand constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of Brand to a JSON object.
Constructor Details
#initialize(created:, name:, published:, settings:, updated:, version:, id: nil, snippets: nil, additional_properties: nil) ⇒ Brands::Brand
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/trycourier/brands/types/brand.rb', line 22 def initialize(created:, name:, published:, settings:, updated:, version:, id: nil, snippets: nil, additional_properties: nil) # @type [Integer] The date/time of when the brand was created. Represented in milliseconds since Unix epoch. @created = created # @type [String] Brand Identifier @id = id # @type [String] Brand name @name = name # @type [Integer] The date/time of when the brand was published. Represented in milliseconds since Unix epoch. @published = published # @type [Brands::BrandSettings] @settings = settings # @type [Integer] The date/time of when the brand was updated. Represented in milliseconds since Unix epoch. @updated = updated # @type [Brands::BrandSnippets] @snippets = snippets # @type [String] The version identifier for the brand @version = version # @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.rb', line 10 def additional_properties @additional_properties end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
10 11 12 |
# File 'lib/trycourier/brands/types/brand.rb', line 10 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/trycourier/brands/types/brand.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.rb', line 10 def name @name end |
#published ⇒ Object (readonly)
Returns the value of attribute published.
10 11 12 |
# File 'lib/trycourier/brands/types/brand.rb', line 10 def published @published end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
10 11 12 |
# File 'lib/trycourier/brands/types/brand.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.rb', line 10 def snippets @snippets end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
10 11 12 |
# File 'lib/trycourier/brands/types/brand.rb', line 10 def updated @updated end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/trycourier/brands/types/brand.rb', line 10 def version @version end |
Class Method Details
.from_json(json_object:) ⇒ Brands::Brand
Deserialize a JSON object to an instance of Brand
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/trycourier/brands/types/brand.rb', line 48 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) created = struct.created id = struct.id name = struct.name published = struct.published if parsed_json["settings"].nil? settings = nil else settings = parsed_json["settings"].to_json settings = Brands::BrandSettings.from_json(json_object: settings) end updated = struct.updated if parsed_json["snippets"].nil? snippets = nil else snippets = parsed_json["snippets"].to_json snippets = Brands::BrandSnippets.from_json(json_object: snippets) end version = struct.version new(created: created, id: id, name: name, published: published, settings: settings, updated: updated, snippets: snippets, version: version, 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.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trycourier/brands/types/brand.rb', line 93 def self.validate_raw(obj:) obj.created.is_a?(Integer) != false || raise("Passed value for field obj.created is not the expected type, validation failed.") 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.") obj.published.is_a?(Integer) != false || raise("Passed value for field obj.published is not the expected type, validation failed.") Brands::BrandSettings.validate_raw(obj: obj.settings) obj.updated.is_a?(Integer) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.") obj.snippets.nil? || Brands::BrandSnippets.validate_raw(obj: obj.snippets) obj.version.is_a?(String) != false || raise("Passed value for field obj.version is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of Brand to a JSON object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/trycourier/brands/types/brand.rb', line 76 def to_json(*_args) { "created": @created, "id": @id, "name": @name, "published": @published, "settings": @settings, "updated": @updated, "snippets": @snippets, "version": @version }.to_json end |