Class: Samsara::Types::AlertObjectAssetResponseBody

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

Overview

The Asset associated with the alert.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes: OMIT, external_ids: OMIT, id:, name: OMIT, serial:, tags: OMIT, type:, additional_properties: nil) ⇒ Samsara::Types::AlertObjectAssetResponseBody

Parameters:

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

    Additional properties unmapped to the current class definition



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 55

def initialize(attributes: OMIT, external_ids: OMIT, id:, name: OMIT, serial:, tags: OMIT, type:, additional_properties: nil)
  @attributes = attributes if attributes != OMIT
  @external_ids = external_ids if external_ids != OMIT
  @id = id
  @name = name if name != OMIT
  @serial = serial
  @tags = tags if tags != OMIT
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "attributes": attributes, "externalIds": external_ids, "id": id, "name": name, "serial": serial, "tags": tags, "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



33
34
35
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 33

def additional_properties
  @additional_properties
end

#attributes ⇒ Array<Samsara::Types::GoaAttributeTinyResponseBody> (readonly)

Returns List of attributes associated with the entity.

Returns:



13
14
15
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 13

def attributes
  @attributes
end

#external_ids ⇒ Hash{String => String} (readonly)

Returns A map of external ids.

Returns:

  • (Hash{String => String}) —

    A map of external ids



15
16
17
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 15

def external_ids
  @external_ids
end

#id ⇒ String (readonly)

Returns The ID of the asset.

Returns:

  • (String) —

    The ID of the asset.



17
18
19
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 17

def id
  @id
end

#name ⇒ String (readonly)

Returns The name of the asset.

Returns:

  • (String) —

    The name of the asset.



19
20
21
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 19

def name
  @name
end

#serial ⇒ String (readonly)

Returns The serial number of the gateway installed on the asset.

Returns:

  • (String) —

    The serial number of the gateway installed on the asset.



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

def serial
  @serial
end

#tags ⇒ Object (readonly)

associated with the asset.



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

def tags
  @tags
end

#type ⇒ Object (readonly)

trailer, equipment, unpowered, vehicle



31
32
33
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 31

def type
  @type
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



72
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
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 72

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  attributes = parsed_json["attributes"]&.map do | item |
  item = item.to_json
  Samsara::Types::GoaAttributeTinyResponseBody.from_json(json_object: item)
end
  external_ids = parsed_json["externalIds"]
  id = parsed_json["id"]
  name = parsed_json["name"]
  serial = parsed_json["serial"]
  tags = parsed_json["tags"]&.map do | item |
  item = item.to_json
  Samsara::Types::GoaTagTinyResponseResponseBody.from_json(json_object: item)
end
  type = parsed_json["type"]
  new(
    attributes: attributes,
    external_ids: external_ids,
    id: id,
    name: name,
    serial: serial,
    tags: tags,
    type: type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


111
112
113
114
115
116
117
118
119
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 111

def self.validate_raw(obj:)
  obj.attributes&.is_a?(Array) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
  obj.external_ids&.is_a?(Hash) != false || raise("Passed value for field obj.external_ids 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.serial.is_a?(String) != false || raise("Passed value for field obj.serial is not the expected type, validation failed.")
  obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.")
  obj.type.is_a?(Samsara::Types::AlertObjectAssetResponseBodyType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


102
103
104
# File 'lib/samsara_api/types/alert_object_asset_response_body.rb', line 102

def to_json
  @_field_set&.to_json
end