Class: CandidApiClient::PreEncounter::Common::Types::BaseModel

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organization_id:, deactivated:, version:, updated_at:, updating_user_id:, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Common::Types::BaseModel

Parameters:

  • organization_id (String)

    The organization that owns this object.

  • deactivated (Boolean)

    True if the object is deactivated. Deactivated objects are not returned in search results but are returned in all other endpoints including scan.

  • version (Integer)

    The version of the object. Any update to any property of an object object will create a new version.

  • updated_at (DateTime)
  • updating_user_id (String)

    The user ID of the user who last updated the object.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 41

def initialize(organization_id:, deactivated:, version:, updated_at:, updating_user_id:,
               additional_properties: nil)
  @organization_id = organization_id
  @deactivated = deactivated
  @version = version
  @updated_at = updated_at
  @updating_user_id = updating_user_id
  @additional_properties = additional_properties
  @_field_set = {
    "organization_id": organization_id,
    "deactivated": deactivated,
    "version": version,
    "updated_at": updated_at,
    "updating_user_id": updating_user_id
  }
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



25
26
27
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 25

def additional_properties
  @additional_properties
end

#deactivatedBoolean (readonly)

Returns True if the object is deactivated. Deactivated objects are not returned in search results but are returned in all other endpoints including scan.

Returns:

  • (Boolean)

    True if the object is deactivated. Deactivated objects are not returned in search results but are returned in all other endpoints including scan.



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

def deactivated
  @deactivated
end

#organization_idString (readonly)

Returns The organization that owns this object.

Returns:

  • (String)

    The organization that owns this object.



13
14
15
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 13

def organization_id
  @organization_id
end

#updated_atDateTime (readonly)

Returns:

  • (DateTime)


21
22
23
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 21

def updated_at
  @updated_at
end

#updating_user_idString (readonly)

Returns The user ID of the user who last updated the object.

Returns:

  • (String)

    The user ID of the user who last updated the object.



23
24
25
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 23

def updating_user_id
  @updating_user_id
end

#versionInteger (readonly)

Returns The version of the object. Any update to any property of an object object will create a new version.

Returns:

  • (Integer)

    The version of the object. Any update to any property of an object object will create a new version.



19
20
21
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 19

def version
  @version
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::PreEncounter::Common::Types::BaseModel

Deserialize a JSON object to an instance of BaseModel

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  organization_id = struct["organization_id"]
  deactivated = struct["deactivated"]
  version = struct["version"]
  updated_at = (DateTime.parse(parsed_json["updated_at"]) unless parsed_json["updated_at"].nil?)
  updating_user_id = struct["updating_user_id"]
  new(
    organization_id: organization_id,
    deactivated: deactivated,
    version: version,
    updated_at: updated_at,
    updating_user_id: updating_user_id,
    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)


93
94
95
96
97
98
99
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 93

def self.validate_raw(obj:)
  obj.organization_id.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
  obj.deactivated.is_a?(Boolean) != false || raise("Passed value for field obj.deactivated is not the expected type, validation failed.")
  obj.version.is_a?(Integer) != false || raise("Passed value for field obj.version is not the expected type, validation failed.")
  obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.")
  obj.updating_user_id.is_a?(String) != false || raise("Passed value for field obj.updating_user_id is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of BaseModel to a JSON object

Returns:

  • (String)


83
84
85
# File 'lib/candidhealth/pre_encounter/common/types/base_model.rb', line 83

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