Class: Samsara::AsyncVehiclesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/vehicles/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Samsara::AsyncVehiclesClient

Parameters:



434
435
436
437
438
439
# File 'lib/samsara_api/vehicles/client.rb', line 434

def initialize(request_client:)
  @request_client = request_client
  @immobilizer = Samsara::Vehicles::AsyncImmobilizerClient.new(request_client: request_client)
  @locations = Samsara::Vehicles::AsyncLocationsClient.new(request_client: request_client)
  @stats = Samsara::Vehicles::AsyncStatsClient.new(request_client: request_client)
end

Instance Attribute Details

#immobilizer ⇒ Samsara::Vehicles::ImmobilizerClient (readonly)



425
426
427
# File 'lib/samsara_api/vehicles/client.rb', line 425

def immobilizer
  @immobilizer
end

#locations ⇒ Samsara::Vehicles::LocationsClient (readonly)



427
428
429
# File 'lib/samsara_api/vehicles/client.rb', line 427

def locations
  @locations
end

#request_client ⇒ Samsara::AsyncRequestClient (readonly)



423
424
425
# File 'lib/samsara_api/vehicles/client.rb', line 423

def request_client
  @request_client
end

#stats ⇒ Samsara::Vehicles::StatsClient (readonly)



429
430
431
# File 'lib/samsara_api/vehicles/client.rb', line 429

def stats
  @stats
end

Instance Method Details

#get(id:, request_options: nil) ⇒ Object

api.vehicles.get(id: "id")



538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/samsara_api/vehicles/client.rb', line 538

def get(id:, request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/fleet/vehicles/#{id}"
end
    Samsara::Types::VehicleResponse.from_json(json_object: response.body)
  end
end

#list(limit: nil, after: nil, parent_tag_ids: nil, tag_ids: nil, attribute_value_ids: nil, attributes: nil, updated_after_time: nil, created_after_time: nil, request_options: nil) ⇒ Object

api.vehicles.list



491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/samsara_api/vehicles/client.rb', line 491

def list(limit: nil, after: nil, parent_tag_ids: nil, tag_ids: nil, attribute_value_ids: nil, attributes: nil, updated_after_time: nil, created_after_time: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "after": after, "parentTagIds": parent_tag_ids, "tagIds": tag_ids, "attributeValueIds": attribute_value_ids, "attributes": attributes, "updatedAfterTime": updated_after_time, "createdAfterTime": created_after_time }.compact
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/fleet/vehicles"
end
    Samsara::Types::VehiclesListVehiclesResponseBody.from_json(json_object: response.body)
  end
end

#update(id:, attributes: nil, aux_input_type_1: nil, aux_input_type_10: nil, aux_input_type_11: nil, aux_input_type_12: nil, aux_input_type_13: nil, aux_input_type_2: nil, aux_input_type_3: nil, aux_input_type_4: nil, aux_input_type_5: nil, aux_input_type_6: nil, aux_input_type_7: nil, aux_input_type_8: nil, aux_input_type_9: nil, engine_hours: nil, external_ids: nil, gateway_serial: nil, gross_vehicle_weight: nil, harsh_acceleration_setting_type: nil, license_plate: nil, name: nil, notes: nil, odometer_meters: nil, static_assigned_driver_id: nil, tag_ids: nil, vehicle_regulation_mode: nil, vehicle_type: nil, vin: nil, request_options: nil) ⇒ Object

api.vehicles.update(id: "id")



797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
# File 'lib/samsara_api/vehicles/client.rb', line 797

def update(id:, attributes: nil, aux_input_type_1: nil, aux_input_type_10: nil, aux_input_type_11: nil, aux_input_type_12: nil, aux_input_type_13: nil, aux_input_type_2: nil, aux_input_type_3: nil, aux_input_type_4: nil, aux_input_type_5: nil, aux_input_type_6: nil, aux_input_type_7: nil, aux_input_type_8: nil, aux_input_type_9: nil, engine_hours: nil, external_ids: nil, gateway_serial: nil, gross_vehicle_weight: nil, harsh_acceleration_setting_type: nil, license_plate: nil, name: nil, notes: nil, odometer_meters: nil, static_assigned_driver_id: nil, tag_ids: nil, vehicle_regulation_mode: nil, vehicle_type: nil, vin: nil, request_options: nil)
  Async do
    response = @request_client.conn.patch do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), attributes: attributes, auxInputType1: aux_input_type_1, auxInputType10: aux_input_type_10, auxInputType11: aux_input_type_11, auxInputType12: aux_input_type_12, auxInputType13: aux_input_type_13, auxInputType2: aux_input_type_2, auxInputType3: aux_input_type_3, auxInputType4: aux_input_type_4, auxInputType5: aux_input_type_5, auxInputType6: aux_input_type_6, auxInputType7: aux_input_type_7, auxInputType8: aux_input_type_8, auxInputType9: aux_input_type_9, engineHours: engine_hours, externalIds: external_ids, gatewaySerial: gateway_serial, grossVehicleWeight: gross_vehicle_weight, harshAccelerationSettingType: harsh_acceleration_setting_type, licensePlate: license_plate, name: name, notes: notes, odometerMeters: odometer_meters, staticAssignedDriverId: static_assigned_driver_id, tagIds: tag_ids, vehicleRegulationMode: vehicle_regulation_mode, vehicleType: vehicle_type, vin: vin }.compact
  req.url "#{@request_client.get_url(request_options: request_options)}/fleet/vehicles/#{id}"
end
    Samsara::Types::VehicleResponse.from_json(json_object: response.body)
  end
end