Package com.smartcar.sdk
Class Vehicle
- java.lang.Object
-
- com.smartcar.sdk.Vehicle
-
public class Vehicle extends java.lang.Object
Smartcar Vehicle API Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Vehicle.UnitSystem
-
Constructor Summary
Constructors Constructor Description Vehicle(java.lang.String vehicleId, java.lang.String accessToken)
Initializes a new Vehicle.Vehicle(java.lang.String vehicleId, java.lang.String accessToken, SmartcarVehicleOptions options)
Initializes a new Vehicle with provided options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VehicleAttributes
attributes()
Send request to the / endpointBatchResponse
batch(java.lang.String[] paths)
Send request to the /batch endpointVehicleBattery
battery()
Send request to the /battery endpointVehicleBatteryCapacity
batteryCapacity()
Send request to the /battery/capacity endpointprotected <T extends ApiData>
Tcall(java.lang.String path, java.lang.String method, okhttp3.RequestBody body, java.lang.Class<T> type)
protected <T extends ApiData>
Tcall(java.lang.String path, java.lang.String method, okhttp3.RequestBody body, java.lang.String accessToken, java.lang.Class<T> type)
Executes an API request under the VehicleIds endpoint.protected <T extends ApiData>
Tcall(java.lang.String path, java.lang.String method, okhttp3.RequestBody body, java.util.Map<java.lang.String,java.lang.String> query, java.lang.Class<T> type)
VehicleCharge
charge()
Send request to the /charge endpointVehicleDiagnosticSystemStatus
diagnosticSystemStatus()
Retrieves the diagnostic system status of the vehicle.VehicleDiagnosticTroubleCodes
diagnosticTroubleCodes()
Retrieves the diagnostic trouble codes of the vehicle.DisconnectResponse
disconnect()
Send request to the /disconnect endpointVehicleEngineOil
engineOil()
Send request to the /engine/oil endpointVehicleFuel
fuel()
Send request to the /fuel endpointVehicleChargeLimit
getChargeLimit()
Get a vehicle's charge limitjava.lang.String
getFlags()
Gets the flags that are passed to the vehicle object as a serialized stringjava.lang.String
getVersion()
Gets the version of Smartcar API that this vehicle is usingVehicleLocation
location()
Send request to the /location endpointActionResponse
lock()
Send request to the /security endpoint to lock a vehicleVehicleLockStatus
lockStatus()
Send request to the /security endpoint to get the vehicle's lock statusVehicleNominalCapacity
nominalCapacity()
Send request to the /battery/nominal_capacity endpointVehicleOdometer
odometer()
Send request to the /odometer endpointApplicationPermissions
permissions()
Send request to the /permissions endpointApplicationPermissions
permissions(RequestPaging paging)
Send request to the /permissions endpoint with paging options setVehicleResponse
request(SmartcarVehicleRequest vehicleRequest)
General purpose method to make a request to a Smartcar endpoint - can be used to make requests to brand specific endpoints.ActionResponse
sendDestination(double latitude, double longitude)
Send request to the /navigation/destination endpoint to set the navigation destinationServiceHistory
serviceHistory()
Overload without parameters to handle no input case, calling the full method with nullsServiceHistory
serviceHistory(java.time.OffsetDateTime startDate, java.time.OffsetDateTime endDate)
Returns a list of all the service records performed on the vehicle, filtered by the optional date range.ActionResponse
setChargeLimit(double limit)
Set a vehicle's charge limitvoid
setUnitSystem(Vehicle.UnitSystem unitSystem)
Sets the preferred unit system for subsequent API requests.ActionResponse
startCharge()
Send request to the /charge endpoint to start charging a vehicleActionResponse
stopCharge()
Send request to the /charge endpoint to stop charging a vehicleWebhookSubscription
subscribe(java.lang.String webhookId)
Subscribe vehicle to a webhookVehicleTirePressure
tirePressure()
Send request to the /tires/pressure endpointActionResponse
unlock()
Send request to the /security endpoint to unlock a vehicleUnsubscribeResponse
unsubscribe(java.lang.String applicationManagementToken, java.lang.String webhookId)
Unsubscribe vehicle from a webhookVehicleVin
vin()
Send request to the /vin endpoint
-
-
-
Constructor Detail
-
Vehicle
public Vehicle(java.lang.String vehicleId, java.lang.String accessToken)
Initializes a new Vehicle.- Parameters:
vehicleId
- the vehicle IDaccessToken
- the OAuth 2.0 access token
-
Vehicle
public Vehicle(java.lang.String vehicleId, java.lang.String accessToken, SmartcarVehicleOptions options)
Initializes a new Vehicle with provided options- Parameters:
vehicleId
- vehicleId the vehicle IDaccessToken
- accessToken the OAuth 2.0 access tokenoptions
- optional arguments provided with a SmartcarVehicleOptions instance
-
-
Method Detail
-
getVersion
public java.lang.String getVersion()
Gets the version of Smartcar API that this vehicle is using- Returns:
- String representing version
-
getFlags
public java.lang.String getFlags()
Gets the flags that are passed to the vehicle object as a serialized string- Returns:
- serialized string of the flags
-
call
protected <T extends ApiData> T call(java.lang.String path, java.lang.String method, okhttp3.RequestBody body, java.lang.String accessToken, java.lang.Class<T> type) throws SmartcarException
Executes an API request under the VehicleIds endpoint.- Parameters:
path
- the path to the sub-endpointmethod
- the method of the requestbody
- the body of the requesttype
- the type into which the response will be parsed- Returns:
- the parsed response
- Throws:
SmartcarException
- if the request is unsuccessful
-
call
protected <T extends ApiData> T call(java.lang.String path, java.lang.String method, okhttp3.RequestBody body, java.lang.Class<T> type) throws SmartcarException
- Throws:
SmartcarException
-
call
protected <T extends ApiData> T call(java.lang.String path, java.lang.String method, okhttp3.RequestBody body, java.util.Map<java.lang.String,java.lang.String> query, java.lang.Class<T> type) throws SmartcarException
- Throws:
SmartcarException
-
attributes
public VehicleAttributes attributes() throws SmartcarException
Send request to the / endpoint- Returns:
- VehicleInfo object
- Throws:
SmartcarException
- if the request is unsuccessful
-
vin
public VehicleVin vin() throws SmartcarException
Send request to the /vin endpoint- Returns:
- the vin of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
permissions
public ApplicationPermissions permissions() throws SmartcarException
Send request to the /permissions endpoint- Returns:
- the permission of the application
- Throws:
SmartcarException
- if the request is unsuccessful
-
permissions
public ApplicationPermissions permissions(RequestPaging paging) throws SmartcarException
Send request to the /permissions endpoint with paging options set- Parameters:
paging
- Request paging options- Returns:
- the permissons of the application
- Throws:
SmartcarException
- if the request is unsuccessful
-
disconnect
public DisconnectResponse disconnect() throws SmartcarException
Send request to the /disconnect endpoint- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessful
-
odometer
public VehicleOdometer odometer() throws SmartcarException
Send request to the /odometer endpoint- Returns:
- the odometer of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
serviceHistory
public ServiceHistory serviceHistory(java.time.OffsetDateTime startDate, java.time.OffsetDateTime endDate) throws SmartcarException, java.io.UnsupportedEncodingException
Returns a list of all the service records performed on the vehicle, filtered by the optional date range. If no dates are specified, records from the last year are returned.- Parameters:
startDate
- the start date of the period to retrieve records from (inclusive)endDate
- the end date of the period to retrieve records until (inclusive)- Returns:
- service history records
- Throws:
SmartcarException
- if the request is unsuccessfuljava.io.UnsupportedEncodingException
-
serviceHistory
public ServiceHistory serviceHistory() throws SmartcarException, java.io.UnsupportedEncodingException
Overload without parameters to handle no input case, calling the full method with nulls- Returns:
- service history records
- Throws:
SmartcarException
- if the request is unsuccessfuljava.io.UnsupportedEncodingException
-
diagnosticSystemStatus
public VehicleDiagnosticSystemStatus diagnosticSystemStatus() throws SmartcarException
Retrieves the diagnostic system status of the vehicle.- Returns:
- the diagnostic system status of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
diagnosticTroubleCodes
public VehicleDiagnosticTroubleCodes diagnosticTroubleCodes() throws SmartcarException
Retrieves the diagnostic trouble codes of the vehicle.- Returns:
- the diagnostic trouble codes of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
fuel
public VehicleFuel fuel() throws SmartcarException
Send request to the /fuel endpoint- Returns:
- the fuel status of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
engineOil
public VehicleEngineOil engineOil() throws SmartcarException
Send request to the /engine/oil endpoint- Returns:
- the engine oil status of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
tirePressure
public VehicleTirePressure tirePressure() throws SmartcarException
Send request to the /tires/pressure endpoint- Returns:
- the tire pressure status of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
battery
public VehicleBattery battery() throws SmartcarException
Send request to the /battery endpoint- Returns:
- the battery status of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
batteryCapacity
public VehicleBatteryCapacity batteryCapacity() throws SmartcarException
Send request to the /battery/capacity endpoint- Returns:
- the battery capacity of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
nominalCapacity
public VehicleNominalCapacity nominalCapacity() throws SmartcarException
Send request to the /battery/nominal_capacity endpoint- Returns:
- Returns a list of nominal rated battery capacities for a vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
getChargeLimit
public VehicleChargeLimit getChargeLimit() throws SmartcarException
Get a vehicle's charge limit- Returns:
- the charge limit of the vehicle as a float value between 0 and 1.
- Throws:
SmartcarException
- if the request is unsuccessful
-
setChargeLimit
public ActionResponse setChargeLimit(double limit) throws SmartcarException
Set a vehicle's charge limit- Parameters:
limit
- the new charge limit to set.- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessful
-
charge
public VehicleCharge charge() throws SmartcarException
Send request to the /charge endpoint- Returns:
- the charge status of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
location
public VehicleLocation location() throws SmartcarException
Send request to the /location endpoint- Returns:
- the location of the vehicle
- Throws:
SmartcarException
- if the request is unsuccessful
-
unlock
public ActionResponse unlock() throws SmartcarException
Send request to the /security endpoint to unlock a vehicle- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessful
-
lock
public ActionResponse lock() throws SmartcarException
Send request to the /security endpoint to lock a vehicle- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessful
-
startCharge
public ActionResponse startCharge() throws SmartcarException
Send request to the /charge endpoint to start charging a vehicle- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessful
-
stopCharge
public ActionResponse stopCharge() throws SmartcarException
Send request to the /charge endpoint to stop charging a vehicle- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessful
-
lockStatus
public VehicleLockStatus lockStatus() throws SmartcarException
Send request to the /security endpoint to get the vehicle's lock status- Returns:
- VehicleLockStatus
- Throws:
SmartcarException
-
sendDestination
public ActionResponse sendDestination(double latitude, double longitude) throws SmartcarException
Send request to the /navigation/destination endpoint to set the navigation destination- Parameters:
latitude
- A double representing the destination's latitudelongitude
- A double representing the destination's longitude- Returns:
- a response indicating success
- Throws:
SmartcarException
- if the request is unsuccessfuljava.lang.IllegalArgumentException
- if the latitude is not between -90.0 and 90.0 or if the longitude is not between -180.0 and 180.0
-
subscribe
public WebhookSubscription subscribe(java.lang.String webhookId) throws SmartcarException
Subscribe vehicle to a webhook- Returns:
- information about the webhook and vehicle subscription
- Throws:
SmartcarException
- if the request is unsuccessful
-
unsubscribe
public UnsubscribeResponse unsubscribe(java.lang.String applicationManagementToken, java.lang.String webhookId) throws SmartcarException
Unsubscribe vehicle from a webhook- Returns:
- response indicating successful removal from the subscription
- Throws:
SmartcarException
- if the request is unsuccessful
-
batch
public BatchResponse batch(java.lang.String[] paths) throws SmartcarException
Send request to the /batch endpoint- Parameters:
paths
- the paths of endpoints to send requests to (ex. "/odometer", "/location", ...)- Returns:
- the BatchResponse object containing the response from all the requested endpoints
- Throws:
SmartcarException
- if the request is unsuccessful
-
request
public VehicleResponse request(SmartcarVehicleRequest vehicleRequest) throws SmartcarException, java.io.IOException
General purpose method to make a request to a Smartcar endpoint - can be used to make requests to brand specific endpoints.- Parameters:
vehicleRequest
- with options for this request. See Smartcar.SmartcarVehicleRequest- Returns:
- the VehicleResponse object containing the response from the requested endpoint
- Throws:
SmartcarException
- if the request is unsuccessfuljava.io.IOException
-
setUnitSystem
public void setUnitSystem(Vehicle.UnitSystem unitSystem)
Sets the preferred unit system for subsequent API requests.- Parameters:
unitSystem
- the desired unit system
-
-