Class: CandidApiClient::PreEncounter::Common::Types::HumanName
- Inherits:
-
Object
- Object
- CandidApiClient::PreEncounter::Common::Types::HumanName
- Defined in:
- lib/candidhealth/pre_encounter/common/types/human_name.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #family ⇒ String readonly
- #given ⇒ Array<String> readonly
- #period ⇒ CandidApiClient::PreEncounter::Common::Types::Period readonly
- #use ⇒ CandidApiClient::PreEncounter::Common::Types::NameUse readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::PreEncounter::Common::Types::HumanName
Deserialize a JSON object to an instance of HumanName.
-
.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(family:, given:, use:, period: OMIT, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Common::Types::HumanName constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of HumanName to a JSON object.
Constructor Details
#initialize(family:, given:, use:, period: OMIT, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Common::Types::HumanName
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 35 def initialize(family:, given:, use:, period: OMIT, additional_properties: nil) @family = family @given = given @use = use @period = period if period != OMIT @additional_properties = additional_properties @_field_set = { "family": family, "given": given, "use": use, "period": period }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
22 23 24 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 22 def additional_properties @additional_properties end |
#family ⇒ String (readonly)
14 15 16 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 14 def family @family end |
#given ⇒ Array<String> (readonly)
16 17 18 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 16 def given @given end |
#period ⇒ CandidApiClient::PreEncounter::Common::Types::Period (readonly)
20 21 22 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 20 def period @period end |
#use ⇒ CandidApiClient::PreEncounter::Common::Types::NameUse (readonly)
18 19 20 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 18 def use @use end |
Class Method Details
.from_json(json_object:) ⇒ CandidApiClient::PreEncounter::Common::Types::HumanName
Deserialize a JSON object to an instance of HumanName
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 50 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) family = struct["family"] given = struct["given"] use = struct["use"] if parsed_json["period"].nil? period = nil else period = parsed_json["period"].to_json period = CandidApiClient::PreEncounter::Common::Types::Period.from_json(json_object: period) end new( family: family, given: given, use: use, period: period, 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.
84 85 86 87 88 89 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 84 def self.validate_raw(obj:) obj.family.is_a?(String) != false || raise("Passed value for field obj.family is not the expected type, validation failed.") obj.given.is_a?(Array) != false || raise("Passed value for field obj.given is not the expected type, validation failed.") obj.use.is_a?(CandidApiClient::PreEncounter::Common::Types::NameUse) != false || raise("Passed value for field obj.use is not the expected type, validation failed.") obj.period.nil? || CandidApiClient::PreEncounter::Common::Types::Period.validate_raw(obj: obj.period) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of HumanName to a JSON object
74 75 76 |
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 74 def to_json(*_args) @_field_set&.to_json end |