Class: Samsara::Types::VehicleResponseResponseBody

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

Overview

A vehicle object

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset_type: OMIT, external_ids: OMIT, id: OMIT, license_plate: OMIT, name: OMIT, vehicle_vin: OMIT, additional_properties: nil) ⇒ Samsara::Types::VehicleResponseResponseBody

Parameters:

  • external_ids (Hash{String => String}) (defaults to: OMIT)

    A map of external ids

  • id (String) (defaults to: OMIT)

    ID of the vehicle

  • license_plate (String) (defaults to: OMIT)

    The license plate of the vehicle.

  • name (String) (defaults to: OMIT)

    Name of the vehicle

  • vehicle_vin (String) (defaults to: OMIT)

    The VIN of the vehicle.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 40

def initialize(asset_type: OMIT, external_ids: OMIT, id: OMIT, license_plate: OMIT, name: OMIT, vehicle_vin: OMIT, additional_properties: nil)
  @asset_type = asset_type if asset_type != OMIT
  @external_ids = external_ids if external_ids != OMIT
  @id = id if id != OMIT
  @license_plate = license_plate if license_plate != OMIT
  @name = name if name != OMIT
  @vehicle_vin = vehicle_vin if vehicle_vin != OMIT
  @additional_properties = additional_properties
  @_field_set = { "assetType": asset_type, "externalIds": external_ids, "id": id, "licensePlate": license_plate, "name": name, "vehicleVin": vehicle_vin }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



24
25
26
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 24

def additional_properties
  @additional_properties
end

#asset_typeObject (readonly)

‘unpowered`, `vehicle`



12
13
14
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 12

def asset_type
  @asset_type
end

#external_idsHash{String => String} (readonly)

Returns A map of external ids.

Returns:

  • (Hash{String => String})

    A map of external ids



14
15
16
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 14

def external_ids
  @external_ids
end

#idString (readonly)

Returns ID of the vehicle.

Returns:

  • (String)

    ID of the vehicle



16
17
18
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 16

def id
  @id
end

#license_plateString (readonly)

Returns The license plate of the vehicle.

Returns:

  • (String)

    The license plate of the vehicle.



18
19
20
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 18

def license_plate
  @license_plate
end

#nameString (readonly)

Returns Name of the vehicle.

Returns:

  • (String)

    Name of the vehicle



20
21
22
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 20

def name
  @name
end

#vehicle_vinString (readonly)

Returns The VIN of the vehicle.

Returns:

  • (String)

    The VIN of the vehicle.



22
23
24
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 22

def vehicle_vin
  @vehicle_vin
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 56

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  asset_type = parsed_json["assetType"]
  external_ids = parsed_json["externalIds"]
  id = parsed_json["id"]
  license_plate = parsed_json["licensePlate"]
  name = parsed_json["name"]
  vehicle_vin = parsed_json["vehicleVin"]
  new(
    asset_type: asset_type,
    external_ids: external_ids,
    id: id,
    license_plate: license_plate,
    name: name,
    vehicle_vin: vehicle_vin,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


87
88
89
90
91
92
93
94
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 87

def self.validate_raw(obj:)
  obj.asset_type&.is_a?(Samsara::Types::VehicleResponseResponseBodyAssetType) != false || raise("Passed value for field obj.asset_type 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.license_plate&.is_a?(String) != false || raise("Passed value for field obj.license_plate 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.vehicle_vin&.is_a?(String) != false || raise("Passed value for field obj.vehicle_vin is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


78
79
80
# File 'lib/samsara_api/types/vehicle_response_response_body.rb', line 78

def to_json
  @_field_set&.to_json
end