Class: CandidApiClient::EncounterProviders::V2::Types::EncounterProviderBase

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/encounter_providers/v_2/types/encounter_provider_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: OMIT, last_name: OMIT, organization_name: OMIT, additional_properties: nil) ⇒ CandidApiClient::EncounterProviders::V2::Types::EncounterProviderBase

Parameters:

  • first_name (String) (defaults to: OMIT)

    If the provider is an individual, this should be set instead of organization name

  • last_name (String) (defaults to: OMIT)

    If the provider is an individual, this should be set instead of organization name

  • organization_name (String) (defaults to: OMIT)

    If the provider is an organization, this should be set instead of first + last name

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 36

def initialize(first_name: OMIT, last_name: OMIT, organization_name: OMIT, additional_properties: nil)
  @first_name = first_name if first_name != OMIT
  @last_name = last_name if last_name != OMIT
  @organization_name = organization_name if organization_name != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "first_name": first_name,
    "last_name": last_name,
    "organization_name": organization_name
  }.reject do |_k, v|
    v == OMIT
  end
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



21
22
23
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 21

def additional_properties
  @additional_properties
end

#first_nameString (readonly)

Returns If the provider is an individual, this should be set instead of organization name.

Returns:

  • (String)

    If the provider is an individual, this should be set instead of organization name



13
14
15
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 13

def first_name
  @first_name
end

#last_nameString (readonly)

Returns If the provider is an individual, this should be set instead of organization name.

Returns:

  • (String)

    If the provider is an individual, this should be set instead of organization name



16
17
18
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 16

def last_name
  @last_name
end

#organization_nameString (readonly)

Returns If the provider is an organization, this should be set instead of first + last name.

Returns:

  • (String)

    If the provider is an organization, this should be set instead of first + last name



19
20
21
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 19

def organization_name
  @organization_name
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::EncounterProviders::V2::Types::EncounterProviderBase

Deserialize a JSON object to an instance of EncounterProviderBase

Parameters:

  • json_object (String)

Returns:



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 54

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  first_name = struct["first_name"]
  last_name = struct["last_name"]
  organization_name = struct["organization_name"]
  new(
    first_name: first_name,
    last_name: last_name,
    organization_name: organization_name,
    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)


80
81
82
83
84
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 80

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of EncounterProviderBase to a JSON object

Returns:

  • (String)


70
71
72
# File 'lib/candidhealth/encounter_providers/v_2/types/encounter_provider_base.rb', line 70

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