playlyfe 0.2.1 → 0.2.2

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.
data/lib/access_token.rb CHANGED
@@ -3,6 +3,10 @@ module OAuth2
3
3
  attr_reader :client, :token, :expires_in, :expires_at, :params
4
4
  attr_accessor :options, :refresh_token
5
5
 
6
+ def self.from_hash(client, hash)
7
+ new(client, hash.delete('access_token') || hash.delete(:access_token), hash)
8
+ end
9
+
6
10
  class << self
7
11
  # Initializes an AccessToken from a Hash
8
12
  #
data/lib/client.rb CHANGED
@@ -126,7 +126,7 @@ module OAuth2
126
126
  # @param [Hash] access token options, to pass to the AccessToken object
127
127
  # @param [Class] class of access token for easier subclassing OAuth2::AccessToken
128
128
  # @return [AccessToken] the initalized AccessToken
129
- def get_token(params, access_token_opts = {}, access_token_class = AccessToken)
129
+ def get_token(params, access_token_opts = {})
130
130
  opts = {:raise_errors => options[:raise_errors], :parse => params.delete(:parse)}
131
131
  if options[:token_method] == :post
132
132
  headers = params.delete(:headers)
@@ -139,7 +139,9 @@ module OAuth2
139
139
  response = request(options[:token_method], token_url, opts)
140
140
  error = Error.new(response)
141
141
  fail(error) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])
142
- AccessToken.from_hash(self, response.parsed.merge(access_token_opts))
142
+ hash = response.parsed.merge(access_token_opts)
143
+ AccessToken.new(self, hash.delete('access_token') || hash.delete(:access_token), hash)
144
+ #AccessToken.from_hash(self, response.parsed.merge(access_token_opts))
143
145
  #access_token_class.from_hash(self, response.parsed.merge(access_token_opts))
144
146
  end
145
147
 
data/test/test.rb CHANGED
@@ -8,7 +8,7 @@ class PlaylyfeTest < Test::Unit::TestCase
8
8
  client_id: "NjZlZWFiMWEtN2ZiOC00YmVmLTk2YWMtNDEyYTNmMjQ5NDBl",
9
9
  client_secret: "NGRhMWJlYzUtODJiNS00ZTdkLTgzNTctMTQyMGEzNTljN2MwMTU2MGM3NTAtZjZiZS0xMWUzLTgxZjYtNmZhMGYyMzRkZGU3"
10
10
  )
11
- puts Playlyfe.token
11
+ puts Playlyfe.token.to_hash
12
12
 
13
13
  players = Playlyfe.get(url: '/players')
14
14
  assert_not_nil players["data"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playlyfe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: