ApiApp

This class represents another App on Homey. When registered, realtime events are fired on the instance.

Table of Contents

Constructor

new Homey.ApiApp(appId)

Parameters:
Name Type Description
appId string

The ID of the App, e.g. com.athom.foo

Example
const Homey = require('homey');
let otherApp = new Homey.ApiApp('com.athom.otherApp');
    otherApp
        .register()
        .on('realtime', this.log.bind(this, 'otherApp.onRealtime'))
        .on('install', this.log.bind(this, 'otherApp.onInstall'))
        .on('uninstall', this.log.bind(this, 'otherApp.onUninstall'))
        .get('/')
            .then( this.log.bind( this, 'otherApp.get') )
            .catch( this.error.bind( this, 'otherApp.get') )

    otherApp.getInstalled()
        .then( this.log.bind( this, 'otherApp.getInstalled') )
        .catch( this.error.bind( this, 'otherApp.getInstalled') )

    otherApp.getVersion()
        .then( this.log.bind( this, 'otherApp.getVersion') )
        .catch( this.error.bind( this, 'otherApp.getVersion') )

Extends

Methods

delete(path, callbackopt)

Perform a DELETE request.

Inherited From:
Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

callback genericCallbackFunction <optional>
Returns:

Promise

get(path, callbackopt)

Perform a GET request.

Inherited From:
Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

callback genericCallbackFunction <optional>
Returns:

Promise

getInstalled(callbackopt) → {Promise}

This is a short-hand method to ManagerApps#getInstalled.

Parameters:
Name Type Attributes Description
callback function <optional>
Name Type Description
err Error
installed boolean
Returns:
Type:
Promise

getVersion(callbackopt) → {Promise}

This is a short-hand method to ManagerApps#getVersion.

Parameters:
Name Type Attributes Description
callback function <optional>
Name Type Description
err Error
version string
Returns:
Type:
Promise

post(path, body, callbackopt)

Perform a POST request.

Inherited From:
Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

body *

The body of the request.

callback genericCallbackFunction <optional>
Returns:

Promise

put(path, body, callbackopt)

Perform a PUT request.

Inherited From:
Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

body *

The body of the request.

callback genericCallbackFunction <optional>
Returns:

Promise

register() → {Api}

Register the API, to receive incoming realtime events. This is a shorthand method for ManagerApi#registerApi.

Inherited From:
Returns:
Type:
Api

unregister()

Unregister the API. This is a shorthand method for ManagerApi#unregisterApi.

Inherited From: