Class: CandidApiClient::Individual::Types::IndividualBase

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/individual/types/individual_base.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first_name:, last_name:, gender:, additional_properties: nil) ⇒ CandidApiClient::Individual::Types::IndividualBase

Parameters:

  • first_name (String)
  • last_name (String)
  • gender (CandidApiClient::Individual::Types::Gender)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



30
31
32
33
34
35
36
# File 'lib/candidhealth/individual/types/individual_base.rb', line 30

def initialize(first_name:, last_name:, gender:, additional_properties: nil)
  @first_name = first_name
  @last_name = last_name
  @gender = gender
  @additional_properties = additional_properties
  @_field_set = { "first_name": first_name, "last_name": last_name, "gender": gender }
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



18
19
20
# File 'lib/candidhealth/individual/types/individual_base.rb', line 18

def additional_properties
  @additional_properties
end

#first_nameString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/candidhealth/individual/types/individual_base.rb', line 12

def first_name
  @first_name
end

#genderCandidApiClient::Individual::Types::Gender (readonly)



16
17
18
# File 'lib/candidhealth/individual/types/individual_base.rb', line 16

def gender
  @gender
end

#last_nameString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/candidhealth/individual/types/individual_base.rb', line 14

def last_name
  @last_name
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Individual::Types::IndividualBase

Deserialize a JSON object to an instance of IndividualBase

Parameters:

  • json_object (String)

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/candidhealth/individual/types/individual_base.rb', line 42

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  first_name = struct["first_name"]
  last_name = struct["last_name"]
  gender = struct["gender"]
  new(
    first_name: first_name,
    last_name: last_name,
    gender: gender,
    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
72
# File 'lib/candidhealth/individual/types/individual_base.rb', line 68

def self.validate_raw(obj:)
  obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.")
  obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.")
  obj.gender.is_a?(CandidApiClient::Individual::Types::Gender) != false || raise("Passed value for field obj.gender is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of IndividualBase to a JSON object

Returns:

  • (String)


58
59
60
# File 'lib/candidhealth/individual/types/individual_base.rb', line 58

def to_json(*_args)
  @_field_set&.to_json
end