Class: Samsara::Types::ReadingHistoryResponseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/reading_history_response_body.rb

Overview

A history of reading values for an entity.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity_id:, external_ids: OMIT, happened_at_time: OMIT, value: OMIT, additional_properties: nil) ⇒ Samsara::Types::ReadingHistoryResponseBody



31
32
33
34
35
36
37
38
39
40
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 31

def initialize(entity_id:, external_ids: OMIT, happened_at_time: OMIT, 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
  @value = value if value != OMIT
  @additional_properties = additional_properties
  @_field_set = { "entityId": entity_id, "externalIds": external_ids, "happenedAtTime": happened_at_time, "value": value }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)



18
19
20
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 18

def additional_properties
  @additional_properties
end

#entity_id ⇒ String (readonly)



10
11
12
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 10

def entity_id
  @entity_id
end

#external_ids ⇒ Hash{String => String} (readonly)



12
13
14
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 12

def external_ids
  @external_ids
end

#happened_at_time ⇒ String (readonly)



14
15
16
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 14

def happened_at_time
  @happened_at_time
end

#value ⇒ Hash{String => Object} (readonly)



16
17
18
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 16

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::ReadingHistoryResponseBody



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 45

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"]
  value = parsed_json["value"]
  new(
    entity_id: entity_id,
    external_ids: external_ids,
    happened_at_time: happened_at_time,
    value: value,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



72
73
74
75
76
77
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 72

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.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



63
64
65
# File 'lib/samsara_api/types/reading_history_response_body.rb', line 63

def to_json
  @_field_set&.to_json
end