Class: WebAPIDriver

WebAPIDriver()

The WebAPIDriver class exposes methods useful for WebAPIDrivers. It creates an API call queue and methods to communicate with an API.

Constructor

new WebAPIDriver()

Example
const WebAPIDriver = require('homey-wifidriver').WebAPIDriver;

class myDriver extends WebAPIDriver {
 onInit(options){
     super.onInit(options);

     this.setDefaultBaseUrl('http://example.api.com/');
     this.setDefaultHeaders({Authorization: `Bearer ${Homey.ManagerSettings.get('accessToken')}`});
 }

 onPairListDevices(){
     return this.apiCallGet({uri: '/list/devices'});
 }
}

Extends

Methods

onInit(options)

This method needs to be called from a driver, it will create a PromiseQueue that will be used for queueing, throttling and rate limiting api calls.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
apiBaseUrl string <optional>

Url used for making api calls

throttle number <optional>

Throttle value, time in ms between api calls

rateLimit number <optional>
Properties
Name Type Attributes Description
max number <optional>

Maximum number of api calls per time unit

per number <optional>

Time unit in ms