rspotify 1.19.1 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca4b04de3b3895c1f1177fa8605555c8194d8afd
4
- data.tar.gz: 14a9d725d5eaecb027d663423e6dbee7941c82c9
3
+ metadata.gz: 6a0c24d5567ae501a2521c15ef19a34175dde046
4
+ data.tar.gz: 25b8e50e446cce78cfb8f98f232353220454ee0b
5
5
  SHA512:
6
- metadata.gz: 2031354beb1320777591b3dc11e231c49a35bc177b5582611347ee302a7d3c3297c04e150db82206156e1e15a37832e1e98bf47fc54e93281f00ae212fac27f3
7
- data.tar.gz: d58ee19c8da18ac3a4a57235c2576f5636774c9ae47788bea1f4bf24294f8f889b6d429868f6db2d25864eb3e3ea5081c350eead84d376c2eeabb518f7ab1c01
6
+ metadata.gz: dd7117cec0764a99ec287d42e913bec0634bccd480b53efa4c9418b7e5782785dc81c59b875dafd53f2637ff8e7ec86ecca4a5b743002abf51ab1eb577ab198e
7
+ data.tar.gz: 504222a7bb2eb95b18e0e6abf5b1961c789b07411245ed23d1914b7c2de45415224baabeeb015f9dadd0e278c4a2b29c22f3b803dfc89200e5805559bc01914c
@@ -42,15 +42,17 @@ module RSpotify
42
42
  #
43
43
  # @param user_id [String]
44
44
  # @param id [String]
45
+ # @param market [String] Optional. An {https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}. Provide this parameter if you want to apply Track Relinking
45
46
  # @return [Playlist]
46
47
  #
47
48
  # @example
48
49
  # playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
49
50
  # playlist.class #=> RSpotify::Playlist
50
51
  # playlist.name #=> "Movie Soundtrack Masterpieces"
51
- def self.find(user_id, id)
52
+ def self.find(user_id, id, market: nil)
52
53
  url = "users/#{user_id}/"
53
54
  url << (id == 'starred' ? id : "playlists/#{id}")
55
+ url << "?market=#{market}" if market
54
56
 
55
57
  response = RSpotify.resolve_auth_request(user_id, url)
56
58
  return response if RSpotify.raw_response
@@ -226,18 +228,20 @@ module RSpotify
226
228
  #
227
229
  # @param limit [Integer] Maximum number of tracks to return. Maximum: 100. Default: 100.
228
230
  # @param offset [Integer] The index of the first track to return. Use with limit to get the next set of objects. Default: 0.
231
+ # @param market [String] Optional. An {https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}. Provide this parameter if you want to apply Track Relinking
229
232
  # @return [Array<Track>]
230
233
  #
231
234
  # @example
232
235
  # playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
233
236
  # playlist.tracks.first.name #=> "Main Theme from Star Wars - Instrumental"
234
- def tracks(limit: 100, offset: 0)
237
+ def tracks(limit: 100, offset: 0, market: nil)
235
238
  last_track = offset + limit - 1
236
239
  if @tracks_cache && last_track < 100 && !RSpotify.raw_response
237
240
  return @tracks_cache[offset..last_track]
238
241
  end
239
242
 
240
243
  url = "#{@path}/tracks?limit=#{limit}&offset=#{offset}"
244
+ url << "&market=#{market}" if market
241
245
  response = RSpotify.resolve_auth_request(@owner.id, url)
242
246
 
243
247
  json = RSpotify.raw_response ? JSON.parse(response) : response
data/lib/rspotify/user.rb CHANGED
@@ -38,6 +38,8 @@ module RSpotify
38
38
  response = RestClient.post(TOKEN_URI, request_body, RSpotify.send(:auth_header))
39
39
  response = JSON.parse(response)
40
40
  @@users_credentials[user_id]['token'] = response['access_token']
41
+ rescue RestClient::BadRequest => e
42
+ raise e if e.response !~ /Refresh token revoked/
41
43
  end
42
44
  private_class_method :refresh_token
43
45
 
@@ -68,7 +70,9 @@ module RSpotify
68
70
 
69
71
  def initialize(options = {})
70
72
  credentials = options['credentials']
73
+ extra = options['extra'].to_h
71
74
  options = options['info'] if options['info']
75
+ options.merge!(extra['raw_info'].to_h)
72
76
 
73
77
  @birthdate ||= options['birthdate']
74
78
  @country ||= options['country']
@@ -1,3 +1,3 @@
1
1
  module RSpotify
2
- VERSION = '1.19.1'
2
+ VERSION = '1.20.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Sad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-11 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2