Package com.smartcar.sdk
Class Smartcar
- java.lang.Object
-
- com.smartcar.sdk.Smartcar
-
public class Smartcar extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
API_ORIGIN
static java.lang.String
API_VERSION
static java.lang.String
MANAGEMENT_API_ORIGIN
-
Constructor Summary
Constructors Constructor Description Smartcar()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DeleteConnections
deleteConnections(java.lang.String applicationManagementToken, ConnectionsFilter filter)
Deletes all the connections by vehicle or user ID and returns a list of all connections that were deleted.static Compatibility
getCompatibility(SmartcarCompatibilityRequest compatibilityRequest)
Determine if a vehicle is compatible with the Smartcar API and the provided permissions for the specified country.static GetConnections
getConnections(java.lang.String applicationManagementToken)
Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.static GetConnections
getConnections(java.lang.String applicationManagementToken, ConnectionsFilter filter)
Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.static GetConnections
getConnections(java.lang.String applicationManagementToken, ConnectionsFilter filter, RequestPagingCursor paging)
Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.static User
getUser(java.lang.String accessToken)
Retrieves the user ID of the user authenticated with the specified access token.static VehicleIds
getVehicles(java.lang.String accessToken)
Retrieves all vehicle IDs associated with the authenticated user.static VehicleIds
getVehicles(java.lang.String accessToken, RequestPaging paging)
Retrieves all vehicles associated with the authenticated user.static java.lang.String
hashChallenge(java.lang.String key, java.lang.String challenge)
Performs a HmacSHA256 hash on a challenge string using the key providedstatic boolean
isExpired(java.util.Date expiration)
Convenience method for determining if an auth token expiration has passed.static void
setApiVersion(java.lang.String version)
Sets the Smartcar API versionstatic boolean
verifyPayload(java.lang.String applicationManagementToken, java.lang.String signature, java.lang.String payload)
Verifies as HmacSHA256 signature
-
-
-
Method Detail
-
setApiVersion
public static void setApiVersion(java.lang.String version)
Sets the Smartcar API version- Parameters:
version
- API version to set
-
getUser
public static User getUser(java.lang.String accessToken) throws SmartcarException
Retrieves the user ID of the user authenticated with the specified access token.- Parameters:
accessToken
- a valid access token- Returns:
- the corresponding user
- Throws:
SmartcarException
- if the request is unsuccessful
-
getVehicles
public static VehicleIds getVehicles(java.lang.String accessToken, RequestPaging paging) throws SmartcarException
Retrieves all vehicles associated with the authenticated user.- Parameters:
accessToken
- a valid access tokenpaging
- paging parameters- Returns:
- the requested vehicle IDs
- Throws:
SmartcarException
- if the request is unsuccessful
-
getVehicles
public static VehicleIds getVehicles(java.lang.String accessToken) throws SmartcarException
Retrieves all vehicle IDs associated with the authenticated user.- Parameters:
accessToken
- a valid access token- Returns:
- the requested vehicle IDs
- Throws:
SmartcarException
- if the request is unsuccessful
-
isExpired
public static boolean isExpired(java.util.Date expiration)
Convenience method for determining if an auth token expiration has passed.- Parameters:
expiration
- the expiration date of the token- Returns:
- whether the token has expired
-
getCompatibility
public static Compatibility getCompatibility(SmartcarCompatibilityRequest compatibilityRequest) throws SmartcarException
Determine if a vehicle is compatible with the Smartcar API and the provided permissions for the specified country. A compatible vehicle is a vehicle that:- has the hardware required for internet connectivity,
- belongs to the makes and models Smartcar supports, and
- supports the permissions.
- Parameters:
compatibilityRequest
- with options for this request. See Smartcar.SmartcarCompatibilityRequest- Returns:
- A Compatibility object with isCompatible set to false if the vehicle is not compatible in the specified country and true if the vehicle is likely compatible.
- Throws:
SmartcarException
- when the request is unsuccessful
-
hashChallenge
public static java.lang.String hashChallenge(java.lang.String key, java.lang.String challenge) throws SmartcarException
Performs a HmacSHA256 hash on a challenge string using the key provided- Parameters:
key
-challenge
-- Returns:
- String digest
- Throws:
SmartcarException
-
verifyPayload
public static boolean verifyPayload(java.lang.String applicationManagementToken, java.lang.String signature, java.lang.String payload) throws SmartcarException
Verifies as HmacSHA256 signature- Parameters:
applicationManagementToken
-signature
-payload
-- Returns:
- boolean whether the signature was verified
- Throws:
SmartcarException
-
getConnections
public static GetConnections getConnections(java.lang.String applicationManagementToken, ConnectionsFilter filter, RequestPagingCursor paging) throws SmartcarException
Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.- Parameters:
applicationManagementToken
-filter
-paging
-- Returns:
- connections
- Throws:
SmartcarException
- if the request is unsuccessful
-
getConnections
public static GetConnections getConnections(java.lang.String applicationManagementToken, ConnectionsFilter filter) throws SmartcarException
Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.- Parameters:
applicationManagementToken
-filter
-- Throws:
SmartcarException
- if the request is unsuccessful
-
getConnections
public static GetConnections getConnections(java.lang.String applicationManagementToken) throws SmartcarException
Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.- Parameters:
applicationManagementToken
-- Throws:
SmartcarException
- if the request is unsuccessful
-
deleteConnections
public static DeleteConnections deleteConnections(java.lang.String applicationManagementToken, ConnectionsFilter filter) throws SmartcarException
Deletes all the connections by vehicle or user ID and returns a list of all connections that were deleted.- Parameters:
applicationManagementToken
-filter
-- Returns:
- connections
- Throws:
SmartcarException
- if the request is unsuccessful
-
-