Class: CandidApiClient::PreEncounter::Common::Types::Period
- Inherits:
-
Object
- Object
- CandidApiClient::PreEncounter::Common::Types::Period
- Defined in:
- lib/candidhealth/pre_encounter/common/types/period.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #end_ ⇒ Date readonly
- #start ⇒ Date readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::PreEncounter::Common::Types::Period
Deserialize a JSON object to an instance of Period.
-
.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.
Instance Method Summary collapse
- #initialize(start: OMIT, end_: OMIT, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Common::Types::Period constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Period to a JSON object.
Constructor Details
#initialize(start: OMIT, end_: OMIT, additional_properties: nil) ⇒ CandidApiClient::PreEncounter::Common::Types::Period
28 29 30 31 32 33 34 35 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 28 def initialize(start: OMIT, end_: OMIT, additional_properties: nil) @start = start if start != OMIT @end_ = end_ if end_ != OMIT @additional_properties = additional_properties @_field_set = { "start": start, "end": end_ }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
17 18 19 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 17 def additional_properties @additional_properties end |
#end_ ⇒ Date (readonly)
15 16 17 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 15 def end_ @end_ end |
#start ⇒ Date (readonly)
13 14 15 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 13 def start @start end |
Class Method Details
.from_json(json_object:) ⇒ CandidApiClient::PreEncounter::Common::Types::Period
Deserialize a JSON object to an instance of Period
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) start = (Date.parse(parsed_json["start"]) unless parsed_json["start"].nil?) end_ = (Date.parse(parsed_json["end"]) unless parsed_json["end"].nil?) new( start: start, end_: end_, 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.
66 67 68 69 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 66 def self.validate_raw(obj:) obj.start&.is_a?(Date) != false || raise("Passed value for field obj.start is not the expected type, validation failed.") obj.end_&.is_a?(Date) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Period to a JSON object
56 57 58 |
# File 'lib/candidhealth/pre_encounter/common/types/period.rb', line 56 def to_json(*_args) @_field_set&.to_json end |