From f54356076ac9d9e4f517ea8c16de522aca233f47 Mon Sep 17 00:00:00 2001 From: Emre Sonmez Date: Mon, 16 Apr 2018 19:58:13 -0700 Subject: [PATCH] feat(endpoints): trim down endpoints to limited endpoint set BREAKING CHANGE: This removes all endpoints from the Smartcar Node SDK and limits our endpoint set to: info, vin, permissions, disconnect, odometer, location, lock, and unlock. --- doc/index.md | 768 +------------------- lib/vehicle.js | 965 +------------------------- test/lib/vehicle-api-param-methods.js | 195 ------ test/lib/vehicle.js | 18 +- 4 files changed, 17 insertions(+), 1929 deletions(-) delete mode 100644 test/lib/vehicle-api-param-methods.js diff --git a/doc/index.md b/doc/index.md index dc269337..1d884b83 100644 --- a/doc/index.md +++ b/doc/index.md @@ -187,7 +187,7 @@ Error thrown when an application makes too many requests and is throttled. ### errors.MonthlyLimitExceeded(message) ⇐ SmartcarError -Error thrown when an application requests more resources than it's allowed +Error thrown when an application requests more resources than its allowed limit, e.g., gone over their allotted monthly request limit. **Kind**: static method of [errors](#module_errors) @@ -224,6 +224,8 @@ Error thrown when vehicle is not capable of performing the method. ### errors.GatewayTimeoutError(message) +Error thrown when gateway to Smartcar times out + **Kind**: static method of [errors](#module_errors) | Param | Description | @@ -313,99 +315,11 @@ Exchange a refresh token for a new access object. * [.disconnect()](#Vehicle+disconnect) ⇒ [Promise](#Promise) * [.permissions()](#Vehicle+permissions) ⇒ [Promise](#Promise) * [.info()](#Vehicle+info) ⇒ [Promise](#Promise) - * [.accelerometer()](#Vehicle+accelerometer) ⇒ [Promise](#Promise) - * [.airbags()](#Vehicle+airbags) ⇒ [Promise](#Promise) - * [.barometer()](#Vehicle+barometer) ⇒ [Promise](#Promise) - * [.battery()](#Vehicle+battery) ⇒ [Promise](#Promise) - * [.charge()](#Vehicle+charge) ⇒ [Promise](#Promise) - * [.chargeAmmeter()](#Vehicle+chargeAmmeter) ⇒ [Promise](#Promise) - * [.chargeLimit()](#Vehicle+chargeLimit) ⇒ [Promise](#Promise) - * [.chargeSchedule()](#Vehicle+chargeSchedule) ⇒ [Promise](#Promise) - * [.chargeVoltmeter()](#Vehicle+chargeVoltmeter) ⇒ [Promise](#Promise) - * [.climate()](#Vehicle+climate) ⇒ [Promise](#Promise) - * [.collisionSensor()](#Vehicle+collisionSensor) ⇒ [Promise](#Promise) - * [.compass()](#Vehicle+compass) ⇒ [Promise](#Promise) - * [.cruiseControl()](#Vehicle+cruiseControl) ⇒ [Promise](#Promise) - * [.dimensions()](#Vehicle+dimensions) ⇒ [Promise](#Promise) - * [.doors()](#Vehicle+doors) ⇒ [Promise](#Promise) - * [.childSafetyLocks()](#Vehicle+childSafetyLocks) ⇒ [Promise](#Promise) - * [.driveMode()](#Vehicle+driveMode) ⇒ [Promise](#Promise) - * [.engine()](#Vehicle+engine) ⇒ [Promise](#Promise) - * [.engineCoolant()](#Vehicle+engineCoolant) ⇒ [Promise](#Promise) - * [.engineHood()](#Vehicle+engineHood) ⇒ [Promise](#Promise) - * [.engineOil()](#Vehicle+engineOil) ⇒ [Promise](#Promise) - * [.engineThrottle()](#Vehicle+engineThrottle) ⇒ [Promise](#Promise) - * [.fuel()](#Vehicle+fuel) ⇒ [Promise](#Promise) - * [.gyroscope()](#Vehicle+gyroscope) ⇒ [Promise](#Promise) - * [.ignition()](#Vehicle+ignition) ⇒ [Promise](#Promise) - * [.hazardLight()](#Vehicle+hazardLight) ⇒ [Promise](#Promise) - * [.headlights()](#Vehicle+headlights) ⇒ [Promise](#Promise) - * [.interiorLights()](#Vehicle+interiorLights) ⇒ [Promise](#Promise) - * [.turnIndicator()](#Vehicle+turnIndicator) ⇒ [Promise](#Promise) * [.location()](#Vehicle+location) ⇒ [Promise](#Promise) - * [.sideviewMirrors()](#Vehicle+sideviewMirrors) ⇒ [Promise](#Promise) * [.odometer()](#Vehicle+odometer) ⇒ [Promise](#Promise) - * [.tripOdometers()](#Vehicle+tripOdometers) ⇒ [Promise](#Promise) - * [.acceleratorPedal()](#Vehicle+acceleratorPedal) ⇒ [Promise](#Promise) - * [.brakePedal()](#Vehicle+brakePedal) ⇒ [Promise](#Promise) - * [.rainSensor()](#Vehicle+rainSensor) ⇒ [Promise](#Promise) - * [.seats()](#Vehicle+seats) ⇒ [Promise](#Promise) - * [.security()](#Vehicle+security) ⇒ [Promise](#Promise) - * [.sliBattery()](#Vehicle+sliBattery) ⇒ [Promise](#Promise) - * [.speedometer()](#Vehicle+speedometer) ⇒ [Promise](#Promise) - * [.steeringWheel()](#Vehicle+steeringWheel) ⇒ [Promise](#Promise) - * [.sunroof()](#Vehicle+sunroof) ⇒ [Promise](#Promise) - * [.tachometer()](#Vehicle+tachometer) ⇒ [Promise](#Promise) - * [.interiorThermistor()](#Vehicle+interiorThermistor) ⇒ [Promise](#Promise) - * [.exteriorThermistor()](#Vehicle+exteriorThermistor) ⇒ [Promise](#Promise) - * [.tires()](#Vehicle+tires) ⇒ [Promise](#Promise) - * [.transmission()](#Vehicle+transmission) ⇒ [Promise](#Promise) - * [.transmissionFluid()](#Vehicle+transmissionFluid) ⇒ [Promise](#Promise) - * [.frontTrunk()](#Vehicle+frontTrunk) ⇒ [Promise](#Promise) - * [.rearTrunk()](#Vehicle+rearTrunk) ⇒ [Promise](#Promise) * [.vin()](#Vehicle+vin) ⇒ [Promise](#Promise) - * [.washerFluid()](#Vehicle+washerFluid) ⇒ [Promise](#Promise) - * [.wheels()](#Vehicle+wheels) ⇒ [Promise](#Promise) - * [.wheelSpeeds()](#Vehicle+wheelSpeeds) ⇒ [Promise](#Promise) - * [.windows()](#Vehicle+windows) ⇒ [Promise](#Promise) - * [.startCharging()](#Vehicle+startCharging) ⇒ [Promise](#Promise) - * [.stopCharging()](#Vehicle+stopCharging) ⇒ [Promise](#Promise) - * [.enableChargeLimit([limit])](#Vehicle+enableChargeLimit) ⇒ [Promise](#Promise) - * [.disableChargeLimit()](#Vehicle+disableChargeLimit) ⇒ [Promise](#Promise) - * [.enableChargeSchedule(startTime)](#Vehicle+enableChargeSchedule) ⇒ [Promise](#Promise) - * [.disableChargeSchedule()](#Vehicle+disableChargeSchedule) ⇒ [Promise](#Promise) - * [.activateChildSafetyLocks(childSafetyLocksArr)](#Vehicle+activateChildSafetyLocks) ⇒ [Promise](#Promise) - * [.disableChildSafetyLocks(childSafetyLocksArr)](#Vehicle+disableChildSafetyLocks) ⇒ [Promise](#Promise) - * [.startClimate(temperature)](#Vehicle+startClimate) ⇒ [Promise](#Promise) - * [.stopClimate()](#Vehicle+stopClimate) ⇒ [Promise](#Promise) - * [.openEngineHood()](#Vehicle+openEngineHood) ⇒ [Promise](#Promise) - * [.closeEngineHood()](#Vehicle+closeEngineHood) ⇒ [Promise](#Promise) - * [.honkHorn()](#Vehicle+honkHorn) ⇒ [Promise](#Promise) - * [.startIgnition()](#Vehicle+startIgnition) ⇒ [Promise](#Promise) - * [.setIgnitionOn()](#Vehicle+setIgnitionOn) ⇒ [Promise](#Promise) - * [.setIgnitionAccessory()](#Vehicle+setIgnitionAccessory) ⇒ [Promise](#Promise) - * [.setIgnitionOff()](#Vehicle+setIgnitionOff) ⇒ [Promise](#Promise) - * [.flashHeadlights(type)](#Vehicle+flashHeadlights) ⇒ [Promise](#Promise) - * [.tiltSideviewMirrors(mirrorsArr)](#Vehicle+tiltSideviewMirrors) ⇒ [Promise](#Promise) - * [.startPanic()](#Vehicle+startPanic) ⇒ [Promise](#Promise) - * [.stopPanic()](#Vehicle+stopPanic) ⇒ [Promise](#Promise) - * [.openChargePort()](#Vehicle+openChargePort) ⇒ [Promise](#Promise) - * [.closeChargePort()](#Vehicle+closeChargePort) ⇒ [Promise](#Promise) - * [.openFuelPort()](#Vehicle+openFuelPort) ⇒ [Promise](#Promise) - * [.closeFuelPort()](#Vehicle+closeFuelPort) ⇒ [Promise](#Promise) * [.lock()](#Vehicle+lock) ⇒ [Promise](#Promise) * [.unlock()](#Vehicle+unlock) ⇒ [Promise](#Promise) - * [.openSunroof(percentOpen)](#Vehicle+openSunroof) ⇒ [Promise](#Promise) - * [.ventSunroof()](#Vehicle+ventSunroof) ⇒ [Promise](#Promise) - * [.closeSunroof()](#Vehicle+closeSunroof) ⇒ [Promise](#Promise) - * [.openFrontTrunk()](#Vehicle+openFrontTrunk) ⇒ [Promise](#Promise) - * [.closeFrontTrunk()](#Vehicle+closeFrontTrunk) ⇒ [Promise](#Promise) - * [.openRearTrunk()](#Vehicle+openRearTrunk) ⇒ [Promise](#Promise) - * [.closeRearTrunk()](#Vehicle+closeRearTrunk) ⇒ [Promise](#Promise) - * [.openWindows(windowsArr)](#Vehicle+openWindows) ⇒ [Promise](#Promise) - * [.closeWindows(windowsArr)](#Vehicle+closeWindows) ⇒ [Promise](#Promise) - * [.lockWindows(windowsArr)](#Vehicle+lockWindows) ⇒ [Promise](#Promise) - * [.unlockWindows(windowsArr)](#Vehicle+unlockWindows) ⇒ [Promise](#Promise) @@ -456,209 +370,6 @@ GET Vehicle.info **Kind**: instance method of [Vehicle](#Vehicle) **Returns**: [Promise](#Promise) - A promise for info on the vehicle's info - - -### vehicle.accelerometer() ⇒ [Promise](#Promise) -GET Vehicle.accelerometer - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's accelerometer - - -### vehicle.airbags() ⇒ [Promise](#Promise) -GET Vehicle.airbags - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's airbags - - -### vehicle.barometer() ⇒ [Promise](#Promise) -GET Vehicle.barometer - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's barometer - - -### vehicle.battery() ⇒ [Promise](#Promise) -GET Vehicle.battery - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's battery - - -### vehicle.charge() ⇒ [Promise](#Promise) -GET Vehicle.charge - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's charge - - -### vehicle.chargeAmmeter() ⇒ [Promise](#Promise) -GET Vehicle.chargeAmmeter - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's charge ammeter - - -### vehicle.chargeLimit() ⇒ [Promise](#Promise) -GET Vehicle.chargeLimit - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's chargeLimit - - -### vehicle.chargeSchedule() ⇒ [Promise](#Promise) -GET Vehicle.chargeSchedule - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's chargeSchedule - - -### vehicle.chargeVoltmeter() ⇒ [Promise](#Promise) -GET Vehicle.chargeVoltmeter - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's charge voltmeter - - -### vehicle.climate() ⇒ [Promise](#Promise) -GET Vehicle.climate - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's climate - - -### vehicle.collisionSensor() ⇒ [Promise](#Promise) -GET Vehicle.collisionSensor - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's collisionSensor - - -### vehicle.compass() ⇒ [Promise](#Promise) -GET Vehicle.compass - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's compass - - -### vehicle.cruiseControl() ⇒ [Promise](#Promise) -GET Vehicle.cruiseControl - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's cruiseControl - - -### vehicle.dimensions() ⇒ [Promise](#Promise) -GET Vehicle.dimensions - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's dimensions - - -### vehicle.doors() ⇒ [Promise](#Promise) -GET Vehicle.doors - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's doors - - -### vehicle.childSafetyLocks() ⇒ [Promise](#Promise) -GET Vehicle.childSafetyLocks - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's childSafetyLocks - - -### vehicle.driveMode() ⇒ [Promise](#Promise) -GET Vehicle.driveMode - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's driveMode - - -### vehicle.engine() ⇒ [Promise](#Promise) -GET Vehicle.engine - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's engine - - -### vehicle.engineCoolant() ⇒ [Promise](#Promise) -GET Vehicle.engineCoolant - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's engineCoolant - - -### vehicle.engineHood() ⇒ [Promise](#Promise) -GET Vehicle.engineHood - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's engineHood - - -### vehicle.engineOil() ⇒ [Promise](#Promise) -GET Vehicle.engineOil - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's engineOil - - -### vehicle.engineThrottle() ⇒ [Promise](#Promise) -GET Vehicle.engineThrottle - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's engineThrottle - - -### vehicle.fuel() ⇒ [Promise](#Promise) -GET Vehicle.fuel - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's fuel - - -### vehicle.gyroscope() ⇒ [Promise](#Promise) -GET Vehicle.gyroscope - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's gyroscope - - -### vehicle.ignition() ⇒ [Promise](#Promise) -GET Vehicle.ignition - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's ignition - - -### vehicle.hazardLight() ⇒ [Promise](#Promise) -GET Vehicle.hazardLight - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's hazardLight - - -### vehicle.headlights() ⇒ [Promise](#Promise) -GET Vehicle.headlights - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's headlights - - -### vehicle.interiorLights() ⇒ [Promise](#Promise) -GET Vehicle.interiorLights - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's interiorLights - - -### vehicle.turnIndicator() ⇒ [Promise](#Promise) -GET Vehicle.turnIndicator - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's turnIndicator ### vehicle.location() ⇒ [Promise](#Promise) @@ -666,13 +377,6 @@ GET Vehicle.location **Kind**: instance method of [Vehicle](#Vehicle) **Returns**: [Promise](#Promise) - A promise for info on the vehicle's location - - -### vehicle.sideviewMirrors() ⇒ [Promise](#Promise) -GET Vehicle.sideviewMirrors - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's sideviewMirrors ### vehicle.odometer() ⇒ [Promise](#Promise) @@ -680,132 +384,6 @@ GET Vehicle.odometer **Kind**: instance method of [Vehicle](#Vehicle) **Returns**: [Promise](#Promise) - A promise for info on the vehicle's odometer - - -### vehicle.tripOdometers() ⇒ [Promise](#Promise) -GET Vehicle.tripOdometers - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's tripOdometers - - -### vehicle.acceleratorPedal() ⇒ [Promise](#Promise) -GET Vehicle.acceleratorPedal - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's acceleratorPedal - - -### vehicle.brakePedal() ⇒ [Promise](#Promise) -GET Vehicle.brakePedal - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's brakePedal - - -### vehicle.rainSensor() ⇒ [Promise](#Promise) -GET Vehicle.rainSensor - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's rainSensor - - -### vehicle.seats() ⇒ [Promise](#Promise) -GET Vehicle.seats - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's seats - - -### vehicle.security() ⇒ [Promise](#Promise) -GET Vehicle.security - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's security - - -### vehicle.sliBattery() ⇒ [Promise](#Promise) -GET Vehicle.sliBattery - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's sliBattery - - -### vehicle.speedometer() ⇒ [Promise](#Promise) -GET Vehicle.speedometer - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's speedometer - - -### vehicle.steeringWheel() ⇒ [Promise](#Promise) -GET Vehicle.steeringWheel - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's steeringWheel - - -### vehicle.sunroof() ⇒ [Promise](#Promise) -GET Vehicle.sunroof - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's sunroof - - -### vehicle.tachometer() ⇒ [Promise](#Promise) -GET Vehicle.tachometer - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's tachometer - - -### vehicle.interiorThermistor() ⇒ [Promise](#Promise) -GET Vehicle.interiorThermistor - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's interiorThermistor - - -### vehicle.exteriorThermistor() ⇒ [Promise](#Promise) -GET Vehicle.exteriorThermistor - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's exteriorThermistor - - -### vehicle.tires() ⇒ [Promise](#Promise) -GET Vehicle.tires - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's tires - - -### vehicle.transmission() ⇒ [Promise](#Promise) -GET Vehicle.transmission - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's transmission - - -### vehicle.transmissionFluid() ⇒ [Promise](#Promise) -GET Vehicle.transmissionFluid - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's transmissionFluid - - -### vehicle.frontTrunk() ⇒ [Promise](#Promise) -GET Vehicle.frontTrunk - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's frontTrunk - - -### vehicle.rearTrunk() ⇒ [Promise](#Promise) -GET Vehicle.rearTrunk - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's rearTrunk ### vehicle.vin() ⇒ [Promise](#Promise) @@ -813,244 +391,6 @@ GET Vehicle.vin **Kind**: instance method of [Vehicle](#Vehicle) **Returns**: [Promise](#Promise) - A promise for info on the vehicle's vin - - -### vehicle.washerFluid() ⇒ [Promise](#Promise) -GET Vehicle.washerFluid - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's washerFluid - - -### vehicle.wheels() ⇒ [Promise](#Promise) -GET Vehicle.wheels - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's wheels - - -### vehicle.wheelSpeeds() ⇒ [Promise](#Promise) -GET Vehicle.wheelSpeeds - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's wheelSpeeds - - -### vehicle.windows() ⇒ [Promise](#Promise) -GET Vehicle.windows - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A promise for info on the vehicle's windows - - -### vehicle.startCharging() ⇒ [Promise](#Promise) -POST Vehicle.startCharging - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.stopCharging() ⇒ [Promise](#Promise) -POST Vehicle.stopCharging - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.enableChargeLimit([limit]) ⇒ [Promise](#Promise) -POST Vehicle.enableChargeLimit - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| [limit] | Float | override the previously set limit, must be between 0 - 1 | - - - -### vehicle.disableChargeLimit() ⇒ [Promise](#Promise) -POST Vehicle.disableChargeLimit - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.enableChargeSchedule(startTime) ⇒ [Promise](#Promise) -POST Vehicle.enableChargeSchedule - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| startTime | String | the datetime string representing when to start charging, i.e, '11:11' | - - - -### vehicle.disableChargeSchedule() ⇒ [Promise](#Promise) -POST Vehicle.disableChargeSchedule - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.activateChildSafetyLocks(childSafetyLocksArr) ⇒ [Promise](#Promise) -POST Vehicle.activateChildSafetyLocks - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| childSafetyLocksArr | Array | array of child safety lock objects, i.e, [{location: 'BACK_LEFT'}] | - - - -### vehicle.disableChildSafetyLocks(childSafetyLocksArr) ⇒ [Promise](#Promise) -POST Vehicle.disableChildSafetyLocks - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| childSafetyLocksArr | Array | array of child safety lock objects, i.e, [{location: 'BACK_LEFT'}] | - - - -### vehicle.startClimate(temperature) ⇒ [Promise](#Promise) -POST Vehicle.startClimate - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| temperature | Number | the temperature to set the car to | - - - -### vehicle.stopClimate() ⇒ [Promise](#Promise) -POST Vehicle.stopClimate - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openEngineHood() ⇒ [Promise](#Promise) -POST Vehicle.openEngineHood - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.closeEngineHood() ⇒ [Promise](#Promise) -POST Vehicle.closeEngineHood - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.honkHorn() ⇒ [Promise](#Promise) -POST Vehicle.honkHorn - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.startIgnition() ⇒ [Promise](#Promise) -POST Vehicle.startIgnition - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.setIgnitionOn() ⇒ [Promise](#Promise) -POST Vehicle.setIgnitionOn - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.setIgnitionAccessory() ⇒ [Promise](#Promise) -POST Vehicle.setIgnitionAccessory - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.setIgnitionOff() ⇒ [Promise](#Promise) -POST Vehicle.setIgnitionOff - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.flashHeadlights(type) ⇒ [Promise](#Promise) -POST Vehicle.flashHeadlights - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| type | String | the type of headlight to perform the action on, i.e 'HIGH_BEAM' | - - - -### vehicle.tiltSideviewMirrors(mirrorsArr) ⇒ [Promise](#Promise) -POST Vehicle.tiltSideviewMirrors - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| mirrorsArr | Array | array of mirror objects to perform action on, i.e [{location: 'LEFT'}] | - - - -### vehicle.startPanic() ⇒ [Promise](#Promise) -POST Vehicle.startPanic - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.stopPanic() ⇒ [Promise](#Promise) -POST Vehicle.stopPanic - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openChargePort() ⇒ [Promise](#Promise) -POST Vehicle.openChargePort - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.closeChargePort() ⇒ [Promise](#Promise) -POST Vehicle.closeChargePort - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openFuelPort() ⇒ [Promise](#Promise) -POST Vehicle.openFuelPort - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.closeFuelPort() ⇒ [Promise](#Promise) -POST Vehicle.closeFuelPort - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response ### vehicle.lock() ⇒ [Promise](#Promise) @@ -1065,108 +405,6 @@ POST Vehicle.unlock **Kind**: instance method of [Vehicle](#Vehicle) **Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openSunroof(percentOpen) ⇒ [Promise](#Promise) -POST Vehicle.openSunroof - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| percentOpen | Number | max: 1, min: 0 | - - - -### vehicle.ventSunroof() ⇒ [Promise](#Promise) -POST Vehicle.ventSunroof - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.closeSunroof() ⇒ [Promise](#Promise) -POST Vehicle.closeSunroof - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openFrontTrunk() ⇒ [Promise](#Promise) -POST Vehicle.openFrontTrunk - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.closeFrontTrunk() ⇒ [Promise](#Promise) -POST Vehicle.closeFrontTrunk - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openRearTrunk() ⇒ [Promise](#Promise) -POST Vehicle.openRearTrunk - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.closeRearTrunk() ⇒ [Promise](#Promise) -POST Vehicle.closeRearTrunk - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - - -### vehicle.openWindows(windowsArr) ⇒ [Promise](#Promise) -POST Vehicle.openWindows - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| windowsArr | Array | array of window objects to perform action upon, i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] | - - - -### vehicle.closeWindows(windowsArr) ⇒ [Promise](#Promise) -POST Vehicle.closeWindows - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| windowsArr | Array | array of window objects to perform action upon, i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] | - - - -### vehicle.lockWindows(windowsArr) ⇒ [Promise](#Promise) -POST Vehicle.lockWindows - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| windowsArr | Array | array of window objects to perform action upon, i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] | - - - -### vehicle.unlockWindows(windowsArr) ⇒ [Promise](#Promise) -POST Vehicle.unlockWindows - -**Kind**: instance method of [Vehicle](#Vehicle) -**Returns**: [Promise](#Promise) - A success or failure response - -| Param | Type | Description | -| --- | --- | --- | -| windowsArr | Array | array of window objects to perform action upon, i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] | - ## Access : Object diff --git a/lib/vehicle.js b/lib/vehicle.js index 24fe68a7..ae0b8f15 100644 --- a/lib/vehicle.js +++ b/lib/vehicle.js @@ -1,7 +1,5 @@ 'use strict'; -const _ = require('lodash'); - const util = require('./util'); /** @exports Vehicle */ @@ -83,7 +81,6 @@ Vehicle.prototype.permissions = function() { /* VEHICLE API METHODS */ - /** * GET Vehicle.info * @@ -93,267 +90,6 @@ Vehicle.prototype.info = function() { return util.wrap(this.request.get('/')); }; -/** - * GET Vehicle.accelerometer - * - * @return {Promise} A promise for info on the vehicle's accelerometer - */ -Vehicle.prototype.accelerometer = function() { - return util.wrap(this.request.get('accelerometer')); -}; - -/** - * GET Vehicle.airbags - * - * @return {Promise} A promise for info on the vehicle's airbags - */ -Vehicle.prototype.airbags = function() { - return util.wrap(this.request.get('airbags')); -}; - -/** - * GET Vehicle.barometer - * - * @return {Promise} A promise for info on the vehicle's barometer - */ -Vehicle.prototype.barometer = function() { - return util.wrap(this.request.get('barometer')); -}; - -/** - * GET Vehicle.battery - * - * @return {Promise} A promise for info on the vehicle's battery - */ -Vehicle.prototype.battery = function() { - return util.wrap(this.request.get('battery')); -}; - -/** - * GET Vehicle.charge - * - * @return {Promise} A promise for info on the vehicle's charge - */ -Vehicle.prototype.charge = function() { - return util.wrap(this.request.get('charge')); -}; - -/** - * GET Vehicle.chargeAmmeter - * - * @return {Promise} A promise for info on the vehicle's charge ammeter - */ -Vehicle.prototype.chargeAmmeter = function() { - return util.wrap(this.request.get('charge/ammeter')); -}; - -/** - * GET Vehicle.chargeLimit - * - * @return {Promise} A promise for info on the vehicle's chargeLimit - */ -Vehicle.prototype.chargeLimit = function() { - return util.wrap(this.request.get('charge/limit')); -}; - -/** - * GET Vehicle.chargeSchedule - * - * @return {Promise} A promise for info on the vehicle's chargeSchedule - */ -Vehicle.prototype.chargeSchedule = function() { - return util.wrap(this.request.get('charge/schedule')); -}; - -/** - * GET Vehicle.chargeVoltmeter - * - * @return {Promise} A promise for info on the vehicle's charge voltmeter - */ -Vehicle.prototype.chargeVoltmeter = function() { - return util.wrap(this.request.get('charge/voltmeter')); -}; - -/** - * GET Vehicle.climate - * - * @return {Promise} A promise for info on the vehicle's climate - */ -Vehicle.prototype.climate = function() { - return util.wrap(this.request.get('climate')); -}; - -/** - * GET Vehicle.collisionSensor - * - * @return {Promise} A promise for info on the vehicle's collisionSensor - */ -Vehicle.prototype.collisionSensor = function() { - return util.wrap(this.request.get('collision_sensor')); -}; - -/** - * GET Vehicle.compass - * - * @return {Promise} A promise for info on the vehicle's compass - */ -Vehicle.prototype.compass = function() { - return util.wrap(this.request.get('compass')); -}; - -/** - * GET Vehicle.cruiseControl - * - * @return {Promise} A promise for info on the vehicle's cruiseControl - */ -Vehicle.prototype.cruiseControl = function() { - return util.wrap(this.request.get('cruise_control')); -}; - -/** - * GET Vehicle.dimensions - * - * @return {Promise} A promise for info on the vehicle's dimensions - */ -Vehicle.prototype.dimensions = function() { - return util.wrap(this.request.get('dimensions')); -}; - -/** - * GET Vehicle.doors - * - * @return {Promise} A promise for info on the vehicle's doors - */ -Vehicle.prototype.doors = function() { - return util.wrap(this.request.get('doors')); -}; - -/** - * GET Vehicle.childSafetyLocks - * - * @return {Promise} A promise for info on the vehicle's childSafetyLocks - */ -Vehicle.prototype.childSafetyLocks = function() { - return util.wrap(this.request.get('doors/child_safety_locks')); -}; - -/** - * GET Vehicle.driveMode - * - * @return {Promise} A promise for info on the vehicle's driveMode - */ -Vehicle.prototype.driveMode = function() { - return util.wrap(this.request.get('drive_mode')); -}; - -/** - * GET Vehicle.engine - * - * @return {Promise} A promise for info on the vehicle's engine - */ -Vehicle.prototype.engine = function() { - return util.wrap(this.request.get('engine')); -}; - -/** - * GET Vehicle.engineCoolant - * - * @return {Promise} A promise for info on the vehicle's engineCoolant - */ -Vehicle.prototype.engineCoolant = function() { - return util.wrap(this.request.get('engine/coolant')); -}; - -/** - * GET Vehicle.engineHood - * - * @return {Promise} A promise for info on the vehicle's engineHood - */ -Vehicle.prototype.engineHood = function() { - return util.wrap(this.request.get('engine/hood')); -}; - -/** - * GET Vehicle.engineOil - * - * @return {Promise} A promise for info on the vehicle's engineOil - */ -Vehicle.prototype.engineOil = function() { - return util.wrap(this.request.get('engine/oil')); -}; - -/** - * GET Vehicle.engineThrottle - * - * @return {Promise} A promise for info on the vehicle's engineThrottle - */ -Vehicle.prototype.engineThrottle = function() { - return util.wrap(this.request.get('engine/throttle')); -}; - -/** - * GET Vehicle.fuel - * - * @return {Promise} A promise for info on the vehicle's fuel - */ -Vehicle.prototype.fuel = function() { - return util.wrap(this.request.get('fuel')); -}; - -/** - * GET Vehicle.gyroscope - * - * @return {Promise} A promise for info on the vehicle's gyroscope - */ -Vehicle.prototype.gyroscope = function() { - return util.wrap(this.request.get('gyroscope')); -}; - -/** - * GET Vehicle.ignition - * - * @return {Promise} A promise for info on the vehicle's ignition - */ -Vehicle.prototype.ignition = function() { - return util.wrap(this.request.get('ignition')); -}; - -/** - * GET Vehicle.hazardLight - * - * @return {Promise} A promise for info on the vehicle's hazardLight - */ -Vehicle.prototype.hazardLight = function() { - return util.wrap(this.request.get('lights/hazard')); -}; - -/** - * GET Vehicle.headlights - * - * @return {Promise} A promise for info on the vehicle's headlights - */ -Vehicle.prototype.headlights = function() { - return util.wrap(this.request.get('lights/headlights')); -}; - -/** - * GET Vehicle.interiorLights - * - * @return {Promise} A promise for info on the vehicle's interiorLights - */ -Vehicle.prototype.interiorLights = function() { - return util.wrap(this.request.get('lights/interior')); -}; - -/** - * GET Vehicle.turnIndicator - * - * @return {Promise} A promise for info on the vehicle's turnIndicator - */ -Vehicle.prototype.turnIndicator = function() { - return util.wrap(this.request.get('lights/turn_indicator')); -}; - /** * GET Vehicle.location * @@ -363,15 +99,6 @@ Vehicle.prototype.location = function() { return util.wrap(this.request.get('location')); }; -/** - * GET Vehicle.sideviewMirrors - * - * @return {Promise} A promise for info on the vehicle's sideviewMirrors - */ -Vehicle.prototype.sideviewMirrors = function() { - return util.wrap(this.request.get('mirrors/side_view')); -}; - /** * GET Vehicle.odometer * @@ -381,168 +108,6 @@ Vehicle.prototype.odometer = function() { return util.wrap(this.request.get('odometer')); }; -/** - * GET Vehicle.tripOdometers - * - * @return {Promise} A promise for info on the vehicle's tripOdometers - */ -Vehicle.prototype.tripOdometers = function() { - return util.wrap(this.request.get('odometer/trips')); -}; - -/** - * GET Vehicle.acceleratorPedal - * - * @return {Promise} A promise for info on the vehicle's acceleratorPedal - */ -Vehicle.prototype.acceleratorPedal = function() { - return util.wrap(this.request.get('pedals/accelerator')); -}; - -/** - * GET Vehicle.brakePedal - * - * @return {Promise} A promise for info on the vehicle's brakePedal - */ -Vehicle.prototype.brakePedal = function() { - return util.wrap(this.request.get('pedals/brake')); -}; - -/** - * GET Vehicle.rainSensor - * - * @return {Promise} A promise for info on the vehicle's rainSensor - */ -Vehicle.prototype.rainSensor = function() { - return util.wrap(this.request.get('rain_sensor')); -}; - -/** - * GET Vehicle.seats - * - * @return {Promise} A promise for info on the vehicle's seats - */ -Vehicle.prototype.seats = function() { - return util.wrap(this.request.get('seats')); -}; - -/** - * GET Vehicle.security - * - * @return {Promise} A promise for info on the vehicle's security - */ -Vehicle.prototype.security = function() { - return util.wrap(this.request.get('security')); -}; - -/** - * GET Vehicle.sliBattery - * - * @return {Promise} A promise for info on the vehicle's sliBattery - */ -Vehicle.prototype.sliBattery = function() { - return util.wrap(this.request.get('sli_battery')); -}; - -/** - * GET Vehicle.speedometer - * - * @return {Promise} A promise for info on the vehicle's speedometer - */ -Vehicle.prototype.speedometer = function() { - return util.wrap(this.request.get('speedometer')); -}; - -/** - * GET Vehicle.steeringWheel - * - * @return {Promise} A promise for info on the vehicle's steeringWheel - */ -Vehicle.prototype.steeringWheel = function() { - return util.wrap(this.request.get('steering_wheel')); -}; - -/** - * GET Vehicle.sunroof - * - * @return {Promise} A promise for info on the vehicle's sunroof - */ -Vehicle.prototype.sunroof = function() { - return util.wrap(this.request.get('sunroof')); -}; - -/** - * GET Vehicle.tachometer - * - * @return {Promise} A promise for info on the vehicle's tachometer - */ -Vehicle.prototype.tachometer = function() { - return util.wrap(this.request.get('tachometer')); -}; - -/** - * GET Vehicle.interiorThermistor - * - * @return {Promise} A promise for info on the vehicle's interiorThermistor - */ -Vehicle.prototype.interiorThermistor = function() { - return util.wrap(this.request.get('thermistors/interior')); -}; - -/** - * GET Vehicle.exteriorThermistor - * - * @return {Promise} A promise for info on the vehicle's exteriorThermistor - */ -Vehicle.prototype.exteriorThermistor = function() { - return util.wrap(this.request.get('thermistors/exterior')); -}; - -/** - * GET Vehicle.tires - * - * @return {Promise} A promise for info on the vehicle's tires - */ -Vehicle.prototype.tires = function() { - return util.wrap(this.request.get('tires')); -}; - -/** - * GET Vehicle.transmission - * - * @return {Promise} A promise for info on the vehicle's transmission - */ -Vehicle.prototype.transmission = function() { - return util.wrap(this.request.get('transmission')); -}; - -/** - * GET Vehicle.transmissionFluid - * - * @return {Promise} A promise for info on the vehicle's transmissionFluid - */ -Vehicle.prototype.transmissionFluid = function() { - return util.wrap(this.request.get('transmission/fluid')); -}; - -/** - * GET Vehicle.frontTrunk - * - * @return {Promise} A promise for info on the vehicle's frontTrunk - */ -Vehicle.prototype.frontTrunk = function() { - return util.wrap(this.request.get('trunks/front')); -}; - -/** - * GET Vehicle.rearTrunk - * - * @return {Promise} A promise for info on the vehicle's rearTrunk - */ -Vehicle.prototype.rearTrunk = function() { - return util.wrap(this.request.get('trunks/rear')); -}; - /** * GET Vehicle.vin * @@ -553,531 +118,25 @@ Vehicle.prototype.vin = function() { }; /** - * GET Vehicle.washerFluid + * POST Vehicle.lock * - * @return {Promise} A promise for info on the vehicle's washerFluid + * @return {Promise} A success or failure response */ -Vehicle.prototype.washerFluid = function() { - return util.wrap(this.request.get('washer_fluid')); +Vehicle.prototype.lock = function() { + return util.wrap(this.request.post('security', { + body: {action: 'LOCK'}, + })); }; /** - * GET Vehicle.wheels + * POST Vehicle.unlock * - * @return {Promise} A promise for info on the vehicle's wheels + * @return {Promise} A success or failure response */ -Vehicle.prototype.wheels = function() { - return util.wrap(this.request.get('wheels')); +Vehicle.prototype.unlock = function() { + return util.wrap(this.request.post('security', { + body: {action: 'UNLOCK'}, + })); }; -/** - * GET Vehicle.wheelSpeeds - * - * @return {Promise} A promise for info on the vehicle's wheelSpeeds - */ -Vehicle.prototype.wheelSpeeds = function() { - return util.wrap(this.request.get('wheels/speeds')); -}; - -/** - * GET Vehicle.windows - * - * @return {Promise} A promise for info on the vehicle's windows - */ -Vehicle.prototype.windows = function() { - return util.wrap(this.request.get('windows')); -}; - -/** - * POST Vehicle.startCharging - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.startCharging = function() { - return util.wrap(this.request.post('charge', { - body: {action: 'START'}, - })); -}; - -/** - * POST Vehicle.stopCharging - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.stopCharging = function() { - return util.wrap(this.request.post('charge', { - body: {action: 'STOP'}, - })); -}; - -/** - * POST Vehicle.enableChargeLimit - * - * @param {Float} [limit] - override the previously set limit, - * must be between 0 - 1 - * @return {Promise} A success or failure response - */ -Vehicle.prototype.enableChargeLimit = function(limit) { - return util.wrap(this.request.post('charge/limit', { - body: {limit, action: 'ENABLE'}, - })); -}; - -/** - * POST Vehicle.disableChargeLimit - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.disableChargeLimit = function() { - return util.wrap(this.request.post('charge/limit', { - body: {action: 'DISABLE'}, - })); -}; - -/** - * POST Vehicle.enableChargeSchedule - * - * @param {String} startTime the datetime string representing when to start - * charging, i.e, '11:11' - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.enableChargeSchedule = function(startTime) { - return util.wrap(this.request.post('charge/schedule', { - body: {action: 'ENABLE', startTime}, - })); -}; - -/** - * POST Vehicle.disableChargeSchedule - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.disableChargeSchedule = function() { - return util.wrap(this.request.post('charge/schedule', { - body: {action: 'DISABLE'}, - })); -}; - -/** - * POST Vehicle.activateChildSafetyLocks - * - * @param {Array} childSafetyLocksArr array of child safety lock objects, - * i.e, [{location: 'BACK_LEFT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.activateChildSafetyLocks = function(childSafetyLocksArr) { - // eslint-disable-next-line max-len - if (_.isNil(childSafetyLocksArr) || !Array.isArray(childSafetyLocksArr)) { - // eslint-disable-next-line max-len - throw new TypeError('activateChildSafetyLocks requires an array of safety locks'); - } - return util.wrap(this.request.post('doors/child_safety_locks', { - body: {action: 'LOCK', childSafetyLocks: childSafetyLocksArr}, - })); -}; - -/** - * POST Vehicle.disableChildSafetyLocks - * - * @param {Array} childSafetyLocksArr array of child safety lock objects, - * i.e, [{location: 'BACK_LEFT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.disableChildSafetyLocks = function(childSafetyLocksArr) { - // eslint-disable-next-line max-len - if (_.isNil(childSafetyLocksArr) || !Array.isArray(childSafetyLocksArr)) { - // eslint-disable-next-line max-len - throw new TypeError('disableChildSafetyLocks requires an array of safety locks'); - } - return util.wrap(this.request.post('doors/child_safety_locks', { - body: {action: 'UNLOCK', childSafetyLocks: childSafetyLocksArr}, - })); -}; - -/** - * POST Vehicle.startClimate - * - * @param {Number} temperature the temperature to set the car to - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.startClimate = function(temperature) { - return util.wrap(this.request.post('climate', { - body: {action: 'START', temperature}, - })); -}; - -/** - * POST Vehicle.stopClimate - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.stopClimate = function() { - return util.wrap(this.request.post('climate', { - body: {action: 'STOP'}, - })); -}; - -/** - * POST Vehicle.openEngineHood - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openEngineHood = function() { - return util.wrap(this.request.post('engine/hood', { - body: {action: 'OPEN'}, - })); -}; - -/** - * POST Vehicle.closeEngineHood - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeEngineHood = function() { - return util.wrap(this.request.post('engine/hood', { - body: {action: 'CLOSE'}, - })); -}; - -/** - * POST Vehicle.honkHorn - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.honkHorn = function() { - return util.wrap(this.request.post('horn', { - body: {action: 'HONK'}, - })); -}; - -/** - * POST Vehicle.startIgnition - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.startIgnition = function() { - return util.wrap(this.request.post('ignition', { - body: {action: 'START'}, - })); -}; - -/** - * POST Vehicle.setIgnitionOn - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.setIgnitionOn = function() { - return util.wrap(this.request.post('ignition', { - body: {action: 'ON'}, - })); -}; - -/** - * POST Vehicle.setIgnitionAccessory - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.setIgnitionAccessory = function() { - return util.wrap(this.request.post('ignition', { - body: {action: 'ACCESSORY'}, - })); -}; - -/** - * POST Vehicle.setIgnitionOff - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.setIgnitionOff = function() { - return util.wrap(this.request.post('ignition', { - body: {action: 'OFF'}, - })); -}; - -/** - * POST Vehicle.flashHeadlights - * - * @param {String} type the type of headlight to perform the action on, - * i.e 'HIGH_BEAM' - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.flashHeadlights = function(type) { - if (_.isNil(type) || typeof type !== 'string') { - // eslint-disable-next-line max-len - throw new TypeError('flashHeadlights requires a string describing type of flash'); - } - return util.wrap(this.request.post('lights/headlights', { - body: {action: 'FLASH', type}, - })); -}; - -/** - * POST Vehicle.tiltSideviewMirrors - * - * @param {Array} mirrorsArr array of mirror objects to perform action on, - * i.e [{location: 'LEFT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.tiltSideviewMirrors = function(mirrorsArr) { - // eslint-disable-next-line max-len - if (_.isNil(mirrorsArr) || !Array.isArray(mirrorsArr)) { - // eslint-disable-next-line max-len - throw new TypeError('tiltSideviewMirrors requires an array of mirrors'); - } - return util.wrap(this.request.post('mirrors/side_view', { - body: {action: 'TILT', mirrors: mirrorsArr}, - })); -}; - -/** - * POST Vehicle.startPanic - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.startPanic = function() { - return util.wrap(this.request.post('panic', { - body: {action: 'START'}, - })); -}; - -/** - * POST Vehicle.stopPanic - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.stopPanic = function() { - return util.wrap(this.request.post('panic', { - body: {action: 'STOP'}, - })); -}; - -/** - * POST Vehicle.openChargePort - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openChargePort = function() { - return util.wrap(this.request.post('ports/charge', { - body: {action: 'OPEN'}, - })); -}; - -/** - * POST Vehicle.closeChargePort - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeChargePort = function() { - return util.wrap(this.request.post('ports/charge', { - body: {action: 'CLOSE'}, - })); -}; - -/** - * POST Vehicle.openFuelPort - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openFuelPort = function() { - return util.wrap(this.request.post('ports/fuel', { - body: {action: 'OPEN'}, - })); -}; - -/** - * POST Vehicle.closeFuelPort - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeFuelPort = function() { - return util.wrap(this.request.post('ports/fuel', { - body: {action: 'CLOSE'}, - })); -}; - -/** - * POST Vehicle.lock - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.lock = function() { - return util.wrap(this.request.post('security', { - body: {action: 'LOCK'}, - })); -}; - -/** - * POST Vehicle.unlock - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.unlock = function() { - return util.wrap(this.request.post('security', { - body: {action: 'UNLOCK'}, - })); -}; - -/** - * POST Vehicle.openSunroof - * - * @param {Number} percentOpen max: 1, min: 0 - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openSunroof = function(percentOpen) { - - if (!_.isNumber(percentOpen)) { - throw new TypeError('"percentOpen" argument must be a number'); - } - - return util.wrap(this.request.post('sunroof', { - body: {action: 'OPEN', percentOpen}, - })); -}; - -/** - * POST Vehicle.ventSunroof - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.ventSunroof = function() { - return util.wrap(this.request.post('sunroof', { - body: {action: 'VENT'}, - })); -}; - -/** - * POST Vehicle.closeSunroof - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeSunroof = function() { - return util.wrap(this.request.post('sunroof', { - body: {action: 'CLOSE'}, - })); -}; - -/** - * POST Vehicle.openFrontTrunk - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openFrontTrunk = function() { - return util.wrap(this.request.post('trunks/front', { - body: {action: 'OPEN'}, - })); -}; - -/** - * POST Vehicle.closeFrontTrunk - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeFrontTrunk = function() { - return util.wrap(this.request.post('trunks/front', { - body: {action: 'CLOSE'}, - })); -}; - -/** - * POST Vehicle.openRearTrunk - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openRearTrunk = function() { - return util.wrap(this.request.post('trunks/rear', { - body: {action: 'OPEN'}, - })); -}; - -/** - * POST Vehicle.closeRearTrunk - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeRearTrunk = function() { - return util.wrap(this.request.post('trunks/rear', { - body: {action: 'CLOSE'}, - })); -}; - -/** - * POST Vehicle.openWindows - * - * @param {Array} windowsArr array of window objects to perform action upon, - * i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.openWindows = function(windowsArr) { - if (_.isNil(windowsArr) || !Array.isArray(windowsArr)) { - // eslint-disable-next-line max-len - throw new TypeError('openWindows requires an array of windows'); - } - return util.wrap(this.request.post('windows', { - body: {action: 'OPEN', windows: windowsArr}, - })); -}; - -/** - * POST Vehicle.closeWindows - * - * @param {Array} windowsArr array of window objects to perform action upon, - * i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.closeWindows = function(windowsArr) { - if (_.isNil(windowsArr) || !Array.isArray(windowsArr)) { - // eslint-disable-next-line max-len - throw new TypeError('closeWindows requires an array of windows'); - } - return util.wrap(this.request.post('windows', { - body: {action: 'CLOSE', windows: windowsArr}, - })); -}; - -/** - * POST Vehicle.lockWindows - * - * @param {Array} windowsArr array of window objects to perform action upon, - * i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.lockWindows = function(windowsArr) { - if (_.isNil(windowsArr) || !Array.isArray(windowsArr)) { - // eslint-disable-next-line max-len - throw new TypeError('lockWindows requires an array of windows'); - } - return util.wrap(this.request.post('windows', { - body: {action: 'LOCK', windows: windowsArr}, - })); -}; - -/** - * POST Vehicle.unlockWindows - * - * @param {Array} windowsArr array of window objects to perform action upon, - * i.e [{location: 'BACK_LEFT'}, {location: 'FRONT_RIGHT'}] - * - * @return {Promise} A success or failure response - */ -Vehicle.prototype.unlockWindows = function(windowsArr) { - if (_.isNil(windowsArr) || !Array.isArray(windowsArr)) { - // eslint-disable-next-line max-len - throw new TypeError('windowsArr requires an array of windows'); - } - return util.wrap(this.request.post('windows', { - body: {action: 'UNLOCK', windows: windowsArr}, - })); -}; - - module.exports = Vehicle; diff --git a/test/lib/vehicle-api-param-methods.js b/test/lib/vehicle-api-param-methods.js deleted file mode 100644 index 7edf6699..00000000 --- a/test/lib/vehicle-api-param-methods.js +++ /dev/null @@ -1,195 +0,0 @@ -'use strict'; - -const Promise = require('bluebird'); -const _ = require('lodash'); -const nock = require('nock'); -const test = require('ava'); - -const Vehicle = require('../../lib/vehicle'); -const config = require('../../lib/config'); - -const VID = 'c8d7e7bc-22ef-4ebe-87ab-f2193c94c9b9'; -const TOKEN = 'fde1666c-5090-4494-8b0d-ec396db9e4d7'; -const USER_AGENT = `smartcar-node-sdk:${config.version}`; - -const vehicle = new Vehicle(VID, TOKEN); - -const nocks = { - base(endpoint, body) { - return nock(`https://api.smartcar.com/v1.0/vehicles/${VID}`) - .matchHeader('User-Agent', USER_AGENT) - .matchHeader('Authorization', `Bearer ${TOKEN}`) - .post(endpoint, body) - .reply(200, {status: 'success'}); - }, -}; - -test.before(() => nock.disableNetConnect()); -test.after(() => nock.cleanAll()); - -const optionalArguments = [ - 'startClimate', - 'updateRequest', - 'enableChargeLimit', - 'enableChargeSchedule', -]; - -// test all the methods that do not require any arguments -_.forEach(Vehicle.prototype, function(method, name) { - - if (!method.length || _.includes(optionalArguments, name)) { - return; - } - - test(`${name} - throws error on invalid params`, function(t) { - return Promise.join( - t.throws(() => vehicle[name](), TypeError), - t.throws(() => vehicle[name]({}), TypeError) - ); - }); - -}); - -test('flashHeadlights', async function(t) { - - const body = { - action: 'FLASH', - type: 'HIGH_BEAM', - }; - - t.context.n = nocks.base('/lights/headlights', body); - const response = await vehicle.flashHeadlights(body.type); - t.is(response.status, 'success'); - -}); - -test('activateChildSafetyLocks', async function(t) { - - const body = { - action: 'LOCK', - childSafetyLocks: [{location: 'BACK_LEFT'}], - }; - - t.context.n = nocks.base('/doors/child_safety_locks', body); - const response = await vehicle.activateChildSafetyLocks( - body.childSafetyLocks - ); - t.is(response.status, 'success'); - -}); - -test('disableChildSafetyLocks', async function(t) { - - const body = { - action: 'UNLOCK', - childSafetyLocks: [{location: 'BACK_LEFT'}], - }; - - t.context.n = nocks.base('/doors/child_safety_locks', body); - const response = await vehicle.disableChildSafetyLocks(body.childSafetyLocks); - t.is(response.status, 'success'); - -}); - -test('tiltSideviewMirrors', async function(t) { - - const body = { - action: 'TILT', - mirrors: [{location: 'LEFT'}], - }; - - t.context.n = nocks.base('/mirrors/side_view', body); - const response = await vehicle.tiltSideviewMirrors(body.mirrors); - t.is(response.status, 'success'); - -}); - -test('openWindows', async function(t) { - - const body = { - action: 'OPEN', - windows: [{location: 'BACK_LEFT'}], - }; - - t.context.n = nocks.base('/windows', body); - const response = await vehicle.openWindows(body.windows); - t.is(response.status, 'success'); - -}); - -test('closeWindows', async function(t) { - - const body = { - action: 'CLOSE', - windows: [{location: 'BACK_LEFT'}], - }; - - t.context.n = nocks.base('/windows', body); - const response = await vehicle.closeWindows(body.windows); - t.is(response.status, 'success'); - -}); - -test('unlockWindows', async function(t) { - - const body = { - action: 'UNLOCK', - windows: [{location: 'BACK_LEFT'}], - }; - - t.context.n = nocks.base('/windows', body); - const response = await vehicle.unlockWindows(body.windows); - t.is(response.status, 'success'); - -}); - -test('lockWindows', async function(t) { - - const body = { - action: 'LOCK', - windows: [{location: 'BACK_LEFT'}], - }; - - t.context.n = nocks.base('/windows', body); - const response = await vehicle.lockWindows(body.windows); - t.is(response.status, 'success'); - -}); - -test('enableChargeLimit', async function(t) { - - const body = { - action: 'ENABLE', - limit: 0.5, - }; - - t.context.n = nocks.base('/charge/limit', body); - const response = await vehicle.enableChargeLimit(body.limit); - t.is(response.status, 'success'); - -}); - -test('enableChargeSchedule', async function(t) { - - const body = { - action: 'ENABLE', - startTime: '11:11', - }; - t.context.n = nocks.base('/charge/schedule', body); - const response = await vehicle.enableChargeSchedule(body.startTime); - t.is(response.status, 'success'); - -}); - -test('startClimate', async function(t) { - - const body = { - action: 'START', - temperature: 32.5, - }; - - t.context.n = nocks.base('/climate', body); - const response = await vehicle.startClimate(body.temperature); - t.is(response.status, 'success'); - -}); diff --git a/test/lib/vehicle.js b/test/lib/vehicle.js index 27b1ec95..fcb1630d 100644 --- a/test/lib/vehicle.js +++ b/test/lib/vehicle.js @@ -135,24 +135,10 @@ test('permissions', async function(t) { test('action with no argument', async function(t) { t.context.nock = nocks.base() - .post('/panic', {action: 'START'}) + .post('/security', {action: 'LOCK'}) .reply(200, {status: 'success'}); - const response = await vehicle.startPanic(); - t.is(response.status, 'success'); - -}); - -test('action with a key and argument', async function(t) { - - t.context.n = nocks.base() - .post('/sunroof', { - action: 'OPEN', - percentOpen: 0.5, - }) - .reply(200, {status: 'success'}); - - const response = await vehicle.openSunroof(0.5); + const response = await vehicle.lock(); t.is(response.status, 'success'); });