Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ node_modules
lib/
/.idea
*.tgz
.vscode
39 changes: 39 additions & 0 deletions src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/Particle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down