Class: CandidApiClient::PreEncounter::Common::Types::HumanName

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/pre_encounter/common/types/human_name.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(family:, given:, use:, period: OMIT, suffix: OMIT, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Common::Types::HumanName



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 38

def initialize(family:, given:, use:, period: OMIT, suffix: OMIT, additional_properties: nil)
  @family = family
  @given = given
  @use = use
  @period = period if period != OMIT
  @suffix = suffix if suffix != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "family": family,
    "given": given,
    "use": use,
    "period": period,
    "suffix": suffix
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



24
25
26
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 24

def additional_properties
  @additional_properties
end

#familyString (readonly)



14
15
16
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 14

def family
  @family
end

#givenArray<String> (readonly)



16
17
18
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 16

def given
  @given
end

#periodCandidApiClient::PreEncounter::Common::Types::Period (readonly)



20
21
22
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 20

def period
  @period
end

#suffixString (readonly)



22
23
24
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 22

def suffix
  @suffix
end

#useCandidApiClient::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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 60

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
  suffix = struct["suffix"]
  new(
    family: family,
    given: given,
    use: use,
    period: period,
    suffix: suffix,
    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.


96
97
98
99
100
101
102
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 96

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)
  obj.suffix&.is_a?(String) != false || raise("Passed value for field obj.suffix is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of HumanName to a JSON object



86
87
88
# File 'lib/candidhealth/pre_encounter/common/types/human_name.rb', line 86

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