Class: Courier::Notifications::BaseCheck
- Inherits:
-
Object
- Object
- Courier::Notifications::BaseCheck
- Defined in:
- lib/trycourier/notifications/types/base_check.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.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Notifications::BaseCheck
Deserialize a JSON object to an instance of BaseCheck.
-
.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:, status:, type:, additional_properties: nil) ⇒ Notifications::BaseCheck constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of BaseCheck to a JSON object.
Constructor Details
#initialize(id:, status:, type:, additional_properties: nil) ⇒ Notifications::BaseCheck
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 16 def initialize(id:, status:, type:, additional_properties: nil) # @type [String] @id = id # @type [Notifications::CheckStatus] @status = status # @type [String] @type = type # @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.
9 10 11 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 9 def additional_properties @additional_properties end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 9 def id @id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 9 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 9 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Notifications::BaseCheck
Deserialize a JSON object to an instance of BaseCheck
31 32 33 34 35 36 37 38 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) id = struct.id status = struct.status type = struct.type new(id: id, status: status, type: type, 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.
51 52 53 54 55 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 51 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.status.is_a?(Notifications::CheckStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of BaseCheck to a JSON object
43 44 45 |
# File 'lib/trycourier/notifications/types/base_check.rb', line 43 def to_json(*_args) { "id": @id, "status": @status, "type": @type }.to_json end |