spotify-ruby-api 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE +21 -0
  7. data/README.md +119 -0
  8. data/Rakefile +7 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/lib/spotify/api/album.rb +164 -0
  12. data/lib/spotify/api/artist.rb +248 -0
  13. data/lib/spotify/api/base.rb +150 -0
  14. data/lib/spotify/api/track.rb +127 -0
  15. data/lib/spotify/api/user.rb +58 -0
  16. data/lib/spotify/api/version.rb +5 -0
  17. data/lib/spotify/api.rb +12 -0
  18. data/lib/spotify/models/album.rb +42 -0
  19. data/lib/spotify/models/artist.rb +34 -0
  20. data/lib/spotify/models/category.rb +23 -0
  21. data/lib/spotify/models/copyright.rb +27 -0
  22. data/lib/spotify/models/cursor.rb +19 -0
  23. data/lib/spotify/models/cursorbased_paging.rb +24 -0
  24. data/lib/spotify/models/error.rb +122 -0
  25. data/lib/spotify/models/external_id.rb +41 -0
  26. data/lib/spotify/models/external_url.rb +39 -0
  27. data/lib/spotify/models/follower.rb +27 -0
  28. data/lib/spotify/models/full/album.rb +46 -0
  29. data/lib/spotify/models/full/artist.rb +37 -0
  30. data/lib/spotify/models/full/track.rb +34 -0
  31. data/lib/spotify/models/full/user.rb +31 -0
  32. data/lib/spotify/models/full.rb +11 -0
  33. data/lib/spotify/models/image.rb +28 -0
  34. data/lib/spotify/models/paging.rb +38 -0
  35. data/lib/spotify/models/playlist_track.rb +24 -0
  36. data/lib/spotify/models/saved_album.rb +22 -0
  37. data/lib/spotify/models/saved_track.rb +22 -0
  38. data/lib/spotify/models/simplified/album.rb +23 -0
  39. data/lib/spotify/models/simplified/artist.rb +23 -0
  40. data/lib/spotify/models/simplified/track.rb +23 -0
  41. data/lib/spotify/models/simplified/user.rb +23 -0
  42. data/lib/spotify/models/simplified.rb +11 -0
  43. data/lib/spotify/models/track.rb +50 -0
  44. data/lib/spotify/models/track_link.rb +33 -0
  45. data/lib/spotify/models/user.rb +41 -0
  46. data/lib/spotify/models.rb +27 -0
  47. data/lib/spotify.rb +6 -0
  48. data/spotify-api.gemspec +34 -0
  49. metadata +160 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60c91432332136859f731759d15fa3ac9654b903
