Class: Samsara::Types::ReadingDefinitionResponseBody

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

Overview

Definition of a reading.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category:, description:, entity_type:, enum_values: OMIT, label:, reading_id:, type:, additional_properties: nil) ⇒ Samsara::Types::ReadingDefinitionResponseBody

Parameters:

  • reading_id (String) —

    The ID of the reading used to fetch time series data in other endpoints.

  • type (Samsara::Types::ReadingTypeResponseBody)
  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 44

def initialize(category:, description:, entity_type:, enum_values: OMIT, label:, reading_id:, type:, additional_properties: nil)
  @category = category
  @description = description
  @entity_type = entity_type
  @enum_values = enum_values if enum_values != OMIT
  @label = label
  @reading_id = reading_id
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "category": category, "description": description, "entityType": entity_type, "enumValues": enum_values, "label": label, "readingId": reading_id, "type": type }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



27
28
29
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 27

def additional_properties
  @additional_properties
end

#category ⇒ String (readonly)

Returns The category enumeration that this reading belongs to.

Returns:

  • (String) —

    The category enumeration that this reading belongs to.



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

def category
  @category
end

#description ⇒ String (readonly)

Returns The human readable description for this reading. Translated to English.

Returns:

  • (String) —

    The human readable description for this reading. Translated to English.



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

def description
  @description
end

#entity_type ⇒ String (readonly)

Returns Entity type of this reading.

Returns:

  • (String) —

    Entity type of this reading.



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

def entity_type
  @entity_type
end

#enum_values ⇒ Array<Samsara::Types::EnumValueResponseBody> (readonly)

Returns Array of enumeration values.

Returns:



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

def enum_values
  @enum_values
end

#label ⇒ Object (readonly)

English.



21
22
23
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 21

def label
  @label
end

#reading_id ⇒ String (readonly)

Returns The ID of the reading used to fetch time series data in other endpoints.

Returns:

  • (String) —

    The ID of the reading used to fetch time series data in other endpoints.



23
24
25
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 23

def reading_id
  @reading_id
end

#type ⇒ Samsara::Types::ReadingTypeResponseBody (readonly)



25
26
27
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 25

def type
  @type
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 61

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  category = parsed_json["category"]
  description = parsed_json["description"]
  entity_type = parsed_json["entityType"]
  enum_values = parsed_json["enumValues"]&.map do | item |
  item = item.to_json
  Samsara::Types::EnumValueResponseBody.from_json(json_object: item)
end
  label = parsed_json["label"]
  reading_id = parsed_json["readingId"]
  unless parsed_json["type"].nil?
    type = parsed_json["type"].to_json
    type = Samsara::Types::ReadingTypeResponseBody.from_json(json_object: type)
  else
    type = nil
  end
  new(
    category: category,
    description: description,
    entity_type: entity_type,
    enum_values: enum_values,
    label: label,
    reading_id: reading_id,
    type: type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


102
103
104
105
106
107
108
109
110
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 102

def self.validate_raw(obj:)
  obj.category.is_a?(String) != false || raise("Passed value for field obj.category is not the expected type, validation failed.")
  obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.entity_type.is_a?(String) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.")
  obj.enum_values&.is_a?(Array) != false || raise("Passed value for field obj.enum_values is not the expected type, validation failed.")
  obj.label.is_a?(String) != false || raise("Passed value for field obj.label 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.")
  Samsara::Types::ReadingTypeResponseBody.validate_raw(obj: obj.type)
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


93
94
95
# File 'lib/samsara_api/types/reading_definition_response_body.rb', line 93

def to_json
  @_field_set&.to_json
end