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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32ecdd01cd2c7b03134332a5613c262ae43b8f35
4
- data.tar.gz: c062c03d6da3925924e3c37c4937d276d965a4e8
3
+ metadata.gz: bfb2b5b6edafa2ae1d2f850d7763f989cea29cd1
4
+ data.tar.gz: ac247d7a84e4d956b3f84471fff3044fdd3a4b4b
5
5
  SHA512:
6
- metadata.gz: 059e7d88f24f7d1a3c301d7a8a933eb03801c9f143fefc1dade6cbadfa9f7c1fd5757e5acf869447dbd3e1480ffd9e2fb0a776c4e0381949d4b5586475a6b94c
7
- data.tar.gz: 62fe90dfe465cceefa78c53771bcec979c6b21299575eae6ba3f1909e08fd0267484db25daaabe8bfb41d0c692c6d900617482915c3796ece44d253e886c0633
6
+ metadata.gz: 9d5083f43fb97db9e71e28171a8058093affab17c336ec449dcbf4212cf5e7a34072b2c47774888a8bf413270fe5b72f14add7c0b68cba52197a844dc1d04fee
7
+ data.tar.gz: d94c61c065ceef8b39096d3a6c52cd55abe366935900a22240f70276c8e4cb5455ba0ccdd20e9e228ce1882faef1d89e803ba12da053bfb7841f20b80dd7f233
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Spotify::API
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
@@ -1,6 +1,6 @@
1
+ require "active_support/all"
1
2
  require "spotify/api"
2
3
  require "spotify/models"
3
- require "active_support/all"
4
4
 
5
5
  module Spotify
6
6
  end
@@ -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::API::Errors::MAX_RETRIES, true)
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::API::Errors::TIMEOUT)
101
- rescue
102
- set_response(Spotify::API::Errors::UNEXPECTED)
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
 
@@ -1,5 +1,5 @@
1
1
  module Spotify
2
2
  module API
3
- VERSION = "0.7.1"
3
+ VERSION = "0.7.2"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ module Spotify
19
19
  status: 700,
20
20
  message: "Timed out."
21
21
  },
22
- unexpected: {
22
+ unexpected_error: {
23
23
  status: 710,
24
24
  message: "Unexpected error."
25
25
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify-ruby-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Gadelha Ruoso