Class: Samsara::Types::Attribute
- Inherits:
-
Object
- Object
- Samsara::Types::Attribute
- Defined in:
- lib/samsara_api/types/attribute.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#attribute_type ⇒ Object
readonly
number. -
#attribute_value_quantity ⇒ Object
readonly
(with different values).
-
#entity_type ⇒ Samsara::Types::AttributeEntityType
readonly
Denotes the type of entity, driver or asset.
-
#id ⇒ String
readonly
The samsara id of the attribute object.
-
#name ⇒ String
readonly
Name of attribute.
-
#number_values ⇒ Array<Float>
readonly
Number values that can be associated with this attribute.
-
#string_values ⇒ Array<String>
readonly
String values that can be associated with this attribute.
-
#values ⇒ Array<Samsara::Types::AttributeValueTiny>
readonly
Representation of values that includes ids.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(attribute_type: OMIT, attribute_value_quantity: OMIT, entity_type: OMIT, id: OMIT, name: OMIT, number_values: OMIT, string_values: OMIT, values: OMIT, additional_properties: nil) ⇒ Samsara::Types::Attribute constructor
- #to_json ⇒ String
Constructor Details
#initialize(attribute_type: OMIT, attribute_value_quantity: OMIT, entity_type: OMIT, id: OMIT, name: OMIT, number_values: OMIT, string_values: OMIT, values: OMIT, additional_properties: nil) ⇒ Samsara::Types::Attribute
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/samsara_api/types/attribute.rb', line 50 def initialize(attribute_type: OMIT, attribute_value_quantity: OMIT, entity_type: OMIT, id: OMIT, name: OMIT, number_values: OMIT, string_values: OMIT, values: OMIT, additional_properties: nil) @attribute_type = attribute_type if attribute_type != OMIT @attribute_value_quantity = attribute_value_quantity if attribute_value_quantity != OMIT @entity_type = entity_type if entity_type != OMIT @id = id if id != OMIT @name = name if name != OMIT @number_values = number_values if number_values != OMIT @string_values = string_values if string_values != OMIT @values = values if values != OMIT @additional_properties = additional_properties @_field_set = { "attributeType": attribute_type, "attributeValueQuantity": attribute_value_quantity, "entityType": entity_type, "id": id, "name": name, "numberValues": number_values, "stringValues": string_values, "values": values }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
31 32 33 |
# File 'lib/samsara_api/types/attribute.rb', line 31 def additional_properties @additional_properties end |
#attribute_type ⇒ Object (readonly)
number.
14 15 16 |
# File 'lib/samsara_api/types/attribute.rb', line 14 def attribute_type @attribute_type end |
#attribute_value_quantity ⇒ Object (readonly)
(with different values). Valid values: single, multi.
17 18 19 |
# File 'lib/samsara_api/types/attribute.rb', line 17 def attribute_value_quantity @attribute_value_quantity end |
#entity_type ⇒ Samsara::Types::AttributeEntityType (readonly)
Returns Denotes the type of entity, driver or asset. Valid values: driver, asset.
19 20 21 |
# File 'lib/samsara_api/types/attribute.rb', line 19 def entity_type @entity_type end |
#id ⇒ String (readonly)
Returns The samsara id of the attribute object.
21 22 23 |
# File 'lib/samsara_api/types/attribute.rb', line 21 def id @id end |
#name ⇒ String (readonly)
Returns Name of attribute.
23 24 25 |
# File 'lib/samsara_api/types/attribute.rb', line 23 def name @name end |
#number_values ⇒ Array<Float> (readonly)
Returns Number values that can be associated with this attribute.
25 26 27 |
# File 'lib/samsara_api/types/attribute.rb', line 25 def number_values @number_values end |
#string_values ⇒ Array<String> (readonly)
Returns String values that can be associated with this attribute.
27 28 29 |
# File 'lib/samsara_api/types/attribute.rb', line 27 def string_values @string_values end |
#values ⇒ Array<Samsara::Types::AttributeValueTiny> (readonly)
Returns Representation of values that includes ids.
29 30 31 |
# File 'lib/samsara_api/types/attribute.rb', line 29 def values @values end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::Attribute
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/samsara_api/types/attribute.rb', line 68 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) attribute_type = parsed_json["attributeType"] attribute_value_quantity = parsed_json["attributeValueQuantity"] entity_type = parsed_json["entityType"] id = parsed_json["id"] name = parsed_json["name"] number_values = parsed_json["numberValues"] string_values = parsed_json["stringValues"] values = parsed_json["values"]&.map do | item | item = item.to_json Samsara::Types::AttributeValueTiny.from_json(json_object: item) end new( attribute_type: attribute_type, attribute_value_quantity: attribute_value_quantity, entity_type: entity_type, id: id, name: name, number_values: number_values, string_values: string_values, values: values, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/samsara_api/types/attribute.rb', line 106 def self.validate_raw(obj:) obj.attribute_type&.is_a?(Samsara::Types::AttributeAttributeType) != false || raise("Passed value for field obj.attribute_type is not the expected type, validation failed.") obj.attribute_value_quantity&.is_a?(Samsara::Types::AttributeAttributeValueQuantity) != false || raise("Passed value for field obj.attribute_value_quantity is not the expected type, validation failed.") obj.entity_type&.is_a?(Samsara::Types::AttributeEntityType) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.") obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.number_values&.is_a?(Array) != false || raise("Passed value for field obj.number_values is not the expected type, validation failed.") obj.string_values&.is_a?(Array) != false || raise("Passed value for field obj.string_values is not the expected type, validation failed.") obj.values&.is_a?(Array) != false || raise("Passed value for field obj.values is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
97 98 99 |
# File 'lib/samsara_api/types/attribute.rb', line 97 def to_json @_field_set&.to_json end |