Class: Samsara::Types::AttributeExpanded
- Inherits:
-
Object
- Object
- Samsara::Types::AttributeExpanded
- Defined in:
- lib/samsara_api/types/attribute_expanded.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).
-
#entities ⇒ Array<Samsara::Types::AttributeEntity>
readonly
Entities that this attribute is applied onto.
-
#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, entities:, additional_properties: nil) ⇒ Samsara::Types::AttributeExpanded 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, entities:, additional_properties: nil) ⇒ Samsara::Types::AttributeExpanded
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 54 def initialize(attribute_type: OMIT, attribute_value_quantity: OMIT, entity_type: OMIT, id: OMIT, name: OMIT, number_values: OMIT, string_values: OMIT, values: OMIT, entities:, 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 @entities = entities @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, "entities": entities }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
34 35 36 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 34 def additional_properties @additional_properties end |
#attribute_type ⇒ Object (readonly)
number.
15 16 17 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 15 def attribute_type @attribute_type end |
#attribute_value_quantity ⇒ Object (readonly)
(with different values). Valid values: single, multi.
18 19 20 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 18 def attribute_value_quantity @attribute_value_quantity end |
#entities ⇒ Array<Samsara::Types::AttributeEntity> (readonly)
Returns Entities that this attribute is applied onto.
32 33 34 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 32 def entities @entities end |
#entity_type ⇒ Samsara::Types::AttributeEntityType (readonly)
Returns Denotes the type of entity, driver or asset. Valid values: driver, asset.
20 21 22 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 20 def entity_type @entity_type end |
#id ⇒ String (readonly)
Returns The samsara id of the attribute object.
22 23 24 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 22 def id @id end |
#name ⇒ String (readonly)
Returns Name of attribute.
24 25 26 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 24 def name @name end |
#number_values ⇒ Array<Float> (readonly)
Returns Number values that can be associated with this attribute.
26 27 28 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 26 def number_values @number_values end |
#string_values ⇒ Array<String> (readonly)
Returns String values that can be associated with this attribute.
28 29 30 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 28 def string_values @string_values end |
#values ⇒ Array<Samsara::Types::AttributeValueTiny> (readonly)
Returns Representation of values that includes ids.
30 31 32 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 30 def values @values end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::AttributeExpanded
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 73 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 entities = parsed_json["entities"]&.map do | item | item = item.to_json Samsara::Types::AttributeEntity.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, entities: entities, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 116 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.") obj.entities.is_a?(Array) != false || raise("Passed value for field obj.entities is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
107 108 109 |
# File 'lib/samsara_api/types/attribute_expanded.rb', line 107 def to_json @_field_set&.to_json end |