diff --git a/.gitignore b/.gitignore index 0619f62e..fbfb4da8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules lib/ /.idea *.tgz +.vscode \ No newline at end of file diff --git a/src/Particle.js b/src/Particle.js index 90ff5039..3e664a28 100644 --- a/src/Particle.js +++ b/src/Particle.js @@ -1922,6 +1922,45 @@ class Particle { }); } + /** + * Get product device's configuration + * @param {Object} options Options for this API call + * @param {String} options.product Config for this product ID or slug + * @param {String} options.auth Access Token + * @param {String} options.deviceId Device ID to access + * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers. + * @param {Object} [options.context] Request context + * @returns {Promise} A promise + */ + getProductDeviceConfiguration({ auth, product, deviceId, headers, context }){ + return this.get({ + uri: `/v1/products/${product}/config/${deviceId}`, + auth, + headers, + context + }); + } + + /** + * Get product device's configuration schema + * @param {Object} options Options for this API call + * @param {String} options.product Config for this product ID or slug + * @param {String} options.auth Access Token + * @param {String} options.deviceId Device ID to access + * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers. + * @param {Object} [options.context] Request context + * @returns {Promise} A promise + */ + getProductDeviceConfigurationSchema({ auth, product, deviceId, headers, context }){ + headers.accept = 'application/schema+json'; + return this.get({ + uri: `/v1/products/${product}/config/${deviceId}`, + auth, + headers, + context + }); + } + /** * Set product configuration * @param {Object} options Options for this API call diff --git a/test/Particle.spec.js b/test/Particle.spec.js index b7bde351..3c105818 100644 --- a/test/Particle.spec.js +++ b/test/Particle.spec.js @@ -2341,6 +2341,31 @@ describe('ParticleAPI', () => { }); }); + describe('.getProductDeviceConfiguration', () => { + it('generates request', () => { + return api.getProductDeviceConfiguration(propsWithProduct).then((results) => { + results.should.match({ + method: 'get', + uri: `/v1/products/${product}/config/${props.deviceId}`, + auth: props.auth + }); + }); + }); + }); + + describe('.getProductDeviceConfigurationSchema', () => { + it('generates request', () => { + return api.getProductDeviceConfigurationSchema(propsWithProduct).then((results) => { + results.should.match({ + method: 'get', + uri: `/v1/products/${product}/config/${props.deviceId}`, + auth: props.auth, + headers: { 'accept': 'application/schema+json' } + }); + }); + }); + }); + describe('.setProductConfiguration', () => { it('generates request', () => { const p = Object.assign({ config: {