Package com.smartcar.sdk
Class Vehicle
- java.lang.Object
-
- com.smartcar.sdk.Vehicle
-
public class Vehicle extends java.lang.ObjectSmartcar Vehicle API Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVehicle.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 VehicleAttributesattributes()Send request to the / endpointBatchResponsebatch(java.lang.String[] paths)Send request to the /batch endpointVehicleBatterybattery()Send request to the /battery endpointVehicleBatteryCapacitybatteryCapacity()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)VehicleChargecharge()Send request to the /charge endpointVehicleDiagnosticSystemStatusdiagnosticSystemStatus()Retrieves the diagnostic system status of the vehicle.VehicleDiagnosticTroubleCodesdiagnosticTroubleCodes()Retrieves the diagnostic trouble codes of the vehicle.DisconnectResponsedisconnect()Send request to the /disconnect endpointVehicleEngineOilengineOil()Send request to the /engine/oil endpointVehicleFuelfuel()Send request to the /fuel endpointVehicleChargeLimitgetChargeLimit()Get a vehicle's charge limitjava.lang.StringgetFlags()Gets the flags that are passed to the vehicle object as a serialized stringjava.lang.StringgetVersion()Gets the version of Smartcar API that this vehicle is usingVehicleLocationlocation()Send request to the /location endpointActionResponselock()Send request to the /security endpoint to lock a vehicleVehicleLockStatuslockStatus()Send request to the /security endpoint to get the vehicle's lock statusVehicleNominalCapacitynominalCapacity()Send request to the /battery/nominal_capacity endpointVehicleOdometerodometer()Send request to the /odometer endpointApplicationPermissionspermissions()Send request to the /permissions endpointApplicationPermissionspermissions(RequestPaging paging)Send request to the /permissions endpoint with paging options setVehicleResponserequest(SmartcarVehicleRequest vehicleRequest)General purpose method to make a request to a Smartcar endpoint - can be used to make requests to brand specific endpoints.ActionResponsesendDestination(double latitude, double longitude)Send request to the /navigation/destination endpoint to set the navigation destinationServiceHistoryserviceHistory()Overload without parameters to handle no input case, calling the full method with nullsServiceHistoryserviceHistory(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.ActionResponsesetChargeLimit(double limit)Set a vehicle's charge limitvoidsetUnitSystem(Vehicle.UnitSystem unitSystem)Sets the preferred unit system for subsequent API requests.ActionResponsestartCharge()Send request to the /charge endpoint to start charging a vehicleActionResponsestopCharge()Send request to the /charge endpoint to stop charging a vehicleWebhookSubscriptionsubscribe(java.lang.String webhookId)Subscribe vehicle to a webhookVehicleTirePressuretirePressure()Send request to the /tires/pressure endpointActionResponseunlock()Send request to the /security endpoint to unlock a vehicleUnsubscribeResponseunsubscribe(java.lang.String applicationManagementToken, java.lang.String webhookId)Unsubscribe vehicle from a webhookVehicleVinvin()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
-
-