gocardless 1.10.1 → 1.11.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/gocardless/client.rb +21 -3
- data/lib/gocardless/version.rb +1 -1
- data/spec/client_spec.rb +51 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb186568bf3bab6c1d0baf10394a75ecd1b14534
|
4
|
+
data.tar.gz: 033069ff0faa53aa992680bd46bd0b0296b6f4c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979d094b2b639f33f92626feb7cff70da4b55cd241fae9dae12f049282c0c99bece3f2fee1f916a6ebb98c4d3eb3ac80600fe7757aab43cb5670c3981ddbc2db
|
7
|
+
data.tar.gz: cd6bfe4b1a8bf4fcb4ca8eda5357aeaa6459a03e64eabc3ae376f85a77a3718e0c07c98108b9465d7521e0ab820165b4587d2b31de5ad30b8673942712f980c0
|
data/CHANGELOG.md
CHANGED
data/lib/gocardless/client.rb
CHANGED
@@ -70,14 +70,31 @@ module GoCardless
|
|
70
70
|
scope = @access_token.params[:scope] || @access_token.params['scope']
|
71
71
|
set_merchant_id_from_scope(scope)
|
72
72
|
|
73
|
-
self.
|
73
|
+
self.scoped_access_token
|
74
74
|
end
|
75
75
|
|
76
76
|
# @return [String] a serialized form of the access token with its scope
|
77
|
+
def scoped_access_token
|
78
|
+
"#{self.unscoped_access_token} #{self.scope}".strip if @access_token
|
79
|
+
end
|
80
|
+
|
77
81
|
def access_token
|
82
|
+
warn "[DEPRECATION] (gocardless-ruby) the behaviour of " +
|
83
|
+
"Client#access_token is deprecated. In future releases it will " +
|
84
|
+
"return the unscoped access token. If you want the scoped access " +
|
85
|
+
"token, use 'scoped_access_token'"
|
86
|
+
self.scoped_access_token
|
87
|
+
end
|
88
|
+
|
89
|
+
# @return [String] a serialized form of the access token without its scope
|
90
|
+
def unscoped_access_token
|
91
|
+
@access_token.token if @access_token
|
92
|
+
end
|
93
|
+
|
94
|
+
# @return [String] the scope of the current access token
|
95
|
+
def scope
|
78
96
|
if @access_token
|
79
|
-
|
80
|
-
"#{@access_token.token} #{scope}".strip
|
97
|
+
@access_token.params[:scope] || @access_token.params['scope']
|
81
98
|
end
|
82
99
|
end
|
83
100
|
|
@@ -347,6 +364,7 @@ module GoCardless
|
|
347
364
|
opts[:headers]['Content-Type'] = 'application/json' unless method == :get
|
348
365
|
opts[:headers]['User-Agent'] = user_agent
|
349
366
|
opts[:body] = MultiJson.encode(opts[:data]) if !opts[:data].nil?
|
367
|
+
path = URI.encode(path)
|
350
368
|
|
351
369
|
# Reset the URL in case the environment / base URL has been changed.
|
352
370
|
@oauth_client.site = base_url
|
data/lib/gocardless/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -130,7 +130,38 @@ describe GoCardless::Client do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
describe "#scoped_access_token" do
|
134
|
+
it "serializes access token correctly" do
|
135
|
+
oauth_client = @client.instance_variable_get(:@oauth_client)
|
136
|
+
token = OAuth2::AccessToken.new(oauth_client, 'TOKEN123')
|
137
|
+
token.params['scope'] = 'a:1 b:2'
|
138
|
+
@client.instance_variable_set(:@access_token, token)
|
139
|
+
|
140
|
+
@client.scoped_access_token.should == 'TOKEN123 a:1 b:2'
|
141
|
+
end
|
142
|
+
|
143
|
+
it "and_return nil when there's no token" do
|
144
|
+
@client.scoped_access_token.should be_nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#unscoped_access_token" do
|
149
|
+
it "serializes access token correctly" do
|
150
|
+
oauth_client = @client.instance_variable_get(:@oauth_client)
|
151
|
+
token = OAuth2::AccessToken.new(oauth_client, 'TOKEN123')
|
152
|
+
token.params['scope'] = 'a:1 b:2'
|
153
|
+
@client.instance_variable_set(:@access_token, token)
|
154
|
+
|
155
|
+
@client.unscoped_access_token.should == 'TOKEN123'
|
156
|
+
end
|
157
|
+
|
158
|
+
it "and_return nil when there's no token" do
|
159
|
+
@client.unscoped_access_token.should be_nil
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
133
163
|
describe "#access_token" do
|
164
|
+
before { @client.stub(:warn) }
|
134
165
|
it "serializes access token correctly" do
|
135
166
|
oauth_client = @client.instance_variable_get(:@oauth_client)
|
136
167
|
token = OAuth2::AccessToken.new(oauth_client, 'TOKEN123')
|
@@ -143,6 +174,26 @@ describe GoCardless::Client do
|
|
143
174
|
it "and_return nil when there's no token" do
|
144
175
|
@client.access_token.should be_nil
|
145
176
|
end
|
177
|
+
|
178
|
+
it "issues a deprecation warning" do
|
179
|
+
@client.should_receive(:warn)
|
180
|
+
@client.access_token
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "#scope" do
|
185
|
+
it "serializes the access token correctly" do
|
186
|
+
oauth_client = @client.instance_variable_get(:@oauth_client)
|
187
|
+
token = OAuth2::AccessToken.new(oauth_client, 'TOKEN123')
|
188
|
+
token.params['scope'] = 'a:1 b:2'
|
189
|
+
@client.instance_variable_set(:@access_token, token)
|
190
|
+
|
191
|
+
@client.scope.should == 'a:1 b:2'
|
192
|
+
end
|
193
|
+
|
194
|
+
it "and_return nil when there's no token" do
|
195
|
+
@client.scope.should be_nil
|
196
|
+
end
|
146
197
|
end
|
147
198
|
|
148
199
|
describe "#access_token=" do
|
@@ -518,7 +569,6 @@ describe GoCardless::Client do
|
|
518
569
|
|
519
570
|
it "includes the gem name" do
|
520
571
|
expect(user_agent).to include("gocardless-ruby")
|
521
|
-
puts(user_agent)
|
522
572
|
end
|
523
573
|
|
524
574
|
it "includes the gem version" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocardless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Marr
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|