gocardless 1.10.1 → 1.11.0

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: 2e22096b949c5df3105ed9060a58824e185fd993
4
- data.tar.gz: 1cc708492608cf07feb13e391e11c6b1e9411925
3
+ metadata.gz: bb186568bf3bab6c1d0baf10394a75ecd1b14534
4
+ data.tar.gz: 033069ff0faa53aa992680bd46bd0b0296b6f4c0
5
5
  SHA512:
6
- metadata.gz: b5a4f60f99788d941ad2e0d5444fd3a83f9e26ffcb1e601fdc137de1b9c7a474f5101b183b83672180aae15bb9664393dbf5663234293defaef080c85299e099
7
- data.tar.gz: 4e2e79bd303380b67722277a242f533887630d8f3cb9c4259a699c5da64d3aa24b48c9bd2c5ac18929c7facf97d87a3274aae65b2704d34e800e3871b585775b
6
+ metadata.gz: 979d094b2b639f33f92626feb7cff70da4b55cd241fae9dae12f049282c0c99bece3f2fee1f916a6ebb98c4d3eb3ac80600fe7757aab43cb5670c3981ddbc2db
7
+ data.tar.gz: cd6bfe4b1a8bf4fcb4ca8eda5357aeaa6459a03e64eabc3ae376f85a77a3718e0c07c98108b9465d7521e0ab820165b4587d2b31de5ad30b8673942712f980c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.11.0 - July 07, 2014
2
+
3
+ - URI encode path before making requests
4
+ - Deprecate Client#access_token
5
+
6
+
1
7
  ## 1.10.1 - June 09, 2014
2
8
 
3
9
  - Use a more useful user agent header
@@ -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.access_token
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
- scope = @access_token.params[:scope] || @access_token.params['scope']
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
@@ -1,3 +1,3 @@
1
1
  module GoCardless
2
- VERSION = '1.10.1'.freeze
2
+ VERSION = '1.11.0'.freeze
3
3
  end
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.10.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-06-09 00:00:00.000000000 Z
12
+ date: 2014-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2