Class: CandidApiClient::Individual::Types::IndividualBase
- Inherits:
-
Object
- Object
- CandidApiClient::Individual::Types::IndividualBase
- Defined in:
- lib/candidhealth/individual/types/individual_base.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #first_name ⇒ String readonly
- #gender ⇒ CandidApiClient::Individual::Types::Gender readonly
- #last_name ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::Individual::Types::IndividualBase
Deserialize a JSON object to an instance of IndividualBase.
-
.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(first_name:, last_name:, gender:, additional_properties: nil) ⇒ CandidApiClient::Individual::Types::IndividualBase constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of IndividualBase to a JSON object.
Constructor Details
#initialize(first_name:, last_name:, gender:, additional_properties: nil) ⇒ CandidApiClient::Individual::Types::IndividualBase
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_properties ⇒ OpenStruct (readonly)
Returns 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_name ⇒ String (readonly)
12 13 14 |
# File 'lib/candidhealth/individual/types/individual_base.rb', line 12 def first_name @first_name end |
#gender ⇒ CandidApiClient::Individual::Types::Gender (readonly)
16 17 18 |
# File 'lib/candidhealth/individual/types/individual_base.rb', line 16 def gender @gender end |
#last_name ⇒ String (readonly)
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
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.
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
58 59 60 |
# File 'lib/candidhealth/individual/types/individual_base.rb', line 58 def to_json(*_args) @_field_set&.to_json end |