Class: Intrinsic::EventTypeObject
- Inherits:
-
Object
- Object
- Intrinsic::EventTypeObject
- Defined in:
- lib/intrinsic/types/event_type_object.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ EventTypeObject
Deserialize a JSON object to an instance of EventTypeObject.
-
.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:, fields:, object:, additional_properties: nil) ⇒ EventTypeObject constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of EventTypeObject to a JSON object.
Constructor Details
#initialize(id:, name:, fields:, object:, additional_properties: nil) ⇒ EventTypeObject
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/intrinsic/types/event_type_object.rb', line 16 def initialize(id:, name:, fields:, object:, additional_properties: nil) # @type [String] ID of the event type @id = id # @type [String] Name of the event type. Must be unique, and can only contain alphanumeric characters and underscores, and be up to 255 characters @name = name # @type [Array<EventTypeField>] Fields of the event type @fields = fields # @type [String] @object = object # @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/intrinsic/types/event_type_object.rb', line 8 def additional_properties @additional_properties end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/intrinsic/types/event_type_object.rb', line 8 def fields @fields end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/intrinsic/types/event_type_object.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/intrinsic/types/event_type_object.rb', line 8 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/intrinsic/types/event_type_object.rb', line 8 def object @object end |
Class Method Details
.from_json(json_object:) ⇒ EventTypeObject
Deserialize a JSON object to an instance of EventTypeObject
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/intrinsic/types/event_type_object.rb', line 33 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 fields = parsed_json["fields"]&.map do |v| v = v.to_json EventTypeField.from_json(json_object: v) end object = struct.object new(id: id, name: name, fields: fields, object: object, 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.
57 58 59 60 61 62 |
# File 'lib/intrinsic/types/event_type_object.rb', line 57 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.fields.is_a?(Array) != false || raise("Passed value for field obj.fields is not the expected type, validation failed.") obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of EventTypeObject to a JSON object
49 50 51 |
# File 'lib/intrinsic/types/event_type_object.rb', line 49 def to_json(*_args) { "id": @id, "name": @name, "fields": @fields, "object": @object }.to_json end |