4
+ data.tar.gz: af790a4f8e46f57403794918580f85d82b9caba9
5
+ SHA512:
6
+ metadata.gz: c50b321d9bcba46221cd4d139e75a0a8f1b4e1d832e5e13c5e17985f6720facde62c9873d04d019f6df00cacd75a177c886d9956a1edb5ecfcba23a9400cf867
7
+ data.tar.gz: b3f5df2353e907f3f3204db4a74f4982b5b0eba94f2ffa2d1bd6303b2d557148a1f4743fd3305bc3b27ee59cf0d2b76a60bc599d70f134ecec122c1388a826bd
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in spotify-api.gemspec
4
+ gemspec
5
+
6
+ gem 'json'
7
+ gem 'activesupport'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Felipe Gadelha Ruoso
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Spotify::API
2
+
3
+ This gem was developed with the purpose of retrieve information from [Spotify](https://spotify.com/) service by using its API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'spotify-ruby-api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install spotify-ruby-api
20
+
21
+ ## Usage
22
+
23
+ require 'spotify'
24
+
25
+ ### Albums
26
+ albums_api = Spotify::API::Albums
27
+
28
+ albums_api.search_by_id(id: '') # => Spotify::Models::Full::Album
29
+ albums_api.search_by_ids(ids: []) # => [Spotify::Models::Full::Album]
30
+
31
+ tracks = albums_api.tracks(id: '') # => Spotify::Models::Paging
32
+ tracks.items # => [Spotify::Models::Simplified::Track]
33
+
34
+ ### Tracks
35
+ tracks_api = Spotify::API::Track
36
+
37
+ tracks_api.search_by_id(id: '') # => Spotify::Models::Full::Track
38
+ tracks_api.search_by_ids(ids: '') # => [Spotify::Models::Full::Track]
39
+
40
+ ### Artists
41
+ artists_api = Spotify::API::Artist
42
+
43
+ artists_api.search_by_id(id: '') # => Spotify::Models::Full::Artist
44
+ artists_api.search_by_ids(ids: '') # => [Spotify::Models::Full::Artist]
45
+
46
+ albums = artists_api.albums(id: '') # => Spotify::Models::Paging
47
+ albums.items # => Spotify::Models::Simplified::Album
48
+
49
+ top_tracks = artists_api.top_tracks(id: '') # => Spotify::Models::Paging
50
+ top_tracks.items # => Spotify::Models::Full::Track
51
+
52
+ related_artists = artists_api.related_artists(id: '') # => Spotify::Models::Paging
53
+ related_artists.items # => [Spotify::Models::Full::Artist]
54
+
55
+ ## Todo
56
+
57
+ The following table shows all API endpoints and if each one is already implemented or not.
58
+
59
+ | Method | EndPoints | Implemented? |
60
+ | GET | /v1/albums/{id} | YES |
61
+ | GET | /v1/albums?ids={ids} | YES |
62
+ | GET | /v1/albums/{id}/tracks | YES |
63
+ | GET | /v1/artists/{id} | YES |
64
+ | GET | /v1/artists?ids={ids} | YES |
65
+ | GET | /v1/artists/{id}/albums | YES |
66
+ | GET | /v1/artists/{id}/top-tracks | YES |
67
+ | GET | /v1/artists/{id}/related-artists | YES |
68
+ | GET | /v1/browse/featured-playlists | NO |
69
+ | GET | /v1/browse/new-releases | NO |
70
+ | GET | /v1/browse/categories | NO |
71
+ | GET | /v1/browse/categories/{id} | NO |
72
+ | GET | /v1/browse/categories/{id}/playlists | NO |
73
+ | GET | /v1/me | NO |
74
+ | GET | /v1/me/following | NO |
75
+ | PUT | /v1/me/following | NO |
76
+ | DELETE | /v1/me/following | NO |
77
+ | GET | /v1/me/following/contains | NO |
78
+ | PUT | /v1/users/{owner_id}/playlists/{playlist_id}/followers | NO |
79
+ | DELETE | /v1/users/{owner_id}/playlists/{playlist_id}/followers | NO |
80
+ | PUT | /v1/me/tracks?ids={ids} | NO |
81
+ | GET | /v1/me/tracks | NO |
82
+ | DELETE | /v1/me/tracks?ids={ids} | NO |
83
+ | GET | /v1/me/tracks/contains?ids={ids} | NO |
84
+ | PUT | /v1/me/albums?ids={ids} | NO |
85
+ | GET | /v1/me/albums | NO |
86
+ | DELETE | /v1/me/albums?ids={ids} | NO |
87
+ | GET | /v1/me/albums/contains?ids={ids} | NO |
88
+ | GET | /v1/search?type=album | YES |
89
+ | GET | /v1/search?type=artist | YES |
90
+ | GET | /v1/search?type=playlist | YES |
91
+ | GET | /v1/search?type=track | YES |
92
+ | GET | /v1/tracks/{id} | YES |
93
+ | GET | /v1/tracks?ids={ids} | YES |
94
+ | GET | /v1/users/{user_id} | YES |
95
+ | GET | /v1/users/{user_id}/playlists | NO |
96
+ | GET | /v1/me/playlists | NO |
97
+ | GET | /v1/users/{user_id}/playlists/{playlist_id} | NO |
98
+ | GET | /v1/users/{user_id}/playlists/{playlist_id}/tracks | NO |
99
+ | POST | /v1/users/{user_id}/playlists | NO |
100
+ | PUT | /v1/users/{user_id}/playlists/{playlist_id} | NO |
101
+ | POST | /v1/users/{user_id}/playlists/{playlist_id}/tracks | NO |
102
+ | DELETE | /v1/users/{user_id}/playlists/{playlist_id}/tracks | NO |
103
+ | PUT | /v1/users/{user_id}/playlists/{playlist_id}/tracks | NO |
104
+ | PUT | /v1/users/{user_id}/playlists/{playlist_id}/tracks | NO |
105
+ | GET | /v1/users/{user_id}/playlists/{playlist_id}/followers/contains | NO |
106
+
107
+ ## Development
108
+
109
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
110
+
111
+ To install this gem onto your local machine, run `bundle exec rake install`.
112
+
113
+ ## Contributing
114
+
115
+ 1. Fork it ( https://github.com/felipegruoso/spotify-api/fork )
116
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
117
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
118
+ 4. Push to the branch (`git push origin my-new-feature`)
119
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
7
+ task test: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "spotify"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,164 @@
1
+ module Spotify
2
+ module API
3
+
4
+ class Album < Spotify::API::Base
5
+
6
+ #
7
+ # API endpoint for albums.
8
+ #
9
+ ALBUMS_URL = "#{BASE_URL}albums"
10
+
11
+ #
12
+ # Gets the albums related to the given parameters.
13
+ #
14
+ # @param [Hash] args the search arguments.
15
+ # @option [Fixnum] :timeout the max time a request can take.
16
+ # @option [Fixnum] :retries the number of retries if necessary.
17
+ #
18
+ # @return [Spotify::Models::Paging] the extracted albums.
19
+ #
20
+ def self.search(args = {})
21
+ args[:type] = :album
22
+
23
+ service_params = args.slice(:timeout, :retries)
24
+ args = args.slice(:q, :market, :type, :limit, :offset)
25
+
26
+ self.new(service_params).search(args)
27
+ end
28
+
29
+ #
30
+ # Gets an album.
31
+ #
32
+ # @param [Hash] args the search arguments.
33
+ # @option [Fixnum] :timeout the max time a request can take.
34
+ # @option [Fixnum] :retries the number of retries if necessary.
35
+ #
36
+ # @return [Full::Album] the extracted album.
37
+ #
38
+ def self.search_by_id(args = {})
39
+ service_params = args.slice(:timeout, :retries)
40
+ args = args.slice(:id)
41
+
42
+ self.new(service_params).search_by_id(args)
43
+ end
44
+
45
+ #
46
+ # Gets an album.
47
+ #
48
+ # @param [Hash] args the search arguments.
49
+ # @option [Fixnum] :timeout the max time a request can take.
50
+ # @option [Fixnum] :retries the number of retries if necessary.
51
+ #
52
+ # @return [Array<Full::Album>] the extracted album.
53
+ #
54
+ def self.search_by_ids(args = {})
55
+ args[:ids] = Array(args[:ids]).join(',')
56
+
57
+ service_params = args.slice(:timeout, :retries)
58
+ args = args.slice(:ids)
59
+
60
+ self.new(service_params).search_by_ids(args)
61
+ end
62
+
63
+ #
64
+ # Gets an album.
65
+ #
66
+ # @param [Hash] args the search arguments.
67
+ # @option [Fixnum] :timeout the max time a request can take.
68
+ # @option [Fixnum] :retries the number of retries if necessary.
69
+ #
70
+ # @return [Full::Album] the extracted album.
71
+ #
72
+ def self.tracks(args = {})
73
+ service_params = args.slice(:timeout, :retries)
74
+ args = args.slice(:id, :limit, :offset, :market)
75
+
76
+ self.new(service_params).tracks(args)
77
+ end
78
+
79
+ #
80
+ # Gets the albums related to the given parameters.
81
+ #
82
+ # @param [Hash] args the search arguments.
83
+ # @option [Fixnum] :timeout the max time a request can take.
84
+ # @option [Fixnum] :retries the number of retries if necessary.
85
+ #
86
+ # @return [Spotify::Models::Paging] the extracted albums.
87
+ #
88
+ def search(args = {})
89
+ if args[:market].to_s.to_sym == FROM_TOKEN
90
+ # TODO: Authorization.
91
+ return Spotify::API::Errors::NOT_AVAILABLE
92
+ end
93
+
94
+ get(SEARCH_URL, args)
95
+
96
+ define_response do
97
+ klass = Spotify::Models::Simplified::Album
98
+
99
+ Spotify::Models::Paging.new(response["albums"], klass)
100
+ end
101
+ end
102
+
103
+ #
104
+ # Gets an album.
105
+ #
106
+ # @param [Hash] args the search arguments.
107
+ # @option [String] :id the album id.
108
+ #
109
+ # @return [Full::Album] the extracted album.
110
+ #
111
+ def search_by_id(args = {})
112
+ url = ALBUMS_URL + '/' + args[:id].to_s
113
+
114
+ get(url)
115
+
116
+ define_response do
117
+ Spotify::Models::Full::Album.new(response)
118
+ end
119
+ end
120
+
121
+ #
122
+ # Gets several albums.
123
+ #
124
+ # @param [Hash] args the search arguments.
125
+ # @option [String] :ids the artists ids between ",".
126
+ #
127
+ # @return [Array<Full::Album>] an array containing
128
+ # the extracted albums.
129
+ #
130
+ def search_by_ids(args = {})
131
+ get(ALBUMS_URL, args)
132
+
133
+ define_response do
134
+ response["albums"].map do |album|
135
+ Spotify::Models::Full::Album.new(album)
136
+ end
137
+ end
138
+ end
139
+
140
+ #
141
+ # Gets the album's tracks.
142
+ #
143
+ # @param [Hash] args the search arguments.
144
+ #
145
+ # @return [Paging] an array containing album's tracks.
146
+ #
147
+ def tracks(args = {})
148
+ url = ALBUMS_URL + '/' + args[:id] + '/tracks'
149
+ params = args.slice(:limit, :offset, :market)
150
+
151
+ get(url, params)
152
+
153
+ define_response do
154
+ klass = Spotify::Models::Simplified::Track
155
+
156
+ Spotify::Models::Paging.new(response, klass)
157
+ end
158
+ end
159
+
160
+ end
161
+
162
+ end
163
+
164
+ end
@@ -0,0 +1,248 @@
1
+ module Spotify
2
+ module API
3
+
4
+ class Artist < Spotify::API::Base
5
+
6
+ #
7
+ # API endpoint for artists.
8
+ #
9
+ ARTISTS_URL = "#{BASE_URL}artists"
10
+
11
+ #
12
+ # Gets the artists related to the given parameters.
13
+ #
14
+ # @param [Hash] args the search arguments.
15
+ # @option [Fixnum] :timeout the max time a request can take.
16
+ # @option [Fixnum] :retries the number of retries if necessary.
17
+ #
18
+ # @return [Spotify::Models::Paging] the extracted artists.
19
+ #
20
+ def self.search(args = {})
21
+ args[:type] = :artist
22
+
23
+ service_params = args.slice(:timeout, :retries)
24
+ args = args.slice(:q, :market, :type, :limit, :offset)
25
+
26
+ self.new(service_params).search(args)
27
+ end
28
+
29
+ #
30
+ # Gets an artist.
31
+ #
32
+ # @param [Hash] args the search arguments.
33
+ # @option [Fixnum] :timeout the max time a request can take.
34
+ # @option [Fixnum] :retries the number of retries if necessary.
35
+ #
36
+ # @return [Full::Artist] the extracted artist.
37
+ #
38
+ def self.search_by_id(args = {})
39
+ service_params = args.slice(:timeout, :retries)
40
+ args = args.slice(:id)
41
+
42
+ self.new(service_params).search_by_id(args)
43
+ end
44
+
45
+ #
46
+ # Gets several artists.
47
+ #
48
+ # @param [Hash] args the search arguments.
49
+ # @option [Fixnum] :timeout the max time a request can take.
50
+ # @option [Fixnum] :retries the number of retries if necessary.
51
+ #
52
+ # @return [Array<Full::Artist>] an array containing
53
+ # the extracted artists.
54
+ #
55
+ def self.search_by_ids(args = {})
56
+ args[:ids] = Array(args[:ids]).join(',')
57
+
58
+ service_params = args.slice(:timeout, :retries)
59
+ args = args.slice(:ids)
60
+
61
+ self.new(service_params).search_by_ids(args)
62
+ end
63
+
64
+ #
65
+ # Get an artist's top tracks.
66
+ #
67
+ # @param [Hash] args the search arguments.
68
+ # @option [Fixnum] :timeout the max time a request can take.
69
+ # @option [Fixnum] :retries the number of retries if necessary.
70
+ #
71
+ # @return [Array<Full::Track>] an array containing
72
+ # the extracted artist's top tracks.
73
+ #
74
+ def self.top_tracks(args = {})
75
+ args = args.slice(:id, :country)
76
+ service_params = args.slice(:timeout, :retries)
77
+
78
+ self.new(service_params).top_tracks(args)
79
+ end
80
+
81
+ #
82
+ # Get an artist's related artists.
83
+ #
84
+ # @param [Hash] args the search arguments.
85
+ # @option [Fixnum] :timeout the max time a request can take.
86
+ # @option [Fixnum] :retries the number of retries if necessary.
87
+ #
88
+ # @return [Array<Full::Artist>] an array containing
89
+ # the extracted artist's related artists.
90
+ #
91
+ def self.related_artists(args = {})
92
+ args = args.slice(:id)
93
+ service_params = args.slice(:timeout, :retries)
94
+
95
+ self.new(service_params).related_artists(args)
96
+ end
97
+
98
+ #
99
+ # Get an artist's albums.
100
+ #
101
+ # @param [Hash] args the search arguments.
102
+ # @option [Fixnum] :timeout the max time a request can take.
103
+ # @option [Fixnum] :retries the number of retries if necessary.
104
+ #
105
+ # @return [Paging] an array containing the extracted artist's albums.
106
+ #
107
+ def self.albums(args = {})
108
+ args[:album_type] = Array(args[:album_type]).join(',')
109
+
110
+ args = args.slice(:id, :album_type, :market, :limit, :offset)
111
+ service_params = args.slice(:timeout, :retries)
112
+
113
+ self.new(service_params).albums(args)
114
+ end
115
+
116
+ #
117
+ # Gets the artists related to the given parameters.
118
+ #
119
+ # @param [Hash] args the search arguments.
120
+ # @option [Fixnum] :timeout the max time a request can take.
121
+ # @option [Fixnum] :retries the number of retries if necessary.
122
+ #
123
+ # @return [Spotify::Models::Paging] the extracted artists.
124
+ #
125
+ def search(args = {})
126
+ if args[:market].to_s.to_sym == FROM_TOKEN
127
+ # TODO: Authorization.
128
+ return Spotify::API::Errors::NOT_AVAILABLE
129
+ end
130
+
131
+ get(SEARCH_URL, args)
132
+
133
+ define_response do
134
+ klass = Spotify::Models::Full::Artist
135
+
136
+ Spotify::Models::Paging.new(response["artists"], klass)
137
+ end
138
+ end
139
+
140
+ #
141
+ # Gets an artist.
142
+ #
143
+ # @param [Hash] args the search arguments.
144
+ # @option [String] :id the artist id.
145
+ #
146
+ # @return [Full::Artist] the extracted artist.
147
+ #
148
+ def search_by_id(args = {})
149
+ url = ARTISTS_URL + '/' + args[:id].to_s
150
+
151
+ get(url)
152
+
153
+ define_response do
154
+ Spotify::Models::Full::Artist.new(response)
155
+ end
156
+ end
157
+
158
+ #
159
+ # Gets several artists.
160
+ #
161
+ # @param [Hash] args the search arguments.
162
+ # @option [String] :ids the artists ids between ",".
163
+ #
164
+ # @return [Array<Full::Artist>] an array containing
165
+ # the extracted artists.
166
+ #
167
+ def search_by_ids(args = {})
168
+ get(ARTISTS_URL, args)
169
+
170
+ define_response do
171
+ response["artists"].map do |artist|
172
+ Spotify::Models::Full::Artist.new(artist)
173
+ end
174
+ end
175
+ end
176
+
177
+ #
178
+ # Get an artist's top tracks.
179
+ #
180
+ # @param [Hash] args the search arguments.
181
+ # @option [String] :id the artist id.
182
+ # @option [String] :country the request country.
183
+ #
184
+ # @return [Array<Full::Track>] an array containing
185
+ # the extracted artist's top tracks.
186
+ #
187
+ def top_tracks(args = {})
188
+ url = ARTISTS_URL + '/' + args[:id].to_s + '/top-tracks'
189
+ params = args.slice(:country)
190
+
191
+ get(url, params)
192
+
193
+ define_response do
194
+ response["tracks"].map do |track|
195
+ Spotify::Models::Full::Track.new(track)
196
+ end
197
+ end
198
+ end
199
+
200
+ #
201
+ # Get an artist's related artists.
202
+ #
203
+ # @param [Hash] args the search arguments.
204
+ # @option [Fixnum] :timeout the max time a request can take.
205
+ # @option [Fixnum] :retries the number of retries if necessary.
206
+ #
207
+ # @return [Array<Full::Artist>] an array containing
208
+ # the extracted artist's related artists.
209
+ #
210
+ def related_artists(args = {})
211
+ url = ARTISTS_URL + '/' + args[:id].to_s + '/related-artists'
212
+
213
+ get(url)
214
+
215
+ define_response do
216
+ response["artists"].map do |artist|
217
+ Spotify::Models::Full::Artist.new(artist)
218
+ end
219
+ end
220
+ end
221
+
222
+ #
223
+ # Get an artist's albums.
224
+ #
225
+ # @param [Hash] args the search arguments.
226
+ # @option [Fixnum] :timeout the max time a request can take.
227
+ # @option [Fixnum] :retries the number of retries if necessary.
228
+ #
229
+ # @return [Paging] an array containing the extracted artist's
230
+ # related artists.
231
+ #
232
+ def albums(args = {})
233
+ url = ARTISTS_URL + '/' + args[:id].to_s + '/albums'
234
+ params = args.slice(:album_type, :market, :limit, :offset)
235
+
236
+ get(url, params)
237
+
238
+ define_response do
239
+ klass = Spotify::Models::Simplified::Album
240
+
241
+ Spotify::Models::Paging.new(response, klass)
242
+ end
243
+ end
244
+
245
+ end
246
+
247
+ end
248
+ end