5.0.0 • Published 6 years ago

resin-register-device v5.0.0

Weekly downloads
50
License
Apache-2.0
Repository
github
Last release
6 years ago

resin-register-device

Resin.io device registration utilities.

npm version dependencies Build Status Build status Gitter(https://badges.gitter.im/Join Chat.svg)

Installation

Install resin-register-device by running:

$ npm install --save resin-register-device

Documentation

Resin-Register-Device exports a factory function, which must be called with a dependencies object, containing a configured resin-request instance.

Example:

deviceRegister = require('resin-register-device')({
	request: request # An instantiated resin-request instance
})

deviceRegister.generateUniqueKey()

Generate a random key, useful for both uuid and api key.

Example:

randomKey = deviceRegister.generateUniqueKey()
# randomKey is a randomly generated key that can be used as either a uuid or an api key
console.log(randomKey)

deviceRegister.register(Object options, Function callback)

Register a device with Resin.io.

Notice: You can use this function as a promise if you omit the callback argument.

The options object requires the following properties:

  • Number userId: The user id.
  • Number applicationId: The application id.
  • String uuid: The device's UUID.
  • String deviceType: The device type slug.
  • String deviceApiKey: The API key to create for the newly registered device.
  • String provisioningApiKey: The provisioning API Key.
  • String apiEndpoint: The API endpoint.

The callback gets called with two arguments: (error, deviceInfo), where deviceInfo is an object containing one property: the id for the device that was just registered.

Example:

deviceRegister.register
		userId: 199
		applicationId: 10350
		uuid: '...'
		deviceType: 'raspberry-pi'
		deviceApiKey: '...'
		provisioningApiKey: '...'
		apiEndpoint: 'https://api.resin.io'
	, (error, deviceInfo) ->
		throw error if error?
		console.log(deviceInfo) # { id }

Tests

Run the test suite by doing:

$ npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ npm run lint

Support

If you're having any problem, please raise an issue on GitHub.

License

The project is licensed under the Apache 2.0 license.

5.0.0

6 years ago

4.1.1

6 years ago

4.1.0

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.0

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago