Class: Samsara::Types::AlertObjectVehicleResponseBody
- Inherits:
-
Object
- Object
- Samsara::Types::AlertObjectVehicleResponseBody
- Defined in:
- lib/samsara_api/types/alert_object_vehicle_response_body.rb
Overview
The vehicle associated with the alert.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#attributes ⇒ Array<Samsara::Types::GoaAttributeTinyResponseBody>
readonly
List of attributes associated with the entity.
-
#external_ids ⇒ Hash{String => String}
readonly
A map of external ids.
-
#id ⇒ String
readonly
The ID of the vehicle.
-
#name ⇒ String
readonly
The name of the vehicle.
-
#serial ⇒ String
readonly
The serial number of the gateway installed on the asset.
- #static_assigned_driver ⇒ Samsara::Types::DriverObjectResponseBody readonly
-
#tags ⇒ Object
readonly
associated with the vehicle.
Class Method Summary collapse
- .from_json(json_object:) ⇒ Samsara::Types::AlertObjectVehicleResponseBody
- .validate_raw(obj:) ⇒ Void
Instance Method Summary collapse
- #initialize(attributes: OMIT, external_ids: OMIT, id:, name: OMIT, serial:, static_assigned_driver: OMIT, tags: OMIT, additional_properties: nil) ⇒ Samsara::Types::AlertObjectVehicleResponseBody constructor
- #to_json ⇒ String
Constructor Details
#initialize(attributes: OMIT, external_ids: OMIT, id:, name: OMIT, serial:, static_assigned_driver: OMIT, tags: OMIT, additional_properties: nil) ⇒ Samsara::Types::AlertObjectVehicleResponseBody
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 47 def initialize(attributes: OMIT, external_ids: OMIT, id:, name: OMIT, serial:, static_assigned_driver: OMIT, tags: OMIT, 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 @static_assigned_driver = static_assigned_driver if static_assigned_driver != OMIT = if != OMIT @additional_properties = additional_properties @_field_set = { "attributes": attributes, "externalIds": external_ids, "id": id, "name": name, "serial": serial, "staticAssignedDriver": static_assigned_driver, "tags": }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
29 30 31 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 29 def additional_properties @additional_properties end |
#attributes ⇒ Array<Samsara::Types::GoaAttributeTinyResponseBody> (readonly)
Returns List of attributes associated with the entity.
13 14 15 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 13 def attributes @attributes end |
#external_ids ⇒ Hash{String => String} (readonly)
Returns A map of external ids.
15 16 17 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 15 def external_ids @external_ids end |
#id ⇒ String (readonly)
Returns The ID of the vehicle.
17 18 19 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 17 def id @id end |
#name ⇒ String (readonly)
Returns The name of the vehicle.
19 20 21 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 19 def name @name end |
#serial ⇒ String (readonly)
Returns The serial number of the gateway installed on the asset.
21 22 23 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 21 def serial @serial end |
#static_assigned_driver ⇒ Samsara::Types::DriverObjectResponseBody (readonly)
23 24 25 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 23 def static_assigned_driver @static_assigned_driver end |
#tags ⇒ Object (readonly)
associated with the vehicle.
27 28 29 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 27 def end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::AlertObjectVehicleResponseBody
64 65 66 67 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 94 95 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 64 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"] unless parsed_json["staticAssignedDriver"].nil? static_assigned_driver = parsed_json["staticAssignedDriver"].to_json static_assigned_driver = Samsara::Types::DriverObjectResponseBody.from_json(json_object: static_assigned_driver) else static_assigned_driver = nil end = parsed_json["tags"]&.map do | item | item = item.to_json Samsara::Types::GoaTagTinyResponseResponseBody.from_json(json_object: item) end new( attributes: attributes, external_ids: external_ids, id: id, name: name, serial: serial, static_assigned_driver: static_assigned_driver, tags: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
108 109 110 111 112 113 114 115 116 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 108 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.static_assigned_driver.nil? || Samsara::Types::DriverObjectResponseBody.validate_raw(obj: obj.static_assigned_driver) obj.&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
99 100 101 |
# File 'lib/samsara_api/types/alert_object_vehicle_response_body.rb', line 99 def to_json @_field_set&.to_json end |