Class: Samsara::Types::Attribute

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • entity_type (Samsara::Types::AttributeEntityType) (defaults to: OMIT) —

    Denotes the type of entity, driver or asset. Valid values: driver, asset.

  • id (String) (defaults to: OMIT) —

    The samsara id of the attribute object.

  • name (String) (defaults to: OMIT) —

    Name of attribute.

  • number_values (Array<Float>) (defaults to: OMIT) —

    Number values that can be associated with this attribute

  • string_values (Array<String>) (defaults to: OMIT) —

    String values that can be associated with this attribute

  • values (Array<Samsara::Types::AttributeValueTiny>) (defaults to: OMIT) —

    Representation of values that includes ids.

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



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.

Returns:

  • (OpenStruct) —

    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.

Returns:



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.

Returns:

  • (String) —

    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.

Returns:

  • (String) —

    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.

Returns:

  • (Array<Float>) —

    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.

Returns:

  • (Array<String>) —

    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.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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

Parameters:

  • obj (Object)

Returns:

  • (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

Returns:

  • (String)


97
98
99
# File 'lib/samsara_api/types/attribute.rb', line 97

def to_json
  @_field_set&.to_json
end