Skip to content

Commit

Permalink
Add ids key in body when saving/removing tracks - Fixes #193
Browse files Browse the repository at this point in the history
  • Loading branch information
JMPerez committed Apr 29, 2018
1 parent 803fe10 commit f0b6b52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions __tests__/spotify-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,9 @@ describe('Spotify Web API', () => {
callback
) {
expect(method).toBe(superagent.del);
expect(JSON.parse(options.data)).toEqual(['3VNWq8rTnQG6fM1eldSpZ0']);
expect(JSON.parse(options.data)).toEqual({
ids: ['3VNWq8rTnQG6fM1eldSpZ0']
});
expect(uri).toBe('https://api.spotify.com/v1/me/tracks');
expect(options.query).toBeFalsy();
callback();
Expand Down Expand Up @@ -3377,7 +3379,9 @@ describe('Spotify Web API', () => {
callback
) {
expect(method).toBe(superagent.put);
expect(JSON.parse(options.data)).toEqual(['3VNWq8rTnQG6fM1eldSpZ0']);
expect(JSON.parse(options.data)).toEqual({
ids: ['3VNWq8rTnQG6fM1eldSpZ0']
});
expect(uri).toBe('https://api.spotify.com/v1/me/tracks');
expect(options.query).toBeFalsy();
expect(options.headers.Authorization).toBe('Bearer myAccessToken');
Expand Down Expand Up @@ -3409,7 +3413,9 @@ describe('Spotify Web API', () => {
callback
) {
expect(method).toBe(superagent.put);
expect(JSON.parse(options.data)).toEqual(['3VNWq8rTnQG6fM1eldSpZ0']);
expect(JSON.parse(options.data)).toEqual({
ids: ['3VNWq8rTnQG6fM1eldSpZ0']
});
expect(uri).toBe('https://api.spotify.com/v1/me/tracks');
expect(options.query).toBeFalsy();
expect(options.headers.Authorization).toBe('Bearer myAccessToken');
Expand All @@ -3435,7 +3441,9 @@ describe('Spotify Web API', () => {
callback
) {
expect(method).toBe(superagent.put);
expect(JSON.parse(options.data)).toEqual(['3VNWq8rTnQG6fM1eldSpZ0']);
expect(JSON.parse(options.data)).toEqual({
ids: ['3VNWq8rTnQG6fM1eldSpZ0']
});
expect(uri).toBe('https://api.spotify.com/v1/me/tracks');
expect(options.query).toBeFalsy();
expect(options.headers.Authorization).toBe(
Expand Down Expand Up @@ -3472,7 +3480,9 @@ describe('Spotify Web API', () => {
callback
) {
expect(method).toBe(superagent.put);
expect(options.data).toEqual(JSON.stringify(['3VNWq8rTnQG6fM1eldSpZ0']));
expect(options.data).toEqual(
JSON.stringify({ ids: ['3VNWq8rTnQG6fM1eldSpZ0'] })
);
expect(uri).toBe('https://api.spotify.com/v1/me/tracks');
expect(options.query).toBeFalsy();
expect(options.headers.Authorization).toBe(
Expand Down
4 changes: 2 additions & 2 deletions src/spotify-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ SpotifyWebApi.prototype = {
return WebApiRequest.builder(this.getAccessToken())
.withPath('/v1/me/tracks')
.withHeaders({ 'Content-Type': 'application/json' })
.withBodyParameters(trackIds)
.withBodyParameters({ ids: trackIds })
.build()
.execute(HttpManager.del, callback);
},
Expand All @@ -989,7 +989,7 @@ SpotifyWebApi.prototype = {
return WebApiRequest.builder(this.getAccessToken())
.withPath('/v1/me/tracks')
.withHeaders({ 'Content-Type': 'application/json' })
.withBodyParameters(trackIds)
.withBodyParameters({ ids: trackIds })
.build()
.execute(HttpManager.put, callback);
},
Expand Down

0 comments on commit f0b6b52

Please sign in to comment.