diff --git a/bower.json b/bower.json index a8caf53..387692b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-spotify", - "version": "0.9.1", + "version": "0.9.3", "authors": [ "Ed Moore " ], diff --git a/dist/angular-spotify.min.js b/dist/angular-spotify.min.js index f501e99..2237560 100644 --- a/dist/angular-spotify.min.js +++ b/dist/angular-spotify.min.js @@ -1,2 +1,2 @@ -/*! angular-spotify 2014-12-21 */ -(function(e,t,n){"use strict";t.module("spotify",[]).provider("Spotify",function(){var n={};n.clientId=null;n.redirectUri=null;n.scope=null;n.accessToken=null;this.setClientId=function(e){n.clientId=e;return n.clientId};this.getClientId=function(){return n.clientId};this.setRedirectUri=function(e){n.redirectUri=e;return n.redirectUri};this.getRedirectUri=function(){return n.redirectUri};this.setScope=function(e){n.scope=e;return n.scope};var r={};r.toQueryString=function(e){var n=[];t.forEach(e,function(e,t){this.push(encodeURIComponent(t)+"="+encodeURIComponent(e))},n);return n.join("&")};n.apiBase="https://api.spotify.com/v1";this.$get=["$q","$http","$window",function(i,s,o){function u(){this.clientId=n.clientId;this.redirectUri=n.redirectUri;this.apiBase=n.apiBase;this.scope=n.scope;this.accessToken=null;this.toQueryString=r.toQueryString}u.prototype.api=function(e,t,n,r,o){var u=i.defer();s({url:this.apiBase+e,method:t?t:"GET",params:n,data:r,headers:o}).success(function(e){u.resolve(e)}).error(function(e){u.reject(e)});return u.promise};u.prototype.search=function(e,t,n){n=n||{};n.q=e;n.type=t;return this.api("/search","GET",n)};u.prototype.getAlbum=function(e){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/albums/"+e)};u.prototype.getAlbums=function(e){e=t.isString(e)?e.split(","):e;t.forEach(e,function(t,n){e[n]=t.indexOf("spotify:")>-1?t.split(":")[2]:t});return this.api("/albums","GET",{ids:e?e.toString():""})};u.prototype.getAlbumTracks=function(e,t){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/albums/"+e+"/tracks","GET",t)};u.prototype.getArtist=function(e){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/artists/"+e)};u.prototype.getArtists=function(e){e=t.isString(e)?e.split(","):e;t.forEach(e,function(t,n){e[n]=t.indexOf("spotify:")>-1?t.split(":")[2]:t});return this.api("/artists/","GET",{ids:e?e.toString():""})};u.prototype.getArtistAlbums=function(e,t){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/artists/"+e+"/albums","GET",t)};u.prototype.getArtistTopTracks=function(e,t){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/artists/"+e+"/top-tracks","GET",{country:t})};u.prototype.getRelatedArtists=function(e){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/artists/"+e+"/related-artists")};u.prototype.getTrack=function(e){e=e.indexOf("spotify:")===-1?e:e.split(":")[2];return this.api("/tracks/"+e)};u.prototype.getTracks=function(e){e=t.isString(e)?e.split(","):e;t.forEach(e,function(t,n){e[n]=t.indexOf("spotify:")>-1?t.split(":")[2]:t});return this.api("/tracks/","GET",{ids:e?e.toString():""})};u.prototype.getUserPlaylists=function(e,t){return this.api("/users/"+e+"/playlists","GET",t,null,{Authorization:"Bearer "+this.authToken})};u.prototype.getPlaylist=function(e,t,n){return this.api("/users/"+e+"/playlists/"+t,"GET",n,null,{Authorization:"Bearer "+this.authToken})};u.prototype.getPlaylistTracks=function(e,t,n){return this.api("/users/"+e+"/playlists/"+t+"/tracks","GET",n,null,{Authorization:"Bearer "+this.authToken})};u.prototype.createPlaylist=function(e,t){return this.api("/users/"+e+"/playlists","POST",null,t,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})};u.prototype.addPlaylistTracks=function(e,n,r,i){r=t.isArray(r)?r:r.split(",");t.forEach(r,function(e,t){r[t]=e.indexOf("spotify:")===-1?"spotify:track:"+e:e});return this.api("/users/"+e+"/playlists/"+n+"/tracks","POST",{uris:r.toString(),position:i?i.position:null},null,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})};u.prototype.removePlaylistTracks=function(e,n,r){r=t.isArray(r)?r:r.split(",");var i;t.forEach(r,function(e,t){i=r[t];r[t]={uri:i.indexOf("spotify:")===-1?"spotify:track:"+i:i}});return this.api("/users/"+e+"/playlists/"+n+"/tracks","DELETE",null,{tracks:r},{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})};u.prototype.replacePlaylistTracks=function(e,n,r){r=t.isArray(r)?r:r.split(",");var i;t.forEach(r,function(e,t){i=r[t];r[t]=i.indexOf("spotify:")===-1?"spotify:track:"+i:i});return this.api("/users/"+e+"/playlists/"+n+"/tracks","PUT",{uris:r.toString()},null,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})};u.prototype.updatePlaylistDetails=function(e,t,n){return this.api("/users/"+e+"/playlists/"+t,"PUT",null,n,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})};u.prototype.getUser=function(e){return this.api("/users/"+e)};u.prototype.getCurrentUser=function(){return this.api("/me","GET",null,null,{Authorization:"Bearer "+this.authToken})};u.prototype.getSavedUserTracks=function(e){return this.api("/me/tracks","GET",e,null,{Authorization:"Bearer "+this.authToken})};u.prototype.userTracksContains=function(e){e=t.isString(e)?e.split(","):e;t.forEach(e,function(t,n){e[n]=t.indexOf("spotify:")>-1?t.split(":")[2]:t});return this.api("/me/tracks/contains","GET",{ids:e.toString()},null,{Authorization:"Bearer "+this.authToken})};u.prototype.saveUserTracks=function(e){e=t.isString(e)?e.split(","):e;t.forEach(e,function(t,n){e[n]=t.indexOf("spotify:")>-1?t.split(":")[2]:t});return this.api("/me/tracks","PUT",{ids:e.toString()},null,{Authorization:"Bearer "+this.authToken})};u.prototype.removeUserTracks=function(e){e=t.isString(e)?e.split(","):e;t.forEach(e,function(t,n){e[n]=t.indexOf("spotify:")>-1?t.split(":")[2]:t});return this.api("/me/tracks","DELETE",{ids:e.toString()},null,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})};u.prototype.getFeaturedPlaylists=function(e){return this.api("/browse/featured-playlists","GET",e,null,{Authorization:"Bearer "+this.authToken})};u.prototype.getNewReleases=function(e){return this.api("/browse/new-releases","GET",e,null,{Authorization:"Bearer "+this.authToken})};u.prototype.setAuthToken=function(e){this.authToken=e;return this.authToken};u.prototype.login=function(){function c(e){if(e.key==="spotify-token"){if(l){l.close()}n.setAuthToken(e.newValue);o.removeEventListener("storage",c,false);t.resolve(e.newValue)}}var t=i.defer();var n=this;var r=400,s=500,u=screen.width/2-r/2,a=screen.height/2-s/2;var f={client_id:this.clientId,redirect_uri:this.redirectUri,scope:this.scope||"",response_type:"token"};var l=e.open("https://accounts.spotify.com/authorize?"+this.toQueryString(f),"Spotify","menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width="+r+",height="+s+",top="+a+",left="+u);o.addEventListener("storage",c,false);return t.promise};return new u}]})})(window,angular) \ No newline at end of file +/*! angular-spotify 2014-12-22 */ +!function(a,b){"use strict";b.module("spotify",[]).provider("Spotify",function(){var c={};c.clientId=null,c.redirectUri=null,c.scope=null,c.accessToken=null,this.setClientId=function(a){return c.clientId=a,c.clientId},this.getClientId=function(){return c.clientId},this.setRedirectUri=function(a){return c.redirectUri=a,c.redirectUri},this.getRedirectUri=function(){return c.redirectUri},this.setScope=function(a){return c.scope=a,c.scope};var d={};d.toQueryString=function(a){var c=[];return b.forEach(a,function(a,b){this.push(encodeURIComponent(b)+"="+encodeURIComponent(a))},c),c.join("&")},c.apiBase="https://api.spotify.com/v1",this.$get=["$q","$http","$window",function(e,f,g){function h(){this.clientId=c.clientId,this.redirectUri=c.redirectUri,this.apiBase=c.apiBase,this.scope=c.scope,this.accessToken=null,this.toQueryString=d.toQueryString}return h.prototype.api=function(a,b,c,d,g){var h=e.defer();return f({url:this.apiBase+a,method:b?b:"GET",params:c,data:d,headers:g}).success(function(a){h.resolve(a)}).error(function(a){h.reject(a)}),h.promise},h.prototype.search=function(a,b,c){return c=c||{},c.q=a,c.type=b,this.api("/search","GET",c)},h.prototype.getAlbum=function(a){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/albums/"+a)},h.prototype.getAlbums=function(a){return a=b.isString(a)?a.split(","):a,b.forEach(a,function(b,c){a[c]=b.indexOf("spotify:")>-1?b.split(":")[2]:b}),this.api("/albums","GET",{ids:a?a.toString():""})},h.prototype.getAlbumTracks=function(a,b){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/albums/"+a+"/tracks","GET",b)},h.prototype.getArtist=function(a){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/artists/"+a)},h.prototype.getArtists=function(a){return a=b.isString(a)?a.split(","):a,b.forEach(a,function(b,c){a[c]=b.indexOf("spotify:")>-1?b.split(":")[2]:b}),this.api("/artists/","GET",{ids:a?a.toString():""})},h.prototype.getArtistAlbums=function(a,b){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/artists/"+a+"/albums","GET",b)},h.prototype.getArtistTopTracks=function(a,b){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/artists/"+a+"/top-tracks","GET",{country:b})},h.prototype.getRelatedArtists=function(a){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/artists/"+a+"/related-artists")},h.prototype.getTrack=function(a){return a=-1===a.indexOf("spotify:")?a:a.split(":")[2],this.api("/tracks/"+a)},h.prototype.getTracks=function(a){return a=b.isString(a)?a.split(","):a,b.forEach(a,function(b,c){a[c]=b.indexOf("spotify:")>-1?b.split(":")[2]:b}),this.api("/tracks/","GET",{ids:a?a.toString():""})},h.prototype.getUserPlaylists=function(a,b){return this.api("/users/"+a+"/playlists","GET",b,null,{Authorization:"Bearer "+this.authToken})},h.prototype.getPlaylist=function(a,b,c){return this.api("/users/"+a+"/playlists/"+b,"GET",c,null,{Authorization:"Bearer "+this.authToken})},h.prototype.getPlaylistTracks=function(a,b,c){return this.api("/users/"+a+"/playlists/"+b+"/tracks","GET",c,null,{Authorization:"Bearer "+this.authToken})},h.prototype.createPlaylist=function(a,b){return this.api("/users/"+a+"/playlists","POST",null,b,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})},h.prototype.addPlaylistTracks=function(a,c,d,e){return d=b.isArray(d)?d:d.split(","),b.forEach(d,function(a,b){d[b]=-1===a.indexOf("spotify:")?"spotify:track:"+a:a}),this.api("/users/"+a+"/playlists/"+c+"/tracks","POST",{uris:d.toString(),position:e?e.position:null},null,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})},h.prototype.removePlaylistTracks=function(a,c,d){d=b.isArray(d)?d:d.split(",");var e;return b.forEach(d,function(a,b){e=d[b],d[b]={uri:-1===e.indexOf("spotify:")?"spotify:track:"+e:e}}),this.api("/users/"+a+"/playlists/"+c+"/tracks","DELETE",null,{tracks:d},{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})},h.prototype.replacePlaylistTracks=function(a,c,d){d=b.isArray(d)?d:d.split(",");var e;return b.forEach(d,function(a,b){e=d[b],d[b]=-1===e.indexOf("spotify:")?"spotify:track:"+e:e}),this.api("/users/"+a+"/playlists/"+c+"/tracks","PUT",{uris:d.toString()},null,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})},h.prototype.updatePlaylistDetails=function(a,b,c){return this.api("/users/"+a+"/playlists/"+b,"PUT",null,c,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})},h.prototype.getUser=function(a){return this.api("/users/"+a)},h.prototype.getCurrentUser=function(){return this.api("/me","GET",null,null,{Authorization:"Bearer "+this.authToken})},h.prototype.getSavedUserTracks=function(a){return this.api("/me/tracks","GET",a,null,{Authorization:"Bearer "+this.authToken})},h.prototype.userTracksContains=function(a){return a=b.isString(a)?a.split(","):a,b.forEach(a,function(b,c){a[c]=b.indexOf("spotify:")>-1?b.split(":")[2]:b}),this.api("/me/tracks/contains","GET",{ids:a.toString()},null,{Authorization:"Bearer "+this.authToken})},h.prototype.saveUserTracks=function(a){return a=b.isString(a)?a.split(","):a,b.forEach(a,function(b,c){a[c]=b.indexOf("spotify:")>-1?b.split(":")[2]:b}),this.api("/me/tracks","PUT",{ids:a.toString()},null,{Authorization:"Bearer "+this.authToken})},h.prototype.removeUserTracks=function(a){return a=b.isString(a)?a.split(","):a,b.forEach(a,function(b,c){a[c]=b.indexOf("spotify:")>-1?b.split(":")[2]:b}),this.api("/me/tracks","DELETE",{ids:a.toString()},null,{Authorization:"Bearer "+this.authToken,"Content-Type":"application/json"})},h.prototype.getFeaturedPlaylists=function(a){return this.api("/browse/featured-playlists","GET",a,null,{Authorization:"Bearer "+this.authToken})},h.prototype.getNewReleases=function(a){return this.api("/browse/new-releases","GET",a,null,{Authorization:"Bearer "+this.authToken})},h.prototype.setAuthToken=function(a){return this.authToken=a,this.authToken},h.prototype.login=function(){function b(a){"spotify-token"===a.key&&(l&&l.close(),d.setAuthToken(a.newValue),g.removeEventListener("storage",b,!1),c.resolve(a.newValue))}var c=e.defer(),d=this,f=400,h=500,i=screen.width/2-f/2,j=screen.height/2-h/2,k={client_id:this.clientId,redirect_uri:this.redirectUri,scope:this.scope||"",response_type:"token"},l=a.open("https://accounts.spotify.com/authorize?"+this.toQueryString(k),"Spotify","menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width="+f+",height="+h+",top="+j+",left="+i);return g.addEventListener("storage",b,!1),c.promise},new h}]})}(window,angular); \ No newline at end of file diff --git a/package.json b/package.json index c370004..5937360 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-spotify", - "version": "0.9.1", + "version": "0.9.3", "description": "Angular Service to connect to Spotify Web API", "main": "Gruntfile.js", "devDependencies": { diff --git a/src/angular-spotify.js b/src/angular-spotify.js index 454f05e..2edc084 100644 --- a/src/angular-spotify.js +++ b/src/angular-spotify.js @@ -344,7 +344,7 @@ }; /** - ====================== Bowse ===================== + ====================== Browse ===================== */ NgSpotify.prototype.getFeaturedPlaylists = function (options) { return this.api('/browse/featured-playlists', 'GET', options, null, { diff --git a/test/mock/featured-playlists.json b/test/mock/featured-playlists.json new file mode 100644 index 0000000..7fc4884 --- /dev/null +++ b/test/mock/featured-playlists.json @@ -0,0 +1,336 @@ +{ + "message" : "Coffee and music – a perfect pairing!", + "playlists" : { + "href" : "https://api.spotify.com/v1/browse/featured-playlists?timestamp=2014-12-22T11:24:34&offset=0&limit=20", + "items" : [ { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/4BKT5olNFqLB1FAa8OtC8k" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/4BKT5olNFqLB1FAa8OtC8k", + "id" : "4BKT5olNFqLB1FAa8OtC8k", + "images" : [ { + "url" : "https://i.scdn.co/image/248213a045c2f086f427692085827fb1feb70645" + } ], + "name" : "Your Favorite Coffeehouse", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/4BKT5olNFqLB1FAa8OtC8k/tracks", + "total" : 84 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:4BKT5olNFqLB1FAa8OtC8k" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/5FJXhjdILmRA2z5bvz4nzf" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/5FJXhjdILmRA2z5bvz4nzf", + "id" : "5FJXhjdILmRA2z5bvz4nzf", + "images" : [ { + "url" : "https://i.scdn.co/image/3618cc1fa353d0dc720ecbd902de23c980fc1b31" + } ], + "name" : "Today's Top Hits", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/5FJXhjdILmRA2z5bvz4nzf/tracks", + "total" : 50 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:5FJXhjdILmRA2z5bvz4nzf" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/2ujjMpFriZ2nayLmrD1Jgl" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/2ujjMpFriZ2nayLmrD1Jgl", + "id" : "2ujjMpFriZ2nayLmrD1Jgl", + "images" : [ { + "url" : "https://i.scdn.co/image/c6ae992ff7b6b9e49bea3b76e3d739ef2f1b1fb2" + } ], + "name" : "Deep Focus", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/2ujjMpFriZ2nayLmrD1Jgl/tracks", + "total" : 98 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:2ujjMpFriZ2nayLmrD1Jgl" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/5UFRIQ89nVPcVsrWjLyjqI" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/5UFRIQ89nVPcVsrWjLyjqI", + "id" : "5UFRIQ89nVPcVsrWjLyjqI", + "images" : [ { + "url" : "https://i.scdn.co/image/9c320a0e9f484ac3668678ae9ee1338fd31e1a7b" + } ], + "name" : "Caffeine Rush", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/5UFRIQ89nVPcVsrWjLyjqI/tracks", + "total" : 71 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:5UFRIQ89nVPcVsrWjLyjqI" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/0ExbFrTy6ypLj9YYNMTnmd" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/0ExbFrTy6ypLj9YYNMTnmd", + "id" : "0ExbFrTy6ypLj9YYNMTnmd", + "images" : [ { + "url" : "https://i.scdn.co/image/52a250248c75034207a34a56248c6686ab2b70eb" + } ], + "name" : "Intense Studying", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/0ExbFrTy6ypLj9YYNMTnmd/tracks", + "total" : 142 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:0ExbFrTy6ypLj9YYNMTnmd" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/74lsbDpc3vMNHHwD0w07ke" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/74lsbDpc3vMNHHwD0w07ke", + "id" : "74lsbDpc3vMNHHwD0w07ke", + "images" : [ { + "url" : "https://i.scdn.co/image/6684e0debbbe7ca94d7eb96c1a186d7bbb2d366e" + } ], + "name" : "Country Coffeehouse", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/74lsbDpc3vMNHHwD0w07ke/tracks", + "total" : 32 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:74lsbDpc3vMNHHwD0w07ke" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/19uVLpMdgv0Dy3LvpYx4LA" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/19uVLpMdgv0Dy3LvpYx4LA", + "id" : "19uVLpMdgv0Dy3LvpYx4LA", + "images" : [ { + "url" : "https://i.scdn.co/image/7feba1395174bd9bc16f1babafffe8570a5ef3c7" + } ], + "name" : "Workday – Lounge", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/19uVLpMdgv0Dy3LvpYx4LA/tracks", + "total" : 95 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:19uVLpMdgv0Dy3LvpYx4LA" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/65y98W0UItf73DJKVgylTP" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/65y98W0UItf73DJKVgylTP", + "id" : "65y98W0UItf73DJKVgylTP", + "images" : [ { + "url" : "https://i.scdn.co/image/223eaea3d44938b833a86651267db608bea1c5a3" + } ], + "name" : "ESM | Electronic Study Music", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/65y98W0UItf73DJKVgylTP/tracks", + "total" : 53 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:65y98W0UItf73DJKVgylTP" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/2SSEozHbLRKueJBM7LAlAo" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/2SSEozHbLRKueJBM7LAlAo", + "id" : "2SSEozHbLRKueJBM7LAlAo", + "images" : [ { + "url" : "https://i.scdn.co/image/8a6deaff6a3af92a9b9fd923e98e22c5acb65e56" + } ], + "name" : "Workday – Pop", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/2SSEozHbLRKueJBM7LAlAo/tracks", + "total" : 128 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:2SSEozHbLRKueJBM7LAlAo" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/7cOO30bzxMm4tO34C9UalD" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/7cOO30bzxMm4tO34C9UalD", + "id" : "7cOO30bzxMm4tO34C9UalD", + "images" : [ { + "url" : "https://i.scdn.co/image/acf2d1cdd5fa27b589262aba943e8c3b170e014e" + } ], + "name" : "Cardio", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/7cOO30bzxMm4tO34C9UalD/tracks", + "total" : 45 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:7cOO30bzxMm4tO34C9UalD" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/5O2ERf8kAYARVVdfCKZ9G7" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/5O2ERf8kAYARVVdfCKZ9G7", + "id" : "5O2ERf8kAYARVVdfCKZ9G7", + "images" : [ { + "url" : "https://i.scdn.co/image/34baf4085738a1e2ad1b426d1fa2d1e64a5bd856" + } ], + "name" : "Coffee Table Jazz", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/5O2ERf8kAYARVVdfCKZ9G7/tracks", + "total" : 57 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:5O2ERf8kAYARVVdfCKZ9G7" + }, { + "collaborative" : false, + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify/playlist/67nMZWgcUxNa5uaiyLDR2x" + }, + "href" : "https://api.spotify.com/v1/users/spotify/playlists/67nMZWgcUxNa5uaiyLDR2x", + "id" : "67nMZWgcUxNa5uaiyLDR2x", + "images" : [ { + "url" : "https://i.scdn.co/image/a69b2bd382b17654cb57c42ab276097c9a7367da" + } ], + "name" : "Brain Food", + "owner" : { + "external_urls" : { + "spotify" : "http://open.spotify.com/user/spotify" + }, + "href" : "https://api.spotify.com/v1/users/spotify", + "id" : "spotify", + "type" : "user", + "uri" : "spotify:user:spotify" + }, + "public" : null, + "tracks" : { + "href" : "https://api.spotify.com/v1/users/spotify/playlists/67nMZWgcUxNa5uaiyLDR2x/tracks", + "total" : 90 + }, + "type" : "playlist", + "uri" : "spotify:user:spotify:playlist:67nMZWgcUxNa5uaiyLDR2x" + } ], + "limit" : 20, + "next" : null, + "offset" : 0, + "previous" : null, + "total" : 12 + } +} \ No newline at end of file diff --git a/test/mock/new-releases.json b/test/mock/new-releases.json new file mode 100644 index 0000000..a4c0f0c --- /dev/null +++ b/test/mock/new-releases.json @@ -0,0 +1,491 @@ +{ + "albums" : { + "href" : "https://api.spotify.com/v1/browse/new-releases?offset=0&limit=20", + "items" : [ { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "ES", "FR", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "MC", "MT", "MX", "MY", "NI", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SG", "SI", "SK", "SV", "TR", "TW", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/60mvULtYiNSRmpVvoa3RE4" + }, + "href" : "https://api.spotify.com/v1/albums/60mvULtYiNSRmpVvoa3RE4", + "id" : "60mvULtYiNSRmpVvoa3RE4", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/8642802d13a53541e313781c34521a0d33099aac", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/631ee4d5160303af86751587457b1b00957e0519", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/d7b7140400d985d1294d7b044da1b5b4bfc0ae69", + "width" : 64 + } ], + "name" : "We Are One (Ole Ola) [The Official 2014 FIFA World Cup Song]", + "type" : "album", + "uri" : "spotify:album:60mvULtYiNSRmpVvoa3RE4" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/4JXziyWNlxM4oPw34PMjVj" + }, + "href" : "https://api.spotify.com/v1/albums/4JXziyWNlxM4oPw34PMjVj", + "id" : "4JXziyWNlxM4oPw34PMjVj", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/47c6249a3d514752fc783e64a2f47611bce66a4b", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/a22dbdd2595f1144890eb269bb93cc79142f2767", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/c1bd45015d6a1245603a88e03d336992f5d653a2", + "width" : 64 + } ], + "name" : "A13", + "type" : "album", + "uri" : "spotify:album:4JXziyWNlxM4oPw34PMjVj" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AU", "BE", "BG", "BO", "BR", "CA", "CL", "CO", "CR", "CY", "CZ", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/1SIpLwZu1R69coxKMH06kw" + }, + "href" : "https://api.spotify.com/v1/albums/1SIpLwZu1R69coxKMH06kw", + "id" : "1SIpLwZu1R69coxKMH06kw", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/c65ef9bb11bcd9d06aa710866fb3440291c5f9ea", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/8db5eeba539b7eabe7599e13e7bd83b8ec9f98bb", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/abfb50b9844def2e40afac4059da71d658845ab2", + "width" : 64 + } ], + "name" : "May Death Never Stop You", + "type" : "album", + "uri" : "spotify:album:1SIpLwZu1R69coxKMH06kw" + }, { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/5qZNAZ5xJCUAiyYoETU0aj" + }, + "href" : "https://api.spotify.com/v1/albums/5qZNAZ5xJCUAiyYoETU0aj", + "id" : "5qZNAZ5xJCUAiyYoETU0aj", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/86c15f11c44726c52df044882e39e6c4d168f8a8", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/f7e52154d6ea994ea9e78dd8b1ab0d37417934ef", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/2a5c218cb7e524c5bd95b938b3553905311705da", + "width" : 64 + } ], + "name" : "Keep Watch", + "type" : "album", + "uri" : "spotify:album:5qZNAZ5xJCUAiyYoETU0aj" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/5ZzFFF7wSMmGaIWjAHElnW" + }, + "href" : "https://api.spotify.com/v1/albums/5ZzFFF7wSMmGaIWjAHElnW", + "id" : "5ZzFFF7wSMmGaIWjAHElnW", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/aa1d1cf0d70fb29b4ae575f10d2ac8acc88413f5", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/aed60ab4e13c6cd781df8dcd2375c2b186ae1991", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/058e4170c906814ee70fb51ae1d84d09d5244979", + "width" : 64 + } ], + "name" : "By Any Means", + "type" : "album", + "uri" : "spotify:album:5ZzFFF7wSMmGaIWjAHElnW" + }, { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/0LKHTm8YOJH9ygGm8DWv40" + }, + "href" : "https://api.spotify.com/v1/albums/0LKHTm8YOJH9ygGm8DWv40", + "id" : "0LKHTm8YOJH9ygGm8DWv40", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/6b2eea62c1a6f986824e25ff4e0f072c515a9988", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/f9a46fb4f6f4ca0117c2d1ab530a36958921720b", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/06e3464983b24b9957828d10b6c2a34c6dddae9c", + "width" : 64 + } ], + "name" : "Depth of My Soul (feat. Shana Halligan)", + "type" : "album", + "uri" : "spotify:album:0LKHTm8YOJH9ygGm8DWv40" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/1dKh4z5Aayt8FFDWjO5FDh" + }, + "href" : "https://api.spotify.com/v1/albums/1dKh4z5Aayt8FFDWjO5FDh", + "id" : "1dKh4z5Aayt8FFDWjO5FDh", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/b2602ba2bd35dca1cc2903d58429a9379b342bf3", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/8b86d8c65c01dacc92305003559db960e36a9614", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/3eb58e564cc6ede9ac234c293e905e166cefa1b2", + "width" : 64 + } ], + "name" : "Singles", + "type" : "album", + "uri" : "spotify:album:1dKh4z5Aayt8FFDWjO5FDh" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/33jUyJOx4j6BWJ7VkzWoth" + }, + "href" : "https://api.spotify.com/v1/albums/33jUyJOx4j6BWJ7VkzWoth", + "id" : "33jUyJOx4j6BWJ7VkzWoth", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/e35451b38b162c4a8665b77e729c53a2437d6f74", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/f5baa64ff1928f27163516658b8301b92e54c80a", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/41f4c456d66bc81d4e10d502d707fb778c431798", + "width" : 64 + } ], + "name" : "Out Among The Stars", + "type" : "album", + "uri" : "spotify:album:33jUyJOx4j6BWJ7VkzWoth" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/4kE1w1zgP6Ag6Ojbuxzk7l" + }, + "href" : "https://api.spotify.com/v1/albums/4kE1w1zgP6Ag6Ojbuxzk7l", + "id" : "4kE1w1zgP6Ag6Ojbuxzk7l", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/c9eca97fd2817f349737dfe2aa672929759a556b", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/b131664fc60fc781b5bfe41a41763d4176abfdcb", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/5d2a8eeb9732f68c09c8c582ee5d028091fe1abf", + "width" : 64 + } ], + "name" : "Underneath the Rainbow (Bonus Track Version)", + "type" : "album", + "uri" : "spotify:album:4kE1w1zgP6Ag6Ojbuxzk7l" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "BE", "BG", "BO", "BR", "CA", "CL", "CO", "CR", "CY", "CZ", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/6RCOAR93Gi157qwW771xFG" + }, + "href" : "https://api.spotify.com/v1/albums/6RCOAR93Gi157qwW771xFG", + "id" : "6RCOAR93Gi157qwW771xFG", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/590d34233a0ef309d2c83213fb20cdef7e7804c6", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/5bceabff51f4e0366fa7e05bfc92e3f8a73e157f", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/32d480d47b3f0d0687c7d6cb362f7246b35fb62e", + "width" : 64 + } ], + "name" : "Kiss Me Once (Special Edition)", + "type" : "album", + "uri" : "spotify:album:6RCOAR93Gi157qwW771xFG" + }, { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/14GhiNSb8mH3sOnersqp28" + }, + "href" : "https://api.spotify.com/v1/albums/14GhiNSb8mH3sOnersqp28", + "id" : "14GhiNSb8mH3sOnersqp28", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/ceabefd7b5c7c1a4a4a550de823289810b14b7dd", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/398e5dda368c86337c8240dd2e6fa015ae576ce2", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/e73d5b0fb22ae7e0ceb66155a7dc82f5512f9005", + "width" : 64 + } ], + "name" : "FALLINLOVE2NITE", + "type" : "album", + "uri" : "spotify:album:14GhiNSb8mH3sOnersqp28" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/7rf1qZJ6hGSlPN7K9ShsVV" + }, + "href" : "https://api.spotify.com/v1/albums/7rf1qZJ6hGSlPN7K9ShsVV", + "id" : "7rf1qZJ6hGSlPN7K9ShsVV", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/9ab61dfa896d1431af5cddcb2bb9dba471103bb0", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/fd6fe6aa26f835e85fc8b555f2ed86a36d62ca33", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/c00728e445db587f47d8f4161319d83e5b2fe33c", + "width" : 64 + } ], + "name" : "Recess", + "type" : "album", + "uri" : "spotify:album:7rf1qZJ6hGSlPN7K9ShsVV" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/1YPlEB0kZ4SOyT2kBLgINR" + }, + "href" : "https://api.spotify.com/v1/albums/1YPlEB0kZ4SOyT2kBLgINR", + "id" : "1YPlEB0kZ4SOyT2kBLgINR", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/baca3f284d82c0b10286dfdd0727b96b7744caf5", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/f0cea1f04f0a442049aad5047d06a4948752d94e", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/233aafd9f55291c1103ed69b821af3521d4f97ce", + "width" : 64 + } ], + "name" : "Love Letters", + "type" : "album", + "uri" : "spotify:album:1YPlEB0kZ4SOyT2kBLgINR" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/2BQejnIGjuFugsT71hhOG3" + }, + "href" : "https://api.spotify.com/v1/albums/2BQejnIGjuFugsT71hhOG3", + "id" : "2BQejnIGjuFugsT71hhOG3", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/b02ee9ec0e8eade076bc2358cba1e22921de956d", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/1e92081774a2150269dc23ee02bd643c8e5c1bb5", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/113ff50a0e7d0a52de712314e1bf4e66e1460598", + "width" : 64 + } ], + "name" : "The Take Off And Landing Of Everything", + "type" : "album", + "uri" : "spotify:album:2BQejnIGjuFugsT71hhOG3" + }, { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/1RUwY4InqOgnkrH1zcl9AI" + }, + "href" : "https://api.spotify.com/v1/albums/1RUwY4InqOgnkrH1zcl9AI", + "id" : "1RUwY4InqOgnkrH1zcl9AI", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/36946cbaa32098e4a3716a18a3b2eb2b4c2d07b0", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/264664cfb24f659e478a768722668dd5658e8ca5", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/b34d0694f1c24489ba862ebb1a32006015e7e1b0", + "width" : 64 + } ], + "name" : "Guilty All The Same (feat. Rakim)", + "type" : "album", + "uri" : "spotify:album:1RUwY4InqOgnkrH1zcl9AI" + }, { + "album_type" : "album", + "available_markets" : [ "CA", "US" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/13xRSfodlL3UtG3xSyL8u2" + }, + "href" : "https://api.spotify.com/v1/albums/13xRSfodlL3UtG3xSyL8u2", + "id" : "13xRSfodlL3UtG3xSyL8u2", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/2ab5e967f8979027fbe7ae7508aaa216f98ebbd9", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/0b87d1fbca3b4bf8a1df3bff69c49083bc0363ba", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/221626b9dc42c9a8e75d53a277c601824f173c49", + "width" : 64 + } ], + "name" : "No Mythologies to Follow (Deluxe)", + "type" : "album", + "uri" : "spotify:album:13xRSfodlL3UtG3xSyL8u2" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/7lAYJiypiPbCDvjKOBX1TV" + }, + "href" : "https://api.spotify.com/v1/albums/7lAYJiypiPbCDvjKOBX1TV", + "id" : "7lAYJiypiPbCDvjKOBX1TV", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/915c9f12ef6479d885ae3f6de2dedafb70494d20", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/aba9cf39c84a1444420b230f0e6b851ec4db8f08", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/107b06d55ea161a15a21dec478d5aa1d0befaa40", + "width" : 64 + } ], + "name" : "Atlas", + "type" : "album", + "uri" : "spotify:album:7lAYJiypiPbCDvjKOBX1TV" + }, { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/4cCfFozyo6JC8acN8uIP7u" + }, + "href" : "https://api.spotify.com/v1/albums/4cCfFozyo6JC8acN8uIP7u", + "id" : "4cCfFozyo6JC8acN8uIP7u", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/95f5cbdb03db43c16046562c5f85cc2e3f77b596", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/c950057b00130fb061e801b45aea6cc45dba1bc3", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/53c5c7fbda7527abb8635e7af36af4e333f01e22", + "width" : 64 + } ], + "name" : "Magic", + "type" : "album", + "uri" : "spotify:album:4cCfFozyo6JC8acN8uIP7u" + }, { + "album_type" : "album", + "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/4JHtCtKG5CXJAXYLJtKUEE" + }, + "href" : "https://api.spotify.com/v1/albums/4JHtCtKG5CXJAXYLJtKUEE", + "id" : "4JHtCtKG5CXJAXYLJtKUEE", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/c61a960d6110e259eb26a8a48d39b5b43b61bcdf", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/e504411141d5dd4742d41245e9821d6da9079bc5", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/b4af49db137f7862cef31d64b4ab9c7f14475467", + "width" : 64 + } ], + "name" : "Somebody's Party - EP", + "type" : "album", + "uri" : "spotify:album:4JHtCtKG5CXJAXYLJtKUEE" + }, { + "album_type" : "album", + "available_markets" : [ "AR", "AU", "BO", "BR", "CA", "CL", "CO", "CR", "DO", "EC", "GT", "HK", "HN", "MX", "MY", "NI", "NZ", "PA", "PE", "PH", "PY", "SG", "SV", "TW", "US", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/0Cvy3SH2exFvz8WIX68HSZ" + }, + "href" : "https://api.spotify.com/v1/albums/0Cvy3SH2exFvz8WIX68HSZ", + "id" : "0Cvy3SH2exFvz8WIX68HSZ", + "images" : [ { + "height" : 640, + "url" : "https://i.scdn.co/image/3d0b40dbf4ed6318b2bbe87d83a9bcbf39fcc45d", + "width" : 640 + }, { + "height" : 300, + "url" : "https://i.scdn.co/image/bc2bd24632e69303590c47a60c0d3b7e73ad641a", + "width" : 300 + }, { + "height" : 64, + "url" : "https://i.scdn.co/image/79b3b1df664940f0352a7214e1260603124cc590", + "width" : 64 + } ], + "name" : "Spotify Sessions - Live at Warped Tour 2013", + "type" : "album", + "uri" : "spotify:album:0Cvy3SH2exFvz8WIX68HSZ" + } ], + "limit" : 20, + "next" : "https://api.spotify.com/v1/browse/new-releases?offset=20&limit=20", + "offset" : 0, + "previous" : null, + "total" : 120 + } +} \ No newline at end of file diff --git a/test/spec/angular-spotify.spec.js b/test/spec/angular-spotify.spec.js index 59d08be..042230a 100644 --- a/test/spec/angular-spotify.spec.js +++ b/test/spec/angular-spotify.spec.js @@ -211,6 +211,15 @@ describe('angular-spotify', function () { expect(Spotify.toQueryString({a: 't', b: 4, c: 'q'})).toBe('a=t&b=4&c=q'); }); + it('should have a method getFeaturedPlaylists()', function () { + expect(Spotify.getFeaturedPlaylists).toBeDefined(); + }); + + it('should have a method getNewReleases()', function () { + expect(Spotify.getNewReleases).toBeDefined(); + }); + + describe('Spotify.api', function () { var $httpBackend; var Spotify; @@ -1369,6 +1378,84 @@ describe('angular-spotify', function () { }); + describe('Browse', function() { + var $httpBackend; + var Spotify; + var api = 'https://api.spotify.com/v1'; + + beforeEach(inject(function(_Spotify_, _$httpBackend_) { + Spotify = _Spotify_; + $httpBackend = _$httpBackend_; + })); + + describe('Browse.getFeaturedPlaylists', function() { + + it('should call the correct URL with authentication and options', function () { + spyOn(Spotify, 'api'); + + Spotify.setAuthToken('TESTING'); + + Spotify.getFeaturedPlaylists({ country: 'NL', locale: 'nl_NL' }); + + expect(Spotify.api).toHaveBeenCalled(); + expect(Spotify.api).toHaveBeenCalledWith('/browse/featured-playlists', 'GET', { + country: 'NL', locale: 'nl_NL' + }, null, { + 'Authorization': 'Bearer TESTING' + }); + }); + + it('should resolve to an object with a message and playlists', function () { + $httpBackend.when('GET', api + '/browse/featured-playlists').respond(200, getJSONFixture('featured-playlists.json')); + + var result; + Spotify.getFeaturedPlaylists().then(function (data) { + result = data; + }); + + $httpBackend.flush(); + expect(result).toBeDefined(); + expect(result instanceof Object).toBeTruthy(); + expect(result.message).toBeDefined(); + expect(result.playlists).toBeDefined(); + }); + + }); + + describe('Browse.getNewReleases', function() { + + it('should call the correct URL with authentication and options', function () { + spyOn(Spotify, 'api'); + + Spotify.setAuthToken('TESTING'); + + Spotify.getNewReleases({ country: 'NL' }); + + expect(Spotify.api).toHaveBeenCalled(); + expect(Spotify.api).toHaveBeenCalledWith('/browse/new-releases', 'GET', { + country: 'NL' + }, null, { + 'Authorization': 'Bearer TESTING' + }); + }); + + it('should resolve to an object with albums', function () { + $httpBackend.when('GET', api + '/browse/new-releases').respond(200, getJSONFixture('new-releases.json')); + + var result; + Spotify.getNewReleases().then(function (data) { + result = data; + }); + + $httpBackend.flush(); + expect(result).toBeDefined(); + expect(result instanceof Object).toBeTruthy(); + expect(result.albums).toBeDefined(); + }); + + }); + }); + }); });