spotify-ruby-api 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/lib/spotify.rb +1 -1
- data/lib/spotify/api/base.rb +8 -4
- data/lib/spotify/api/version.rb +1 -1
- data/lib/spotify/models/error.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfb2b5b6edafa2ae1d2f850d7763f989cea29cd1
|
4
|
+
data.tar.gz: ac247d7a84e4d956b3f84471fff3044fdd3a4b4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d5083f43fb97db9e71e28171a8058093affab17c336ec449dcbf4212cf5e7a34072b2c47774888a8bf413270fe5b72f14add7c0b68cba52197a844dc1d04fee
|
7
|
+
data.tar.gz: d94c61c065ceef8b39096d3a6c52cd55abe366935900a22240f70276c8e4cb5455ba0ccdd20e9e228ce1882faef1d89e803ba12da053bfb7841f20b80dd7f233
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# spotify-ruby-api
|
2
2
|
|
3
3
|
This gem was developed with the purpose of retrieve information from [Spotify](https://spotify.com/) service by using its API.
|
4
4
|
|
@@ -20,9 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
require 'spotify'
|
23
|
+
require 'spotify'
|
24
24
|
|
25
25
|
### Albums
|
26
|
+
```ruby
|
26
27
|
albums_api = Spotify::API::Albums
|
27
28
|
|
28
29
|
albums_api.search_by_id(id: '') # => Spotify::Models::Full::Album
|
@@ -30,14 +31,18 @@ albums_api.search_by_ids(ids: []) # => [Spotify::Models::Full::Album]
|
|
30
31
|
|
31
32
|
tracks = albums_api.tracks(id: '') # => Spotify::Models::Paging
|
32
33
|
tracks.items # => [Spotify::Models::Simplified::Track]
|
34
|
+
```
|
33
35
|
|
34
36
|
### Tracks
|
37
|
+
```ruby
|
35
38
|
tracks_api = Spotify::API::Track
|
36
39
|
|
37
40
|
tracks_api.search_by_id(id: '') # => Spotify::Models::Full::Track
|
38
41
|
tracks_api.search_by_ids(ids: '') # => [Spotify::Models::Full::Track]
|
42
|
+
```
|
39
43
|
|
40
44
|
### Artists
|
45
|
+
```ruby
|
41
46
|
artists_api = Spotify::API::Artist
|
42
47
|
|
43
48
|
artists_api.search_by_id(id: '') # => Spotify::Models::Full::Artist
|
@@ -51,12 +56,14 @@ top_tracks.items # => Spotify::Models::Full::Track
|
|
51
56
|
|
52
57
|
related_artists = artists_api.related_artists(id: '') # => Spotify::Models::Paging
|
53
58
|
related_artists.items # => [Spotify::Models::Full::Artist]
|
59
|
+
```
|
54
60
|
|
55
61
|
## Todo
|
56
62
|
|
57
63
|
The following table shows all API endpoints and if each one is already implemented or not.
|
58
64
|
|
59
65
|
| Method | EndPoints | Implemented? |
|
66
|
+
|--------|----------------------------------------------------------------|--------------|
|
60
67
|
| GET | /v1/albums/{id} | YES |
|
61
68
|
| GET | /v1/albums?ids={ids} | YES |
|
62
69
|
| GET | /v1/albums/{id}/tracks | YES |
|
data/lib/spotify.rb
CHANGED
data/lib/spotify/api/base.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'timeout'
|
3
|
+
require 'net/http'
|
2
4
|
|
3
5
|
module Spotify
|
4
6
|
module API
|
@@ -86,7 +88,7 @@ module Spotify
|
|
86
88
|
@attempts = attempts
|
87
89
|
|
88
90
|
if attempts > MAX_RETRIES || attempts > @retries
|
89
|
-
set_response(Spotify::
|
91
|
+
set_response(Spotify::Models::Error.max_retries, true)
|
90
92
|
|
91
93
|
else
|
92
94
|
begin
|
@@ -97,9 +99,11 @@ module Spotify
|
|
97
99
|
end
|
98
100
|
|
99
101
|
rescue Timeout::Error
|
100
|
-
set_response(Spotify::
|
101
|
-
rescue
|
102
|
-
|
102
|
+
set_response(Spotify::Models::Error.timeout)
|
103
|
+
rescue Exception => e
|
104
|
+
puts e.message
|
105
|
+
puts e.backtrace
|
106
|
+
set_response(Spotify::Models::Error.unexpected_error)
|
103
107
|
end
|
104
108
|
end
|
105
109
|
|
data/lib/spotify/api/version.rb
CHANGED
data/lib/spotify/models/error.rb
CHANGED