rspotify 2.2.1 → 2.3.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: fb2791528d6b1ac2e75c7a697f2621d37b1f4a35
4
- data.tar.gz: 4db8e2fb68a9a0364336ddbf07e54f37c87c4b98
3
+ metadata.gz: cdb5d05c82ca5e425422843ec89590e50eeda168
4
+ data.tar.gz: e3178dcd15a55d6efff239aa384b4a2c48a2f721
5
5
  SHA512:
6
- metadata.gz: 1f1fa14c4492d13caab545ce09758a4634dced583f7ee646d00539c982be6b9939db868ac389439dcb3e258c541baa59f964ef6918c1e7aabb3412518ec87d52
7
- data.tar.gz: 2f81ab704a788baa982c1f3b2894d7e20443294e2f98610be7cc031348c702a84c3b697d90aedf88aa26e9042875baa187df56784fc3a475192acf04a7a89855
6
+ metadata.gz: fb4206df7dd0b654bd9186488027f047ceba828b7db72a870f8775b8f068b668cf8d722a2af2ceb4dc701f710e98fdb990d1c8739436c30401f5e17e5e02519e
7
+ data.tar.gz: f83a6ee536693dd4616811a1fcc965f788680ca4b6c09296667e5f5c8a6c7e80c9e10b4cf45f5e29bef683b42629d84e7116f0cdda54c9730a4c4c76f747190b
@@ -59,14 +59,16 @@ module RSpotify
59
59
  url << "?#{query}" if query
60
60
 
61
61
  begin
62
+ headers = get_headers(params)
63
+ headers['Accept-Language'] = ENV['ACCEPT_LANGUAGE'] if ENV['ACCEPT_LANGUAGE']
62
64
  response = RestClient.send(verb, url, *params)
63
65
  rescue RestClient::Unauthorized => e
64
66
  raise e if request_was_user_authenticated?(*params)
65
67
  if @client_token
66
68
  authenticate(@client_id, @client_secret)
67
69
 
68
- obj = params.find{|x| x.is_a?(Hash) && x['Authorization']}
69
- obj['Authorization'] = "Bearer #{@client_token}"
70
+ headers = get_headers(params)
71
+ headers['Authorization'] = "Bearer #{@client_token}"
70
72
 
71
73
  response = retry_connection verb, url, params
72
74
  end
@@ -86,11 +88,11 @@ module RSpotify
86
88
  User.class_variable_get('@@users_credentials')
87
89
  end
88
90
 
89
- obj = params.find{|x| x.is_a?(Hash) && x['Authorization']}
90
- if users_credentials
91
+ headers = get_headers(params)
92
+ if users_credentials
91
93
  creds = users_credentials.map{|user_id, creds| "Bearer #{creds['token']}"}
92
94
 
93
- if creds.include?(obj['Authorization'])
95
+ if creds.include?(headers['Authorization'])
94
96
  return true
95
97
  end
96
98
  end
@@ -101,5 +103,10 @@ module RSpotify
101
103
  authorization = Base64.strict_encode64 "#{@client_id}:#{@client_secret}"
102
104
  { 'Authorization' => "Basic #{authorization}" }
103
105
  end
106
+
107
+ def get_headers(params)
108
+ params.find{|param| param.is_a?(Hash) && param['Authorization']}
109
+ end
110
+
104
111
  end
105
112
  end
@@ -1,3 +1,3 @@
1
1
  module RSpotify
2
- VERSION = '2.2.1'
2
+ VERSION = '2.3.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: 2.2.1
4
+ version: 2.3.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: 2018-09-02 00:00:00.000000000 Z
11
+ date: 2018-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2