10.2.0 • Published 8 years ago

meshblu-http v10.2.0

Weekly downloads
49
License
MIT
Repository
github
Last release
8 years ago

Meshblu HTTP

A node package to use the Meshblu HTTP API...

Build Status Code Climate Test Coverage npm version Gitter

Usage

Install:

npm install --save meshblu-http

Use:

var MeshbluHttp = require('meshblu-http');

var meshbluHttp = new MeshbluHttp();

meshbluHttp.register({}, function(error, response) {
  // code goes here
})

Functions

Constructor

ParameterTypeRequiredDescription
optionsobjectnocan contain any of these keys: bearerToken, uuid, token, hostname, port, protocol, domain, service, secure, resolveSrv, auth

var meshbluHttp = new MeshbluHttp({uuid: 'fancy_uuid', token: 'fancy_token'})
var meshbluHttp = new MeshbluHttp({bearerToken: 'some-bearer-token'})

Authenticate

ParameterTypeRequiredDescription
callbackfunctionyesa function that returns error and response

meshbluHttp.authenticate(function(error, response) {
  // code goes here
})

Create Hook

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid
typestringyes   a string containing the type
urlstringyes   a string containing the url
callbackfunctionyes   a function that returns error

meshbluHttp.createHook('fancy_uuid', 'fancy_token', 'fancy_url', function(error) {
  // code goes here
})

Create Subscription

ParameterTypeRequiredDescription
optionsobjectyes   an object containing three keys: subscriberUuid, emitterUuid, and type
callbackfunctionyesa function that returns error and response

meshbluHttp.createSubscription(
  {
    subscriberUuid: 'fancy_uuid',
    emitterUuid: 'another_fancy_uuid',
    type: 'fancy_type'
  },
  function(error, response){
    // code goes here
  }
)

Delete Subscription

ParameterTypeRequiredDescription
optionsobjectyes   an object containing three keys: subscriberUuid, emitterUuid, and type
callbackfunctionyesa function that returns error and response

meshbluHttp.deleteSubscription(
  {
    subscriberUuid: 'fancy_uuid',
    emitterUuid: 'another_fancy_uuid',
    type: 'fancy_type'
  },
  function(error, response){
    // code goes here
  }
)

Delete Subscriptions

ParameterTypeRequiredDescription
optionsobjectyes   an object containing three keys: subscriberUuid, emitterUuid, and type. Type and emitterUuid are optional and will be used to filter the subscriptions to delete.
callbackfunctionyesa function that returns error and response

meshbluHttp.deleteSubscriptions(
  {
    subscriberUuid: 'fancy_uuid',
    emitterUuid: 'another_fancy_uuid',
    type: 'fancy_type'
  },
  function(error, response){
    // code goes here
  }
)

Device

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
metadataobjectno   an object containing metadata information
callbackfunctionyes   a function that returns error and response

meshbluHttp.device('fancy_uuid', {as: 'another_user_uuid'}, function(error, response){
  // code goes here
})

Devices

ParameterTypeRequiredDescription
queryobjectno    an object containing the keys you want to search for
metadataobjectno   an object containing metadata information
callbackfunctionyes   a function that returns error and response

meshbluHttp.devices({type: 'drone'}, {as: 'another_user_uuid'}, function(error, response){
  // code goes here
})

Find And Update

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
paramsobjectyes   an object containing the new changes to the device
metadataobjectno   an object containing metadata information
callbackfunctionyes   a function that returns error and response

meshbluHttp.findAndUpdate('fancy_uuid', {type: 'new-type'}, function(error, response){
  // code goes here
})

Generate And Store Token

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
callbackfunctionyes   a function that returns error and response

meshbluHttp.generateAndStoreToken('fancy_uuid', function(error, response){
  // code goes here
})

Generate And Store Token With Options

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
optionsobjectnoan object containing the options for the token
callbackfunctionyes   a function that returns error and response

meshbluHttp.generateAndStoreTokenWithOptions('fancy_uuid', {expiresOn: '1485452874'},
  function(error, response){
    // code goes here
  }
)

Generate Key Pair

ParameterTypeRequiredDescription
none   

meshbluHttp.generateKeyPair()

Health Check

ParameterTypeRequiredDescription
callbackfunctionyes   a function that returns error, healthy, and code

meshbluHttp.healthcheck(function(error, healthy, code){
  // code goes here
})

Message

ParameterTypeRequiredDescription
messageobjectyesan object containing the message to send
metadataobjectno   an object containing metadata information
callbackfunctionyes   a function that returns error and response

meshbluHttp.message({data: 'hello_message'}, function(error, response){
  // code goes here
})

My Devices

ParameterTypeRequiredDescription
queryobjectno   an object containing your query
callbackfunctionyes   a function that returns error and response

meshbluHttp.mydevices({type: 'drone'}, function(error, response){
  // code goes here
})

Public Key

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
callbackfunctionyes   a function that returns error and response

meshbluHttp.publicKey('fancy_uuid', function(error, response){
  // code goes here
})

Register

ParameterTypeRequiredDescription
optionsobjectyes   an object containing properties that you would like your device to have. Can be empty object
callbackfunctionyes   a function that returns error and response

meshbluHttp.register({color: 'blue'}, function(error, response){
  // code goes here
})

Reset Token

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
callbackfunctionyes   a function that returns error and response

meshbluHttp.resetToken('fancy_uuid', function(error, response){
  // code goes here
})

Revoke Token

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
tokenstringyes   a string containing the token of the device
callbackfunctionyes   a function that returns error and response

