Class: Samsara::Types::ReadingSnapshotResponseBody
- Inherits:
-
Object
- Object
- Samsara::Types::ReadingSnapshotResponseBody
- Defined in:
- lib/samsara_api/types/reading_snapshot_response_body.rb
Overview
A snapshot of a reading value at a point in time.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#entity_id ⇒ String
readonly
The ID of the entity this readings is for.
-
#external_ids ⇒ Hash{String => String}
readonly
A map of external ids.
-
#happened_at_time ⇒ String
readonly
The time in RFC 3339 format when the reading was measured.
-
#reading_id ⇒ String
readonly
The ID of the reading for which the data is being returned.
-
#value ⇒ Hash{String => Object}
readonly
The value of the reading.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(entity_id:, external_ids: OMIT, happened_at_time: OMIT, reading_id:, value: OMIT, additional_properties: nil) ⇒ Samsara::Types::ReadingSnapshotResponseBody constructor
- #to_json ⇒ String
Constructor Details
#initialize(entity_id:, external_ids: OMIT, happened_at_time: OMIT, reading_id:, value: OMIT, additional_properties: nil) ⇒ Samsara::Types::ReadingSnapshotResponseBody
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 34 def initialize(entity_id:, external_ids: OMIT, happened_at_time: OMIT, reading_id:, value: OMIT, additional_properties: nil) @entity_id = entity_id @external_ids = external_ids if external_ids != OMIT @happened_at_time = happened_at_time if happened_at_time != OMIT @reading_id = reading_id @value = value if value != OMIT @additional_properties = additional_properties @_field_set = { "entityId": entity_id, "externalIds": external_ids, "happenedAtTime": happened_at_time, "readingId": reading_id, "value": value }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 20 def additional_properties @additional_properties end |
#entity_id ⇒ String (readonly)
Returns The ID of the entity this readings is for.
10 11 12 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 10 def entity_id @entity_id end |
#external_ids ⇒ Hash{String => String} (readonly)
Returns A map of external ids.
12 13 14 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 12 def external_ids @external_ids end |
#happened_at_time ⇒ String (readonly)
Returns The time in RFC 3339 format when the reading was measured.
14 15 16 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 14 def happened_at_time @happened_at_time end |
#reading_id ⇒ String (readonly)
Returns The ID of the reading for which the data is being returned.
16 17 18 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 16 def reading_id @reading_id end |
#value ⇒ Hash{String => Object} (readonly)
Returns The value of the reading.
18 19 20 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 18 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::ReadingSnapshotResponseBody
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 49 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) entity_id = parsed_json["entityId"] external_ids = parsed_json["externalIds"] happened_at_time = parsed_json["happenedAtTime"] reading_id = parsed_json["readingId"] value = parsed_json["value"] new( entity_id: entity_id, external_ids: external_ids, happened_at_time: happened_at_time, reading_id: reading_id, value: value, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
78 79 80 81 82 83 84 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 78 def self.validate_raw(obj:) obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") obj.external_ids&.is_a?(Hash) != false || raise("Passed value for field obj.external_ids is not the expected type, validation failed.") obj.happened_at_time&.is_a?(String) != false || raise("Passed value for field obj.happened_at_time is not the expected type, validation failed.") obj.reading_id.is_a?(String) != false || raise("Passed value for field obj.reading_id is not the expected type, validation failed.") obj.value&.is_a?(Hash) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
69 70 71 |
# File 'lib/samsara_api/types/reading_snapshot_response_body.rb', line 69 def to_json @_field_set&.to_json end |