Class: Samsara::Types::ReadingTypeResponseBody
- Inherits:
-
Object
- Object
- Samsara::Types::ReadingTypeResponseBody
- Defined in:
- lib/samsara_api/types/reading_type_response_body.rb
Overview
Type information for the reading.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#data_type ⇒ Samsara::Types::ReadingTypeResponseBodyDataType
readonly
The data type of the reading.
- #unit ⇒ Samsara::Types::UnitResponseBody readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(data_type:, unit: OMIT, additional_properties: nil) ⇒ Samsara::Types::ReadingTypeResponseBody constructor
- #to_json ⇒ String
Constructor Details
#initialize(data_type:, unit: OMIT, additional_properties: nil) ⇒ Samsara::Types::ReadingTypeResponseBody
27 28 29 30 31 32 33 34 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 27 def initialize(data_type:, unit: OMIT, additional_properties: nil) @data_type = data_type @unit = unit if unit != OMIT @additional_properties = additional_properties @_field_set = { "dataType": data_type, "unit": unit }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 16 def additional_properties @additional_properties end |
#data_type ⇒ Samsara::Types::ReadingTypeResponseBodyDataType (readonly)
Returns The data type of the reading. Valid values: integer, float, string.
12 13 14 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 12 def data_type @data_type end |
#unit ⇒ Samsara::Types::UnitResponseBody (readonly)
14 15 16 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 14 def unit @unit end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::ReadingTypeResponseBody
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 39 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) data_type = parsed_json["dataType"] unless parsed_json["unit"].nil? unit = parsed_json["unit"].to_json unit = Samsara::Types::UnitResponseBody.from_json(json_object: unit) else unit = nil end new( data_type: data_type, unit: unit, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
67 68 69 70 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 67 def self.validate_raw(obj:) obj.data_type.is_a?(Samsara::Types::ReadingTypeResponseBodyDataType) != false || raise("Passed value for field obj.data_type is not the expected type, validation failed.") obj.unit.nil? || Samsara::Types::UnitResponseBody.validate_raw(obj: obj.unit) end |
Instance Method Details
#to_json ⇒ String
58 59 60 |
# File 'lib/samsara_api/types/reading_type_response_body.rb', line 58 def to_json @_field_set&.to_json end |