Class: Courier::Lists::List
- Inherits:
-
Object
- Object
- Courier::Lists::List
- Defined in:
- lib/trycourier/lists/types/list.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.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Lists::List
Deserialize a JSON object to an instance of List.
-
.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(id:, name:, created: nil, updated: nil, additional_properties: nil) ⇒ Lists::List constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of List to a JSON object.
Constructor Details
#initialize(id:, name:, created: nil, updated: nil, additional_properties: nil) ⇒ Lists::List
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/trycourier/lists/types/list.rb', line 16 def initialize(id:, name:, created: nil, updated: nil, additional_properties: nil) # @type [String] @id = id # @type [String] @name = name # @type [Integer] @created = created # @type [Integer] @updated = updated # @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.
8 9 10 |
# File 'lib/trycourier/lists/types/list.rb', line 8 def additional_properties @additional_properties end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
8 9 10 |
# File 'lib/trycourier/lists/types/list.rb', line 8 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/trycourier/lists/types/list.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/trycourier/lists/types/list.rb', line 8 def name @name end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
8 9 10 |
# File 'lib/trycourier/lists/types/list.rb', line 8 def updated @updated end |
Class Method Details
.from_json(json_object:) ⇒ Lists::List
Deserialize a JSON object to an instance of List
33 34 35 36 37 38 39 40 41 |
# File 'lib/trycourier/lists/types/list.rb', line 33 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) id = struct.id name = struct.name created = struct.created updated = struct.updated new(id: id, name: name, created: created, updated: updated, 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.
54 55 56 57 58 59 |
# File 'lib/trycourier/lists/types/list.rb', line 54 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.") obj.created&.is_a?(Integer) != false || raise("Passed value for field obj.created is not the expected type, validation failed.") obj.updated&.is_a?(Integer) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of List to a JSON object
46 47 48 |
# File 'lib/trycourier/lists/types/list.rb', line 46 def to_json(*_args) { "id": @id, "name": @name, "created": @created, "updated": @updated }.to_json end |