spotify-finder
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -57,2 +57,17 @@ var request = require('superagent') | ||
Client.prototype.getArtists = function (array_ids, callback) { | ||
var ids = array_ids.toString() | ||
this._request('/artists', { ids: ids }, callback) | ||
} | ||
Client.prototype.getTrack = function (id, callback) { | ||
var url = '/tracks/' + id | ||
this._request(url, null, callback) | ||
} | ||
Client.prototype.getTracks = function (array_ids, callback) { | ||
var ids = array_ids.toString() | ||
this._request('/tracks', { ids: ids }, callback) | ||
} | ||
module.exports = Client |
{ | ||
"name": "spotify-finder", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A Spotify API Client", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -79,2 +79,22 @@ # spotify-finder | ||
Get several artists by id | ||
```js | ||
client.getArtists(['15deb326635d69d0505434', '934da7155ec15deb32663'], function (err, artists) { | ||
//do something with artists | ||
}) | ||
``` | ||
Get an track by id | ||
```js | ||
client.getTrack('934da7155ec15deb32663', function (err, track) { | ||
//do something with track | ||
}) | ||
``` | ||
Get several tracks by id | ||
```js | ||
client.getTracks(['15deb326635d69d0505s', 'da7155ec15deb326635d69d'], function (err, tracks) { | ||
//do something with tracks | ||
}) | ||
``` | ||
## License MIT | ||
@@ -81,0 +101,0 @@ |
@@ -57,4 +57,4 @@ var test = require('tape') | ||
nock(endpoint) | ||
.get('/albums/' + id_album) | ||
.reply(200, { id: id_album }) | ||
.get('/albums/' + id_album) | ||
.reply(200, { id: id_album }) | ||
@@ -75,4 +75,4 @@ client.getAlbum(id_album, { tracks: false }, function (err, album) { | ||
nock(endpoint) | ||
.get('/albums/' + id_album + '/tracks') | ||
.reply(200, { items: [] }) | ||
.get('/albums/' + id_album + '/tracks') | ||
.reply(200, { items: [] }) | ||
@@ -85,3 +85,2 @@ client.getAlbum(id_album, { tracks: true }, function (err, tracks) { | ||
}) | ||
test('should get several albums', function (t) { | ||
@@ -146,3 +145,3 @@ var ids = ['67sdfahy4dertgd232dttt', '5asw67sad23q2tsdf232'] | ||
nock(endpoint) | ||
.get('/artists/' + id_artist + '/top-tracks') | ||
.get('/artists/' + id_artist + '/top-tracks') | ||
.query({ country: 'SE' }) | ||
@@ -164,3 +163,3 @@ .reply(200, { tracks: [] }) | ||
nock(endpoint) | ||
.get('/artists/' + id_artist + '/related-artists') | ||
.get('/artists/' + id_artist + '/related-artists') | ||
.query({ country: 'SE' }) | ||
@@ -175,1 +174,51 @@ .reply(200, { artists: [] }) | ||
}) | ||
test('should get several artist', function (t) { | ||
var ids = ['aweWEqewrw253462sda', 'sdar3tadsgdas4d2fy2'] | ||
var client = spotify.createClient({ endpoint: endpoint }) | ||
t.equals(typeof client.getArtists, 'function', 'should be a function') | ||
nock(endpoint) | ||
.get('/artists') | ||
.query({ ids: ids.toString() }) | ||
.reply(200, { artists: [] }) | ||
client.getArtists(ids.toString(), function (err, data) { | ||
t.error(err, 'should not be an error') | ||
t.ok(Array.isArray(data.artists), 'should be an Array of artists') | ||
t.end() | ||
}) | ||
}) | ||
test('should get an track', function (t) { | ||
var id_track = 'eGsygTp906u18L0Oimnem' | ||
var client = spotify.createClient({ endpoint: endpoint }) | ||
t.equals(typeof client.getTrack, 'function', 'should be an function') | ||
nock(endpoint) | ||
.get('/tracks/' + id_track) | ||
.reply(200, { id: id_track }) | ||
client.getTrack(id_track, function (err, track) { | ||
t.error(err, 'should not be an error') | ||
t.equals(track.id, id_track, 'should retrive a track id') | ||
t.end() | ||
}) | ||
}) | ||
test('should get several tracks', function (t) { | ||
var ids = ['0eGsygTp906u18L0Oimnem', 'dsadeTd465hfdg45hddsd'] | ||
var client = spotify.createClient({ endpoint: endpoint }) | ||
t.equals(typeof client.getTracks, 'function', 'should be an function') | ||
nock(endpoint) | ||
.get('/tracks') | ||
.query({ ids: ids.toString() }) | ||
.reply(200, { tracks: [] }) | ||
client.getTracks(ids.toString(), function (err, data) { | ||
t.error(err, 'should not be an error') | ||
t.ok(Array.isArray(data.tracks), 'should be an Array of tracks') | ||
t.end() | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13366
242
123