11const got = require ( 'got' )
22const mqtt = require ( 'mqtt' )
33
4- class Hub {
5- constructor ( apiKey , deviceID , options ) {
4+ class Axis {
5+ constructor ( apiKey , clientID , options ) {
66 this . apiKey = apiKey
7- this . deviceID = deviceID
7+ this . clientID = clientID
88 this . handlers = { }
99 this . options = options || { }
1010 }
1111
1212 _normalizeDeviceID ( ) {
13- return `${ this . projectID } :${ this . deviceID } `
13+ return `${ this . projectID } :${ this . clientID } `
1414 }
1515
1616 _normalizeTopic ( topic ) {
@@ -21,9 +21,9 @@ class Hub {
2121 return topic . replace ( this . projectID + '/' , '' ) ;
2222 }
2323
24- async _findKey ( ) {
24+ async _findProjectID ( ) {
2525 try {
26- const response = await got ( 'https://api.labstack.com/keys ' , {
26+ const response = await got ( 'https://api.labstack.com/axis/key ' , {
2727 headers : {
2828 'Authorization' : `Bearer ${ this . apiKey } `
2929 } ,
@@ -37,12 +37,12 @@ class Hub {
3737
3838 async connect ( handler ) {
3939 try {
40- await this . _findKey ( )
40+ await this . _findProjectID ( )
4141 } catch ( error ) {
4242 throw error
4343 }
4444
45- this . client = mqtt . connect ( 'mqtt://hub .labstack.com' , {
45+ this . client = mqtt . connect ( 'mqtt://axis .labstack.com' , {
4646 username : this . projectID ,
4747 password : this . apiKey ,
4848 clientId : this . _normalizeDeviceID ( )
@@ -85,4 +85,4 @@ class Hub {
8585 }
8686}
8787
88- module . exports = Hub
88+ module . exports = Axis
0 commit comments