Class: CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(member:, discriminant:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError

Parameters:

  • member (Object)
  • discriminant (String)


26
27
28
29
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 26

def initialize(member:, discriminant:)
  @member = member
  @discriminant = discriminant
end

Instance Attribute Details

#discriminantString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 18

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns:

  • (Object)


16
17
18
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 16

def member
  @member
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError

Deserialize a JSON object to an instance of SchemaInstanceValidationError

Parameters:

  • json_object (String)

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 35

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  member = case struct.type
           when "multiple_instances_for_schema"
             CandidApiClient::Encounters::V4::Types::MultipleInstancesForSchemaError.from_json(json_object: json_object)
           when "value_does_not_match_key_type"
             CandidApiClient::Encounters::V4::Types::ValueDoesNotMatchKeyTypeError.from_json(json_object: json_object)
           when "key_does_not_exist"
             CandidApiClient::Encounters::V4::Types::KeyDoesNotExistError.from_json(json_object: json_object)
           when "schema_does_not_exist"
             CandidApiClient::Encounters::V4::Types::SchemaDoesNotExistError.from_json(json_object: json_object)
           when "schema_unauthorized_access"
             CandidApiClient::Encounters::V4::Types::SchemaUnauthorizedAccessError.from_json(json_object: json_object)
           else
             CandidApiClient::Encounters::V4::Types::MultipleInstancesForSchemaError.from_json(json_object: json_object)
           end
  new(member: member, discriminant: struct.type)
end

.key_does_not_exist(member:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError



120
121
122
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 120

def self.key_does_not_exist(member:)
  new(member: member, discriminant: "key_does_not_exist")
end

.multiple_instances_for_schema(member:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError



108
109
110
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 108

def self.multiple_instances_for_schema(member:)
  new(member: member, discriminant: "multiple_instances_for_schema")
end

.schema_does_not_exist(member:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError



126
127
128
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 126

def self.schema_does_not_exist(member:)
  new(member: member, discriminant: "schema_does_not_exist")
end

.schema_unauthorized_access(member:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError



132
133
134
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 132

def self.schema_unauthorized_access(member:)
  new(member: member, discriminant: "schema_unauthorized_access")
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)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 81

def self.validate_raw(obj:)
  case obj.type
  when "multiple_instances_for_schema"
    CandidApiClient::Encounters::V4::Types::MultipleInstancesForSchemaError.validate_raw(obj: obj)
  when "value_does_not_match_key_type"
    CandidApiClient::Encounters::V4::Types::ValueDoesNotMatchKeyTypeError.validate_raw(obj: obj)
  when "key_does_not_exist"
    CandidApiClient::Encounters::V4::Types::KeyDoesNotExistError.validate_raw(obj: obj)
  when "schema_does_not_exist"
    CandidApiClient::Encounters::V4::Types::SchemaDoesNotExistError.validate_raw(obj: obj)
  when "schema_unauthorized_access"
    CandidApiClient::Encounters::V4::Types::SchemaUnauthorizedAccessError.validate_raw(obj: obj)
  else
    raise("Passed value matched no type within the union, validation failed.")
  end
end

.value_does_not_match_key_type(member:) ⇒ CandidApiClient::Encounters::V4::Types::SchemaInstanceValidationError



114
115
116
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 114

def self.value_does_not_match_key_type(member:)
  new(member: member, discriminant: "value_does_not_match_key_type")
end

Instance Method Details

#is_a?(obj) ⇒ Boolean

For Union Types, is_a? functionality is delegated to the wrapped member.

Parameters:

  • obj (Object)

Returns:

  • (Boolean)


102
103
104
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 102

def is_a?(obj)
  @member.is_a?(obj)
end

#kind_of?Object



21
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 21

alias kind_of? is_a?

#to_json(*_args) ⇒ String

For Union Types, to_json functionality is delegated to the wrapped member.

Returns:

  • (String)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb', line 57

def to_json(*_args)
  case @discriminant
  when "multiple_instances_for_schema"
    { **@member.to_json, type: @discriminant }.to_json
  when "value_does_not_match_key_type"
    { **@member.to_json, type: @discriminant }.to_json
  when "key_does_not_exist"
    { **@member.to_json, type: @discriminant }.to_json
  when "schema_does_not_exist"
    { **@member.to_json, type: @discriminant }.to_json
  when "schema_unauthorized_access"
    { **@member.to_json, type: @discriminant }.to_json
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end