Methods

Conductor()

Constructor for the Conductor API.

login( options )

options - an object with the following keys:

  • username - User name for the Conductor account, usually an email address.
  • password - Password for the Conductor account.

This API call logs into Conductor and creates a session, returning a Promise. The returned Promise-value includes account information about the now authenticated user.

logout()

Ends the current Conductor session, returning a Promise that resolves upon completion.

getSession()

Fetches the current session, if still valid. If the returned Promise object is resolved as a rejection, then the client should create a new session using the login call.

getMessages( nodeType, nodeId, maxResults )

  • nodeType - type of data stream to access, could be ‘gateway’, ‘network’, ‘application’, or ‘module’

  • nodeId - the identifier appropriate for the node type.  For example, if nodeType=’gateway’, then nodeId will be of the form $101-0-0-0-xxxxxxxxx

  • maxResults - optional max number of messages to load, defaults to 20

This call loads messages for the given node type from Conductor as a single connection (without streaming or polling).  No messages older than 5 days will be returned.  Returns a Promise that resolves to the requested data.

attachMessages( nodeType, streamOptions, decoder, options )

  • nodeType - type of data stream to access, could be ‘gateway’, ‘network’, ‘application’, or ‘module’

  • streamOptions - an object with the following fields:
    • gatewayId - identifier of the form $101-0-0-0-xxxxxxxxx, required when nodeType is ‘gateway’
    • networkToken - 8 character hex string, required when nodeType is ‘network’

    • applicationToken - 20 character hex string, required when nodeType is ‘application’
    • module - Identifier of the form $301-0-0-0-xxxxxxxxx, required when nodeType is ‘module’

    • messages - Array, Array-like object (with push(), length, and shift() operations), or knockout ObservableArray to be populated with messages from the data stream

  • decoder - An optional function that is called when each new message arrives.  The call parameter is the message that was just received.  The return value must be a Promise.  Once the returned Promise resolves with success, the streamOptions.messages array will have the new message pushed into it.

  • options - an optional object with the following field:

    • maxResults - The number of messages to hold in the streamOptions.messages array, default value is 20.  This is also passed to Conductor at first connection as a maximum number of history messages to pre-populate.


Creates a streaming connection to Conductor and populates messages from the nodeType/nodeId combination as they arrive.  The first time a stream is attached, the JavaScript API will populate up to options.maxResults history messages from the previous 5 days of traffic.  Returns a Promise that resolves to the Conductor.Subscription object that implements the streaming connection.

detachMessages( nodeType, streamOptions )

Closes a stream created by the attachMessages operation.  The nodeType and streamOptions.<gatewayId, networkToken, applicationToken, or module> parameters must match the corresponding attachMessages call.  There is no return value.

issueCommand( payload, options )

  • payload - the hex string to send to the target module

  • options - an object with the following required fields:
    • module - the destination module for this message (or $301-0-0-0-fffffffff for broadcast)

    • gateway - An optional id for the gateway to use in routing.  It is
noAck - If false or omitted, then the requiredAckRatio and requiredSuccessfulAckRatio commReqs options are both set to 0.  If true, then the values will be 1.


Sends a hex payload to the given destination.  If a gateway is provided, then the message will use Conductor’s commandRoutes mode for transmission.  Otherwise, commandTargets mode is used.  All messages sent with this API wrapper have a ttl of 60 seconds.  The return value is a Promise that resolves to Conductor’s envelope information about the command.

loadGateways()

Loads all gateways in the current session’s account, returning a Promise that resolves into the known Gateway objects.

updateGateway( gatewayInfo )

  • gatewayInfo - an object with the following fields:
    • apiBase - the URL for this gateway (rel.href) as returned by the loadGateways() call
    • gatewayName - new name for the gateway

Updates the name of a given gateway, returning a Promise that resolves upon completion.

registerGateway( args )

  • args - an object with the following fields:

    • gatewayId - the id of the gateway to register

    • networkToken - the network token to assign to this gateway


Updates the network token registration for the given gateway, returning a Promise that resolves upon completion.

loadNetworks()

Loads all network tokens in the current session’s account, returning a Promise that resolves into the known Network objects.  Universal (Open) network(s) are also discovered as a side effect.

updateNetwork( networkInfo )

  • networkInfo - an object with the following fields:
    • apiBase - the URL for this network (rel.href) as returned by the loadNetworks() call.

    • networkName - new name for the network token


Updates the friendly name of a given network token, returning a Promise that resolves upon completion.

loadApplications()

Loads all application ids in the current session’s account, returning a Promise that resolves into the know Application objects.

updateApplication( applicationInfo )

  • applicationInfo - an object with the following fields:
    • apiBase - the URL for this network (rel.href) as returned by the loadApplications() call
    • applicationName - new name for the application id

Updates the friendly name of a given application, returning a Promise that resolves upon completion.

createApplication( applicationName )

  • applicationName - optional name for the newly created application id.  Default value is a name derived from the username and current time.


Creates a new application id and associates it with the current account.  Returns a Promise that resolves upon completion of the creation process.

loadApplicationStats( options )

  • options - an optional object with the following field:

    • refreshRate - time, in milliseconds, between poll updates to refresh the module list


Accesses Conductor to find all modules registered to this account, updating the various data structures returned from loadApplications(), loadGateways(), and loadNetworks().  Returns a Promise that resolves upon the first completion of the Conductor call.  If refresh is enabled (with a value greater than 0 ms), then subsequent calls will not have an effect on the Promise.

loadUsers()

Loads all users in the current session’s account, returning a Promise that resolves into the known User objects.

updateUser( userInfo )

  • userInfo - An object with at least one of the following fields - name, company, phoneNumber, address1, address2, city, state, zipCode, country.  In addition, the following field is required:
    • apiBase - the URL for this user (rel.href) as returned by the loadUsers() call


Updates the personal information for the given user.  Returns a Promise that resolves upon successful update of the user.

updatePassword( userInfo, oldPassword, newPassword )

  • userInfo - an object with the following fields:
    • apiBase - the URL for this user (rel.href) as returned by the loadUsers() call.
    • email - the user’s login name (usually an email address)

  • oldPassword - the old password on the account

  • newPassword - the desired replacement password


Updates the user’s password.  Unlike most other calls in this API wrapper, updatePassword() does not use the current session.  This call returns a Promise that resolves upon successful completion of the change operation, logout, login, and getSession.  The Promise may reject upon a failure at any of those steps, so refer to the Promise’s value for a description of how it failed.

createUser( userInfo )

  • userInfo - An object with the new user’s email, password, and name.  Additional fields such as company, phoneNumber, address1, address2, city, state, zipCode, and country are optional.


Creates a new user.  If there is an authenticated session, then the new user will be provisioned as a member of the current account.  Otherwise, the user will be anonymously provisioned.  Returns a Promise that resolves with the new user’s information upon completion of the provisioning process.

0 Comments

Add your comment

E-Mail me when someone replies to this comment