meshbluHttp.revokeToken('fancy_uuid', 'fancy_token', function(error, response){
  // code goes here
})

Revoke Token By Query

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
queryobjectyes   an object containing your query
callbackfunctionyes   a function that returns error and response

meshbluHttp.revokeTokenByQuery('fancy_uuid', {expiresOn: '1485452874'},
  function(error, response){
    // code goes here
  }
)

Search

ParameterTypeRequiredDescription
queryobjectyes   an object containing your query
metadataobjectyes  an object containing metadata information. Can be left empty
callbackfunctionyes   a function that returns error and response

meshbluHttp.search({type: 'drone'}, {as: 'another_uuid'},
  function(error, response){
    // code goes here
  }
)

Search Tokens

ParameterTypeRequiredDescription
queryobjectyes   an object containing your query
metadataobjectyes  an object containing metadata information. Can be left empty
callbackfunctionyes   a function that returns error and response

meshbluHttp.searchTokens({expiresOn: '1485452874'}, {as: 'another_uuid'},
  function(error, response){
    // code goes here
  }
)

Set Private Key

ParameterTypeRequiredDescription
privateKeystring/objectyes  a string or object containing your privateKey

meshbluHttp.setPrivateKey(privateKey)

Sign

ParameterTypeRequiredDescription
data    objectyes   an object containing the data you want to sign your privateKey with

meshbluHttp.sign(data)

Subscriptions

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid of the device
metadataobjectno   an object containing metadata information
callbackfunctionyes   a function that returns error and response

meshbluHttp.subscriptions('fancy_uuid', {as: 'another_uuid'},
  function(error, response){
    // code goes here
  }
)

Unregister

ParameterTypeRequiredDescription
deviceobjectyes   an object containing the device credentials
callbackfunctionyes   a function that returns error and response

meshbluHttp.unregister({uuid: 'abc', token: 'asd'}, function(error, response){
  // code goes here
})

Update

ParameterTypeRequiredDescription
uuidstringyes   a string containing the uuid
paramsobjectyes   an object containing the new changes to the device
metadataobjectno   an object containing metadata information
callbackfunctionyesa function that returns error and response

meshbluHttp.update('fancy_uuid', {color: 'green'}, function(error, response){
  // code goes here
})

Verify

ParameterTypeRequiredDescription
messagestring/objectyes   data for encrypting
signaturestringyes   this can be obtained from sign()

meshbluHttp.verify(message, signature)

Whoami

ParameterTypeRequiredDescription
callbackfunctionyesa function that returns error and response

meshbluHttp.whoami(function(error, response){
  // code goes here
})
10.2.0

8 years ago

10.1.0

8 years ago

10.0.7

8 years ago

10.0.6

8 years ago

10.0.5

8 years ago

10.0.4

8 years ago

10.0.3

8 years ago

10.0.2

8 years ago

10.0.1

8 years ago

10.0.0

8 years ago

9.9.0

8 years ago

9.8.0

8 years ago

9.7.3

8 years ago

9.7.2

8 years ago

9.7.1

8 years ago

9.7.0

8 years ago

9.6.0

8 years ago

9.5.0

8 years ago

9.4.3

8 years ago

9.4.2

8 years ago

9.4.1

8 years ago

9.4.0

8 years ago

9.3.4

8 years ago

9.3.3

8 years ago

9.3.2

8 years ago

9.3.1

8 years ago

9.3.0

8 years ago

9.2.0

8 years ago

9.1.0

9 years ago

9.0.0

9 years ago

8.1.0

9 years ago

8.0.0

9 years ago

7.4.0

9 years ago

7.3.0

9 years ago

7.2.1

9 years ago

7.2.0

9 years ago

7.1.0

9 years ago

7.0.0

9 years ago

6.0.3

9 years ago

6.0.2

9 years ago

5.5.0

9 years ago

5.4.0

9 years ago

5.3.3

9 years ago

5.1.1

9 years ago

5.3.2

9 years ago

5.3.1

9 years ago

5.3.0

9 years ago

5.2.0

9 years ago

5.1.0

9 years ago

5.0.2

9 years ago

5.0.1

9 years ago

4.2.1

9 years ago

4.2.0

9 years ago

4.1.0

9 years ago

4.0.4

9 years ago

4.0.3

9 years ago

4.0.2

9 years ago

4.0.1

9 years ago

4.0.0

9 years ago

3.10.3

9 years ago

3.10.2

9 years ago

3.10.1

9 years ago

3.10.0

9 years ago

3.9.0

9 years ago

3.8.0

9 years ago

3.7.0

9 years ago

3.6.0

10 years ago

3.5.11

10 years ago

3.5.10

10 years ago

3.5.9

10 years ago

3.5.8

10 years ago

3.5.7

10 years ago

3.5.6

10 years ago

3.5.5

10 years ago

3.5.4

10 years ago

3.5.3

10 years ago

3.5.2

10 years ago

3.5.1

10 years ago

3.5.0

10 years ago

3.4.1

10 years ago

3.4.0

10 years ago

3.3.0

10 years ago

3.2.1

10 years ago

3.1.0

10 years ago

3.0.0

10 years ago

2.8.0

10 years ago

2.7.0

10 years ago

2.6.0

10 years ago

2.5.0

10 years ago

2.4.0

10 years ago

2.3.0

10 years ago

2.2.0

10 years ago

2.1.0

10 years ago

2.0.5

10 years ago

2.0.4

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago