particle-api-js 10.5.0 → 10.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +2 -4
- package/CHANGELOG.md +6 -0
- package/dist/particle.min.js +1 -1
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +171 -133
- package/package.json +1 -1
- package/src/Agent.js +4 -2
- package/src/Particle.js +54 -0
- package/test/Particle.spec.js +71 -0
package/package.json
CHANGED
package/src/Agent.js
CHANGED
|
@@ -255,8 +255,10 @@ class Agent {
|
|
|
255
255
|
}
|
|
256
256
|
if (query) {
|
|
257
257
|
const queryParams = qs.stringify(query);
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
if (queryParams) {
|
|
259
|
+
const hasParams = actualUri.includes('?');
|
|
260
|
+
actualUri = `${actualUri}${hasParams ? '&' : '?'}${queryParams}`;
|
|
261
|
+
}
|
|
260
262
|
}
|
|
261
263
|
|
|
262
264
|
const userAgentHeader = { 'User-Agent': `${packageJson.name}/${packageJson.version} (${packageJson.repository.url})` };
|
package/src/Particle.js
CHANGED
|
@@ -2631,6 +2631,60 @@ class Particle {
|
|
|
2631
2631
|
});
|
|
2632
2632
|
}
|
|
2633
2633
|
|
|
2634
|
+
/**
|
|
2635
|
+
* List Device OS versions
|
|
2636
|
+
*
|
|
2637
|
+
* @param {Object} options Options for this API call
|
|
2638
|
+
* @param {Number} [options.platformId] Platform ID to filter Device OS versions
|
|
2639
|
+
* @param {Number} [options.internalVersion] Internal version number to filter Device OS versions
|
|
2640
|
+
* @param {Number} [options.page] Page number for pagination
|
|
2641
|
+
* @param {Number} [options.perPage] Number of items per page
|
|
2642
|
+
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2643
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2644
|
+
* @param {Object} [options.context] Request context
|
|
2645
|
+
*
|
|
2646
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the list of Device OS versions.
|
|
2647
|
+
*/
|
|
2648
|
+
listDeviceOsVersions({ platformId, internalVersion, page, perPage, auth, headers, context }) {
|
|
2649
|
+
const query = {
|
|
2650
|
+
platform_id: platformId,
|
|
2651
|
+
internal_version: internalVersion,
|
|
2652
|
+
page,
|
|
2653
|
+
per_page: perPage
|
|
2654
|
+
};
|
|
2655
|
+
|
|
2656
|
+
return this.get({
|
|
2657
|
+
uri: '/v1/device-os/versions',
|
|
2658
|
+
query,
|
|
2659
|
+
auth,
|
|
2660
|
+
headers,
|
|
2661
|
+
context
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
/**
|
|
2666
|
+
* Get a specific Device OS version
|
|
2667
|
+
*
|
|
2668
|
+
* @param {Object} options Options for this API call
|
|
2669
|
+
* @param {String} options.version Version of the Device OS
|
|
2670
|
+
* @param {Number} [options.platformId] Optional platform ID to filter Device OS version
|
|
2671
|
+
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2672
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2673
|
+
* @param {Object} [options.context] Request context
|
|
2674
|
+
*
|
|
2675
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the specified Device OS version data.
|
|
2676
|
+
*/
|
|
2677
|
+
getDeviceOsVersion({ version, platformId, auth, headers, context }) {
|
|
2678
|
+
const query = platformId ? { platform_id: platformId } : {};
|
|
2679
|
+
return this.get({
|
|
2680
|
+
uri: `/v1/device-os/versions/${version}`,
|
|
2681
|
+
query,
|
|
2682
|
+
auth,
|
|
2683
|
+
headers,
|
|
2684
|
+
context
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2634
2688
|
/**
|
|
2635
2689
|
* Set default auth token that will be used in each method if `auth` is not provided
|
|
2636
2690
|
* @param {Auth} auth The access token or basic auth object
|
package/test/Particle.spec.js
CHANGED
|
@@ -2889,6 +2889,77 @@ describe('ParticleAPI', () => {
|
|
|
2889
2889
|
});
|
|
2890
2890
|
});
|
|
2891
2891
|
|
|
2892
|
+
describe('.listDeviceOsVersions', () => {
|
|
2893
|
+
it('generates request without optional parameters', () => {
|
|
2894
|
+
return api.listDeviceOsVersions({ auth: props.auth }).then((results) => {
|
|
2895
|
+
results.should.match({
|
|
2896
|
+
method: 'get',
|
|
2897
|
+
uri: '/v1/device-os/versions',
|
|
2898
|
+
auth: props.auth,
|
|
2899
|
+
query: {}
|
|
2900
|
+
});
|
|
2901
|
+
});
|
|
2902
|
+
});
|
|
2903
|
+
|
|
2904
|
+
it('generates request with all optional parameters', () => {
|
|
2905
|
+
const options = {
|
|
2906
|
+
auth: props.auth,
|
|
2907
|
+
platformId: 6,
|
|
2908
|
+
internalVersion: '1.2.3',
|
|
2909
|
+
page: 2,
|
|
2910
|
+
perPage: 25
|
|
2911
|
+
};
|
|
2912
|
+
return api.listDeviceOsVersions(options).then((results) => {
|
|
2913
|
+
results.should.match({
|
|
2914
|
+
method: 'get',
|
|
2915
|
+
uri: '/v1/device-os/versions',
|
|
2916
|
+
auth: props.auth,
|
|
2917
|
+
query: {
|
|
2918
|
+
platform_id: 6,
|
|
2919
|
+
internal_version: '1.2.3',
|
|
2920
|
+
page: 2,
|
|
2921
|
+
per_page: 25
|
|
2922
|
+
}
|
|
2923
|
+
});
|
|
2924
|
+
});
|
|
2925
|
+
});
|
|
2926
|
+
});
|
|
2927
|
+
|
|
2928
|
+
describe('.getDeviceOsVersion', () => {
|
|
2929
|
+
it('generates request without optional parameters', () => {
|
|
2930
|
+
const options = {
|
|
2931
|
+
auth: props.auth,
|
|
2932
|
+
version: '1.2.3'
|
|
2933
|
+
};
|
|
2934
|
+
return api.getDeviceOsVersion(options).then((results) => {
|
|
2935
|
+
results.should.match({
|
|
2936
|
+
method: 'get',
|
|
2937
|
+
uri: '/v1/device-os/versions/1.2.3',
|
|
2938
|
+
auth: props.auth,
|
|
2939
|
+
query: {}
|
|
2940
|
+
});
|
|
2941
|
+
});
|
|
2942
|
+
});
|
|
2943
|
+
|
|
2944
|
+
it('generates request with platformId parameter', () => {
|
|
2945
|
+
const options = {
|
|
2946
|
+
auth: props.auth,
|
|
2947
|
+
version: '1.2.3',
|
|
2948
|
+
platformId: 6
|
|
2949
|
+
};
|
|
2950
|
+
return api.getDeviceOsVersion(options).then((results) => {
|
|
2951
|
+
results.should.match({
|
|
2952
|
+
method: 'get',
|
|
2953
|
+
uri: '/v1/device-os/versions/1.2.3',
|
|
2954
|
+
auth: props.auth,
|
|
2955
|
+
query: {
|
|
2956
|
+
platform_id: 6
|
|
2957
|
+
}
|
|
2958
|
+
});
|
|
2959
|
+
});
|
|
2960
|
+
});
|
|
2961
|
+
});
|
|
2962
|
+
|
|
2892
2963
|
describe('.unprotectDevice', () => {
|
|
2893
2964
|
it('generates request', () => {
|
|
2894
2965
|
return api.unprotectDevice(Object.assign({}, propsWithProduct, {
|