Skip to content

Commit 30c5c05

Browse files
author
Joe Goggins
committed
Introduce setDefaultAuth(auth) top level method
1 parent e74c61b commit 30c5c05

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Particle.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,15 @@ class Particle {
20992099
});
21002100
}
21012101

2102+
/**
2103+
* Set default auth token that will be used in each method if `auth` is not provided
2104+
* @param {String} auth A Particle access token
2105+
* @returns {undefined}
2106+
*/
2107+
setDefaultAuth(auth){
2108+
this._defaultAuth = auth;
2109+
}
2110+
21022111
/**
21032112
* API URI to access a device
21042113
* @param {Object} options Options for this API call

test/Particle.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,4 +2716,16 @@ describe('ParticleAPI', () => {
27162716
expect(api.agent.setBaseUrl.firstCall.args[0]).to.eql(baseUrl);
27172717
});
27182718
});
2719+
2720+
describe('setDefaultAuth(auth)', () => {
2721+
afterEach(() => {
2722+
sinon.restore();
2723+
});
2724+
2725+
it('sets ._defaultAuth', () => {
2726+
const auth = 'foo';
2727+
api.setDefaultAuth(auth);
2728+
expect(api._defaultAuth).to.eql(auth);
2729+
});
2730+
});
27192731
});

0 commit comments

Comments
 (0)