Class: CandidApiClient::CustomSchemas::V1::Types::SchemaInstance
- Inherits:
-
Object
- Object
- CandidApiClient::CustomSchemas::V1::Types::SchemaInstance
- Defined in:
- lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#content ⇒ Hash{String => Object}
readonly
A set of key-value pairs that adhere to the naming and type convention of the schema.
-
#schema_id ⇒ String
readonly
The schema to which the content must adhere.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance
Deserialize a JSON object to an instance of SchemaInstance.
-
.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(schema_id:, content:, additional_properties: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of SchemaInstance to a JSON object.
Constructor Details
#initialize(schema_id:, content:, additional_properties: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance
33 34 35 36 37 38 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 33 def initialize(schema_id:, content:, additional_properties: nil) @schema_id = schema_id @content = content @additional_properties = additional_properties @_field_set = { "schema_id": schema_id, "content": content } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
19 20 21 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 19 def additional_properties @additional_properties end |
#content ⇒ Hash{String => Object} (readonly)
Returns A set of key-value pairs that adhere to the naming and type convention of the schema. Not all keys in the schema must be included, but attaching any key that does not exist in the schema or attaching a key with the incorrect value type will result in errors.
17 18 19 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 17 def content @content end |
#schema_id ⇒ String (readonly)
Returns The schema to which the content must adhere.
12 13 14 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 12 def schema_id @schema_id end |
Class Method Details
.from_json(json_object:) ⇒ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance
Deserialize a JSON object to an instance of SchemaInstance
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 44 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) schema_id = struct["schema_id"] content = struct["content"] new( schema_id: schema_id, content: content, 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.
68 69 70 71 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 68 def self.validate_raw(obj:) obj.schema_id.is_a?(String) != false || raise("Passed value for field obj.schema_id is not the expected type, validation failed.") obj.content.is_a?(Hash) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of SchemaInstance to a JSON object
58 59 60 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb', line 58 def to_json(*_args) @_field_set&.to_json end |