Class: CandidApiClient::Commons::Types::StreetAddressBase

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/commons/types/street_address_base.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address_1:, city:, state:, zip_code:, address_2: OMIT, additional_properties: nil) ⇒ CandidApiClient::Commons::Types::StreetAddressBase

Parameters:

  • address_1 (String)
  • address_2 (String) (defaults to: OMIT)
  • city (String)
  • state (CandidApiClient::Commons::Types::State)
  • zip_code (String)

    5-digit zip code

  • 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
49
50
51
52
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 36

def initialize(address_1:, city:, state:, zip_code:, address_2: OMIT, additional_properties: nil)
  @address_1 = address_1
  @address_2 = address_2 if address_2 != OMIT
  @city = city
  @state = state
  @zip_code = zip_code
  @additional_properties = additional_properties
  @_field_set = {
    "address1": address_1,
    "address2": address_2,
    "city": city,
    "state": state,
    "zip_code": zip_code
  }.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



22
23
24
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 22

def additional_properties
  @additional_properties
end

#address_1String (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 12

def address_1
  @address_1
end

#address_2String (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 14

def address_2
  @address_2
end

#cityString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 16

def city
  @city
end

#stateCandidApiClient::Commons::Types::State (readonly)



18
19
20
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 18

def state
  @state
end

#zip_codeString (readonly)

Returns 5-digit zip code.

Returns:

  • (String)

    5-digit zip code



20
21
22
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 20

def zip_code
  @zip_code
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Commons::Types::StreetAddressBase

Deserialize a JSON object to an instance of StreetAddressBase

Parameters:

  • json_object (String)

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 58

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  address_1 = struct["address1"]
  address_2 = struct["address2"]
  city = struct["city"]
  state = struct["state"]
  zip_code = struct["zip_code"]
  new(
    address_1: address_1,
    address_2: address_2,
    city: city,
    state: state,
    zip_code: zip_code,
    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)


88
89
90
91
92
93
94
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 88

def self.validate_raw(obj:)
  obj.address_1.is_a?(String) != false || raise("Passed value for field obj.address_1 is not the expected type, validation failed.")
  obj.address_2&.is_a?(String) != false || raise("Passed value for field obj.address_2 is not the expected type, validation failed.")
  obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.")
  obj.state.is_a?(CandidApiClient::Commons::Types::State) != false || raise("Passed value for field obj.state is not the expected type, validation failed.")
  obj.zip_code.is_a?(String) != false || raise("Passed value for field obj.zip_code is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of StreetAddressBase to a JSON object

Returns:

  • (String)


78
79
80
# File 'lib/candidhealth/commons/types/street_address_base.rb', line 78

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