From 1cb68a5fb948c012fa8c79d667ba1be0c4aa400e Mon Sep 17 00:00:00 2001 From: Adrian Garcia Jimenez Date: Fri, 25 Aug 2023 15:32:00 -0700 Subject: [PATCH] revert: Removing lock status (#165) revert(lock): Lock status commits This reverts commit 67763d413a950cf09e4bf2e6fb4a1e2de0d88f9d. This reverts commit 60290757c149c9b6b5238d48240cada7ae889e8b. --------- Co-authored-by: Adrian Garcia --- doc/readme.md | 100 ------------------------------------- lib/smartcar-service.js | 1 - lib/vehicle.js | 93 ---------------------------------- test/end-to-end/vehicle.js | 37 -------------- test/unit/lib/vehicle.js | 26 ---------- 5 files changed, 257 deletions(-) diff --git a/doc/readme.md b/doc/readme.md index 434cfe0..0c988bc 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -74,8 +74,6 @@ the following fields :

Odometer : Object
-
SecurityResponse : Object
-
Location : Object
Attributes : Object
@@ -628,7 +626,6 @@ Initializes a new Service object to make requests to the Smartcar API. * [.startCharge()](#Vehicle+startCharge) ⇒ [ActionResponse](#ActionResponse) * [.stopCharge()](#Vehicle+stopCharge) ⇒ [ActionResponse](#ActionResponse) * [.disconnect()](#Vehicle+disconnect) ⇒ [ActionResponse](#ActionResponse) - * [.lockStatus()](#Vehicle+lockStatus) ⇒ LockStatus @@ -983,19 +980,6 @@ to make requests to it again. for all possible errors. **See**: [Smartcar API Doc - Disconnect](https://smartcar.com/docs/api#delete-disconnect) - - -### vehicle.lockStatus() ⇒ LockStatus -Returns the lock status of the vehicle. - -**Kind**: instance method of [Vehicle](#Vehicle) -**Throws**: - -- [SmartcarError](#SmartcarError) - an instance of SmartcarError. - See the [errors section](https://github.com/smartcar/node-sdk/tree/master/doc#errors) - for all possible errors. - -**See**: [Smartcar API Doc - Lock Status](https://smartcar.com/docs/api#get-security) ## METHODS\_MAP : object.<String, Object> @@ -1333,90 +1317,6 @@ the following fields : } } ``` - - -## SecurityResponse : Object -**Kind**: global typedef -**Properties** - -| Name | Type | Description | -| --- | --- | --- | -| isLocked | Boolean | Whether the vehicle is locked or not. | -| doors | Array | The status of each of the vehicle's doors. | -| windows | Array | The status of each of the vehicle's windows. | -| sunroof | Array | The status of each of the vehicle's sunroof. | -| storage | Array | The status of each of the vehicle's storage. | -| chargingPort | Array | The status of each of the vehicle's chargingPort. | -| meta | [Meta](#Meta) | | - -**Example** -```js -{ - isLocked: true, - doors: [ - { - type: 'frontLeft', - status: 'LOCKED', - }, - { - type: 'frontRight', - status: 'LOCKED', - }, - { - type: 'backLeft', - status: 'LOCKED', - }, - { - type: 'backRight', - status: 'LOCKED', - }, - ], - windows: [ - { - type: 'frontLeft', - status: 'CLOSED', - }, - { - type: 'frontRight', - status: 'CLOSED', - }, - { - type: 'backLeft', - status: 'CLOSED', - }, - { - type: 'backRight', - status: 'CLOSED', - }, - ], - sunroof: [ - { - type: 'sunroof', - status: 'CLOSED', - }, - ], - storage: [ - { - type: 'rear', - status: 'CLOSED', - }, - { - type: 'front', - status: 'CLOSED', - }, - ], - chargingPort: [ - { - type: 'chargingPort', - status: 'CLOSED', - }, - ], - meta: { - dataAge: new Date('2018-05-04T07:20:50.844Z'), - requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f', - }, -} -``` ## Location : Object diff --git a/lib/smartcar-service.js b/lib/smartcar-service.js index 7e91b14..206d917 100644 --- a/lib/smartcar-service.js +++ b/lib/smartcar-service.js @@ -35,7 +35,6 @@ const getNameFromPath = (path) => { // '/' should have a method name of 'attributes' // '/tires/pressure' should be tirePressure and NOT tiresPressure const BATCH_PATH_TO_ATTRIBUTE = { - '/security': 'lockStatus', '/tires/pressure': 'tirePressure', '/': 'attributes', }; diff --git a/lib/vehicle.js b/lib/vehicle.js index 6cad6ad..ddeb2e4 100644 --- a/lib/vehicle.js +++ b/lib/vehicle.js @@ -31,7 +31,6 @@ const METHODS_MAP = { startCharge: {requestType: 'post', path: 'charge', body: {action: 'START'}}, stopCharge: {requestType: 'post', path: 'charge', body: {action: 'STOP'}}, disconnect: {requestType: 'delete', path: 'application'}, - lockStatus: {path: 'security'}, }; /** @exports Vehicle */ @@ -596,86 +595,6 @@ Vehicle.prototype.request = async function( * } * } */ - -/** - * @type {Object} - * @typedef SecurityResponse - * @property {Boolean} isLocked - Whether the vehicle is locked or not. - * @property {Array} doors - The status of each of the vehicle's doors. - * @property {Array} windows - The status of each of the vehicle's windows. - * @property {Array} sunroof - The status of each of the vehicle's sunroof. - * @property {Array} storage - The status of each of the vehicle's storage. - * @property {Array} chargingPort - The status of each of the vehicle's chargingPort. - * @property {Meta} meta - * - * @example - * { - * isLocked: true, - * doors: [ - * { - * type: 'frontLeft', - * status: 'LOCKED', - * }, - * { - * type: 'frontRight', - * status: 'LOCKED', - * }, - * { - * type: 'backLeft', - * status: 'LOCKED', - * }, - * { - * type: 'backRight', - * status: 'LOCKED', - * }, - * ], - * windows: [ - * { - * type: 'frontLeft', - * status: 'CLOSED', - * }, - * { - * type: 'frontRight', - * status: 'CLOSED', - * }, - * { - * type: 'backLeft', - * status: 'CLOSED', - * }, - * { - * type: 'backRight', - * status: 'CLOSED', - * }, - * ], - * sunroof: [ - * { - * type: 'sunroof', - * status: 'CLOSED', - * }, - * ], - * storage: [ - * { - * type: 'rear', - * status: 'CLOSED', - * }, - * { - * type: 'front', - * status: 'CLOSED', - * }, - * ], - * chargingPort: [ - * { - * type: 'chargingPort', - * status: 'CLOSED', - * }, - * ], - * meta: { - * dataAge: new Date('2018-05-04T07:20:50.844Z'), - * requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f', - * }, - * } - */ - /** * @name Vehicle#odometer * @function @@ -828,16 +747,4 @@ Vehicle.prototype.request = async function( * for all possible errors. */ -/** - * @name Vehicle#lockStatus - * @function - * @memberof Vehicle - * @description Returns the lock status of the vehicle. - * @see {@link https://smartcar.com/docs/api#get-security|Smartcar API Doc - Lock Status} - * @return {LockStatus} - * @throws {SmartcarError} - an instance of SmartcarError. - * See the [errors section](https://github.com/smartcar/node-sdk/tree/master/doc#errors) - * for all possible errors. - */ - module.exports = Vehicle; diff --git a/test/end-to-end/vehicle.js b/test/end-to-end/vehicle.js index deb2036..925cc2f 100644 --- a/test/end-to-end/vehicle.js +++ b/test/end-to-end/vehicle.js @@ -25,7 +25,6 @@ test.before(async(t) => { getVehicle('FORD', [ 'required:control_charge', 'required:control_security', - 'required:read_security', ]), getVehicle('KIA', [ 'required:read_charge', @@ -313,22 +312,6 @@ test('vehicle unlock', async(t) => { t.is(response.meta.requestId.length, 36); }); -test('vehicle read security', async(t) => { - const response = await t.context.ford.lockStatus(); - t.deepEqual( - _.xor(_.keys(response), [ - 'isLocked', - 'doors', - 'windows', - 'sunroof', - 'storage', - 'chargingPort', - 'meta', - ]), - [], - ); -}); - test('vehicle startCharge', async(t) => { const response = await t.context.ford.startCharge(); t.deepEqual( @@ -394,26 +377,6 @@ test('vehicle batch', async(t) => { t.is(location.meta.requestId.length, 36); }); -test('vehicle batch - security', async(t) => { - const response = await t.context.ford.batch([ - '/security', - ]); - - const lockStatus = response.lockStatus(); - t.deepEqual( - _.xor(_.keys(lockStatus), [ - 'isLocked', - 'doors', - 'windows', - 'sunroof', - 'storage', - 'chargingPort', - 'meta', - ]), - [], - ); -}); - test('vehicle request - odometer', async(t) => { const response = await t.context.volt.request( 'get', diff --git a/test/unit/lib/vehicle.js b/test/unit/lib/vehicle.js index cd9ed0c..ddf38c4 100644 --- a/test/unit/lib/vehicle.js +++ b/test/unit/lib/vehicle.js @@ -350,29 +350,3 @@ test('request - set charge limit', async function(t) { ); t.true(t.context.n.isDone()); }); - -test('request - security', async function(t) { - sinon.restore(); // clear all spys - - t.context.n = nocks - .base() - .get('/security') - .reply(200, - { - isLocked: true, - doors: [], - windows: [], - storage: [], - sunroof: [], - chargingPort: [], - }, {'sc-request-id': 'requestId'}); - - const serviceRequestSpy = sinon.spy(vehicle.service, 'request'); - - const response = await vehicle.lockStatus(); - - t.true(serviceRequestSpy.calledOnceWith('get', 'security')); - t.is(response.meta.requestId, 'requestId'); - t.is(response.isLocked, true); - t.true(t.context.n.isDone()); -});