Class: CandidApiClient::PreEncounter::Coverages::V1::Types::PlanDate

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_date:, field_name:, end_date: OMIT, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Coverages::V1::Types::PlanDate

Parameters:

  • start_date (Date)
  • end_date (Date) (defaults to: OMIT)
  • field_name (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 32

def initialize(start_date:, field_name:, end_date: OMIT, additional_properties: nil)
  @start_date = start_date
  @end_date = end_date if end_date != OMIT
  @field_name = field_name
  @additional_properties = additional_properties
  @_field_set = {
    "start_date": start_date,
    "end_date": end_date,
    "field_name": field_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



20
21
22
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 20

def additional_properties
  @additional_properties
end

#end_dateDate (readonly)

Returns:

  • (Date)


16
17
18
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 16

def end_date
  @end_date
end

#field_nameString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 18

def field_name
  @field_name
end

#start_dateDate (readonly)

Returns:

  • (Date)


14
15
16
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 14

def start_date
  @start_date
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::PreEncounter::Coverages::V1::Types::PlanDate

Deserialize a JSON object to an instance of PlanDate

Parameters:

  • json_object (String)

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 50

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  start_date = (Date.parse(parsed_json["start_date"]) unless parsed_json["start_date"].nil?)
  end_date = (Date.parse(parsed_json["end_date"]) unless parsed_json["end_date"].nil?)
  field_name = struct["field_name"]
  new(
    start_date: start_date,
    end_date: end_date,
    field_name: field_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)


77
78
79
80
81
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 77

def self.validate_raw(obj:)
  obj.start_date.is_a?(Date) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.")
  obj.end_date&.is_a?(Date) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.")
  obj.field_name.is_a?(String) != false || raise("Passed value for field obj.field_name is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PlanDate to a JSON object

Returns:

  • (String)


67
68
69
# File 'lib/candidhealth/pre_encounter/coverages/v_1/types/plan_date.rb', line 67

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