Class: CandidApiClient::CustomSchemas::V1::Types::SchemaInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_id:, content:, additional_properties: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance

Parameters:

  • schema_id (String)

    The schema to which the content must adhere.

  • content (Hash{String => Object})

    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.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#contentHash{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.

Returns:

  • (Hash{String => Object})

    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_idString (readonly)

Returns The schema to which the content must adhere.

Returns:

  • (String)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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