diff --git a/README.md b/README.md
index 63a3ccfe..d8c4f05c 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ const client = new smartcar.AuthClient({
// Redirect to Smartcar's authentication flow
app.get('/login', function(req, res) {
- const link = client.getAuthUrl({state: 'MY_STATE_PARAM'});
+ const link = client.getAuthUrl();
// redirect to the link
res.redirect(link);
diff --git a/doc/readme.md b/doc/readme.md
index c68c5101..377a18be 100644
--- a/doc/readme.md
+++ b/doc/readme.md
@@ -303,6 +303,7 @@ Error thrown when gateway to Smartcar times out
* [.getAuthUrl([options])](#AuthClient+getAuthUrl) ⇒ String
* [.exchangeCode(code)](#AuthClient+exchangeCode) ⇒ [Promise.<Access>
](#Access)
* [.exchangeRefreshToken(token)](#AuthClient+exchangeRefreshToken) ⇒ [Promise.<Access>
](#Access)
+ * [.compatibility(vin)](#AuthClient+compatibility) ⇒ Promise.<Boolean>
@@ -372,6 +373,19 @@ Exchange a refresh token for a new access object.
| --- | --- | --- |
| token | String
| Refresh token to exchange for a new set of Access and Refresh tokens. |
+
+
+### authClient.compatibility(vin) ⇒ Promise.<Boolean>
+Determine whether a vehicle is compatible with Smartcar
+
+**Kind**: instance method of [AuthClient
](#AuthClient)
+**Returns**: Promise.<Boolean>
- true if the vehicle is compatible
+with Smartcar
+
+| Param | Type | Description |
+| --- | --- | --- |
+| vin | String
| the VIN of the vehicle |
+
## Vehicle
diff --git a/lib/auth-client.js b/lib/auth-client.js
index 2293548b..6231ea07 100644
--- a/lib/auth-client.js
+++ b/lib/auth-client.js
@@ -202,4 +202,25 @@ AuthClient.prototype.exchangeRefreshToken = function(token) {
};
+/**
+ * Determine whether a vehicle is compatible with Smartcar
+ *
+ * @param {String} vin - the VIN of the vehicle
+ * @return {Promise.} true if the vehicle is compatible
+ * with Smartcar
+ */
+AuthClient.prototype.compatibility = function(vin) {
+
+ const qs = {vin};
+
+ return util.wrap(this.request.get({
+ baseUrl: config.api,
+ url: `v${config.version}/compatibility`,
+ qs,
+ }))
+ .then(function(response) {
+ return response.compatible;
+ });
+};
+
module.exports = AuthClient;
diff --git a/test/end-to-end/auth-client.js b/test/end-to-end/auth-client.js
index 1554c65f..38e82a7c 100644
--- a/test/end-to-end/auth-client.js
+++ b/test/end-to-end/auth-client.js
@@ -52,3 +52,16 @@ test('exchangeRefreshToken', async(t) => {
'refreshToken',
]), []);
});
+
+test('compatibility', async(t) => {
+ const client = new smartcar.AuthClient(getAuthClientParams());
+
+ const teslaVin = '5YJXCDE22HF068739';
+ const royceVin = 'SCA665C59HUX86700';
+
+ const teslaComp = await client.compatibility(teslaVin);
+ const royceComp = await client.compatibility(royceVin);
+
+ t.truthy(teslaComp);
+ t.falsy(royceComp);
+});
diff --git a/test/unit/lib/auth-client.js b/test/unit/lib/auth-client.js
index 466bfc27..4e37b8b9 100644
--- a/test/unit/lib/auth-client.js
+++ b/test/unit/lib/auth-client.js
@@ -342,3 +342,29 @@ test('exchangeRefreshToken', async function(t) {
t.true(n.isDone());
});
+
+test('compatibility', async function(t) {
+ const client = new AuthClient({
+ clientId: CLIENT_ID,
+ clientSecret: CLIENT_SECRET,
+ redirectUri: 'https://insurance.co/callback',
+ });
+
+ const vin = 'fake_vin';
+
+ const n = nock('https://api.smartcar.com')
+ .get('/v1.0/compatibility')
+ .query({vin})
+ .basicAuth({
+ user: CLIENT_ID,
+ pass: CLIENT_SECRET,
+ })
+ .reply(200, {
+ compatible: true,
+ });
+
+ const response = await client.compatibility(vin);
+
+ t.is(response, true);
+ t.true(n.isDone());
+});