Skip to content

Commit

Permalink
Merge pull request #20 from PlayNetwork/v1.0.20
Browse files Browse the repository at this point in the history
adding ability to retrieve version from each API consumed via the SDK
  • Loading branch information
brozeph committed Jun 10, 2016
2 parents 00dc49e + 22e3269 commit 14faaef
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 2 deletions.
4 changes: 4 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.0.20 - 2016/06/10

* Added `#version` method to each sub-module

# v1.0.19 - 2016/06/01

* Fixed typo in documentation for `playback` sub-module
Expand Down
10 changes: 9 additions & 1 deletion lib/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ module.exports = function (claimOptions, ensureAuthHeaders, self) {
req.on(EVENT_REQUEST, (data) => (self.emit(EVENT_REQUEST, data)));
req.on(EVENT_RESPONSE, (data) => (self.emit(EVENT_RESPONSE, data)));

self.settings = () => (settings);

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v0/version'
});
});

self.settings = () => (settings);
return validation.promiseOrCallback(exec, callback);
};

return self;
};
10 changes: 10 additions & 0 deletions lib/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,15 @@ module.exports = function (contentOptions, ensureAuthHeaders, self) {

self.settings = () => (settings);

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v0/version'
});
});

return validation.promiseOrCallback(exec, callback);
};

return self;
};
10 changes: 10 additions & 0 deletions lib/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,5 +415,15 @@ module.exports = function (deviceOptions, ensureAuthHeaders, self) {

self.settings = () => (settings);

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v0/version'
});
});

return validation.promiseOrCallback(exec, callback);
};

return self;
};
10 changes: 10 additions & 0 deletions lib/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,15 @@ module.exports = function (keyOptions, clientId, secret, self) {

self.settings = () => (settings);

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v0/version'
});
});

return validation.promiseOrCallback(exec, callback);
};

return self;
};
10 changes: 10 additions & 0 deletions lib/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,5 +777,15 @@ module.exports = function (musicOptions, ensureAuthHeaders, self) {
return validation.promiseOrCallback(exec, callback);
};

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v2/version'
});
});

return validation.promiseOrCallback(exec, callback);
};

return self;
};
10 changes: 10 additions & 0 deletions lib/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,15 @@ module.exports = function (playbackOptions, ensureAuthHeaders, self) {

self.settings = () => (settings);

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v1/version'
});
});

return validation.promiseOrCallback(exec, callback);
};

return self;
};
10 changes: 10 additions & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,15 @@ module.exports = function (settingsOptions, ensureAuthHeaders, self) {
return validation.promiseOrCallback(exec, callback);
};

self.version = (callback) => {
let exec = co(function *() {
return yield req.get({
pathname : '/v0/version'
});
});

return validation.promiseOrCallback(exec, callback);
};

return self;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playnetwork-sdk",
"version": "1.0.19",
"version": "1.0.20",
"contributors": [
{
"name": "Joshua Thomas",
Expand Down
33 changes: 33 additions & 0 deletions test/lib/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,37 @@ describe('content', () => {
});
});
});

describe('#version', () => {
it('should properly return version (promise)', (done) => {
// intercept outbound request
nock('https://content-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

content.version()
.then((result) => {
should.exist(result);
should.exist(requestInfo);

return done();
})
.catch(done);
});

it('should properly return version (callback)', (done) => {
// intercept outbound request
nock('https://content-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

content.version(function (err, result) {
should.not.exist(err);
should.exist(result);
should.exist(requestInfo);

return done();
});
});
});
});
33 changes: 33 additions & 0 deletions test/lib/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,4 +797,37 @@ describe('device', () => {
});
});
});

describe('#version', () => {
it('should properly return version (promise)', (done) => {
// intercept outbound request
nock('https://device-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

device.version()
.then((result) => {
should.exist(result);
should.exist(requestInfo);

return done();
})
.catch(done);
});

it('should properly return version (callback)', (done) => {
// intercept outbound request
nock('https://device-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

device.version(function (err, result) {
should.not.exist(err);
should.exist(result);
should.exist(requestInfo);

return done();
});
});
});
});
33 changes: 33 additions & 0 deletions test/lib/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,37 @@ describe('key', () => {
.catch(done);
});
});

describe('#version', () => {
it('should properly return version (promise)', (done) => {
// intercept outbound request
nock('https://key-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

key.version()
.then((result) => {
should.exist(result);
should.exist(requestInfo);

return done();
})
.catch(done);
});

it('should properly return version (callback)', (done) => {
// intercept outbound request
nock('https://key-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

key.version(function (err, result) {
should.not.exist(err);
should.exist(result);
should.exist(requestInfo);

return done();
});
});
});
});
33 changes: 33 additions & 0 deletions test/lib/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,4 +1412,37 @@ describe('music', () => {
});
});
});

describe('#version', () => {
it('should properly return version (promise)', (done) => {
// intercept outbound request
nock('https://curio-music-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

music.version()
.then((result) => {
should.exist(result);
should.exist(requestInfo);

return done();
})
.catch(done);
});

it('should properly return version (callback)', (done) => {
// intercept outbound request
nock('https://curio-music-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

music.version(function (err, result) {
should.not.exist(err);
should.exist(result);
should.exist(requestInfo);

return done();
});
});
});
});
33 changes: 33 additions & 0 deletions test/lib/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,37 @@ describe('playback', () => {
});
});
});

describe('#version', () => {
it('should properly return version (promise)', (done) => {
// intercept outbound request
nock('https://playback-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

playback.version()
.then((result) => {
should.exist(result);
should.exist(requestInfo);

return done();
})
.catch(done);
});

it('should properly return version (callback)', (done) => {
// intercept outbound request
nock('https://playback-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

playback.version(function (err, result) {
should.not.exist(err);
should.exist(result);
should.exist(requestInfo);

return done();
});
});
});
});
33 changes: 33 additions & 0 deletions test/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,37 @@ describe('settings', () => {
});
});
});

describe('#version', () => {
it('should properly return version (promise)', (done) => {
// intercept outbound request
nock('https://curio-settings-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

settings.version()
.then((result) => {
should.exist(result);
should.exist(requestInfo);

return done();
})
.catch(done);
});

it('should properly return version (callback)', (done) => {
// intercept outbound request
nock('https://curio-settings-api.apps.playnetwork.com')
.get(/\/v[0-9]{1}\/version/i)
.reply(200, { version : 'test' });

settings.version(function (err, result) {
should.not.exist(err);
should.exist(result);
should.exist(requestInfo);

return done();
});
});
});
});

0 comments on commit 14faaef

Please sign in to comment.