Class: Samsara::Types::AttributeExpanded

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/attribute_expanded.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, entities:, additional_properties: nil) ⇒ Samsara::Types::AttributeExpanded

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.

  • entities (Array<Samsara::Types::AttributeEntity>) —

    Entities that this attribute is applied onto

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

    Additional properties unmapped to the current class definition



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.

Returns:

  • (OpenStruct) —

    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.

Returns:



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.

Returns:



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.

Returns:

  • (String) —

    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.

Returns:

  • (String) —

    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.

Returns:

  • (Array<Float>) —

    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.

Returns:

  • (Array<String>) —

    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.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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

Parameters:

  • obj (Object)

Returns:

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

Returns:

  • (String)


107
108
109
# File 'lib/samsara_api/types/attribute_expanded.rb', line 107

def to_json
  @_field_set&.to_json
end