gocardless 0.1.2 → 0.1.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ ## 0.1.3 - February 22, 2012
2
+
3
+ - Fix parameter encoding in `Client#new_merchant_url` (related to Faraday issue
4
+ #115)
5
+ - Allow changing environment / base_url after client init
6
+
7
+
8
+ ## 0.1.2 - February 2, 2012
9
+
10
+ - Add `webhook_valid?` method to `Client`
11
+ - Make `confirm_resource` play nicely with `HashWithIndifferentAccess`
12
+ - More RFC compliant parameter encoding
13
+
14
+
15
+ ## 0.1.1 - January 12, 2012
16
+
17
+ - Add `name` to `Bill`
18
+ - Add `state` support to `new_{subscription,pre_authorization,bill}_url`
19
+
20
+
21
+ ## 0.1.0 - November 23, 2011
22
+
23
+ - Initial release
24
+
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ group :development do
6
6
  gem "guard", "~> 0.8.8"
7
7
  if RUBY_PLATFORM.downcase.include?("darwin")
8
8
  gem "guard-rspec", "~> 0.5.4"
9
- gem "rb-fsevent", "~> 0.4.3.1"
10
- gem "growl_notify", "~> 0.0.3"
9
+ gem "rb-fsevent", "~> 0.9"
10
+ gem "growl", "~> 1.0.3"
11
11
  end
12
12
  end
data/Rakefile CHANGED
@@ -3,7 +3,8 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  desc "Generate YARD documentation"
5
5
  YARD::Rake::YardocTask.new do |t|
6
- t.files = ['lib/**/*.rb'].reject { |f| f.match(/seed|example/) }
6
+ files = ['lib/**/*.rb', '-', 'CHANGELOG.md', 'LICENSE']
7
+ t.files = files.reject { |f| f =~ /seed|example/ }
7
8
  end
8
9
 
9
10
  desc "Run the specs"
@@ -53,6 +53,8 @@ module GoCardless
53
53
  :response_type => 'code',
54
54
  :scope => 'manage_merchant'
55
55
  }
56
+ # Faraday doesn't flatten params in this case (Faraday issue #115)
57
+ options = Hash[Utils.flatten_params(options)]
56
58
  @oauth_client.authorize_url(params.merge(options))
57
59
  end
58
60
  alias :new_merchant_url :authorize_url
@@ -250,7 +252,7 @@ module GoCardless
250
252
  # Validates the payload contents of a webhook request.
251
253
  #
252
254
  # @param [Hash] params the contents of payload of the webhook
253
- # @return [boolean] true when valid, false otherwise
255
+ # @return [Boolean] true when valid, false otherwise
254
256
  def webhook_valid?(params)
255
257
  signature_valid?(params)
256
258
  end
@@ -261,14 +263,18 @@ module GoCardless
261
263
  #
262
264
  # @param [Symbol] method the HTTP method to use (e.g. +:get+, +:post+)
263
265
  # @param [String] path the path fragment of the URL
264
- # @option [String] body the request body
265
- # @option [Hash] params query string parameters
266
+ # @option [Hash] opts query string parameters
266
267
  def request(method, path, opts = {})
267
268
  raise ClientError, 'Access token missing' unless @access_token
269
+
268
270
  opts[:headers] = {} if opts[:headers].nil?
269
271
  opts[:headers]['Accept'] = 'application/json'
270
272
  opts[:headers]['Content-Type'] = 'application/json' unless method == :get
271
273
  opts[:body] = JSON.generate(opts[:data]) if !opts[:data].nil?
274
+
275
+ # Reset the URL in case the environment / base URL has been changed.
276
+ @oauth_client.site = self.class.base_url
277
+
272
278
  header_keys = opts[:headers].keys.map(&:to_s)
273
279
  if header_keys.map(&:downcase).include?('authorization')
274
280
  @oauth_client.request(method, path, opts)
@@ -1,3 +1,3 @@
1
1
  module GoCardless
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -53,6 +53,13 @@ describe GoCardless::Client do
53
53
  query['redirect_uri'].first.should == @redirect_uri
54
54
  query['client_id'].first.should == @app_id
55
55
  end
56
+
57
+ it "encodes prefilling parameters correctly" do
58
+ params = {:merchant => {:user => {:email => "a@b.com"}}}
59
+ url = @client.authorize_url(params.merge(:redirect_uri => @redirect_uri))
60
+ encoded_key = GoCardless::Utils.percent_encode('merchant[user][email]')
61
+ URI.parse(url).query.should match /#{encoded_key}=a%40b\.com/
62
+ end
56
63
  end
57
64
 
58
65
  describe "#fetch_access_token" do
@@ -341,10 +348,10 @@ describe GoCardless::Client do
341
348
  end
342
349
 
343
350
  it "should include the redirect_uri in the URL query" do
344
- params = { 'a' => '1', 'b' => '2', :redirect_uri => "http://www.google.com" }
345
- url = @client.send(:new_limit_url, :subscription, params)
346
- get_params(url)["redirect_uri"].should == "http://www.google.com"
347
- end
351
+ params = { 'a' => '1', 'b' => '2', :redirect_uri => "http://www.google.com" }
352
+ url = @client.send(:new_limit_url, :subscription, params)
353
+ get_params(url)["redirect_uri"].should == "http://www.google.com"
354
+ end
348
355
 
349
356
  it "should add merchant_id to the limit" do
350
357
  url = @client.send(:new_limit_url, :subscription, {})
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gocardless
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 800522045387967993
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Harry Marr
@@ -16,8 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-02-02 00:00:00 +00:00
20
- default_executable:
19
+ date: 2012-02-22 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: oauth2
@@ -27,7 +26,7 @@ dependencies:
27
26
  requirements:
28
27
  - - ~>
29
28
  - !ruby/object:Gem::Version
30
- hash: 15424071
29
+ hash: 2087324949208970369
31
30
  segments:
32
31
  - 0
33
32
  - 5
@@ -45,7 +44,7 @@ dependencies:
45
44
  requirements:
46
45
  - - ">="
47
46
  - !ruby/object:Gem::Version
48
- hash: 5
47
+ hash: 3211771947681907367
49
48
  segments:
50
49
  - 1
51
50
  - 5
@@ -61,7 +60,7 @@ dependencies:
61
60
  requirements:
62
61
  - - ~>
63
62
  - !ruby/object:Gem::Version
64
- hash: 15
63
+ hash: 4369430763100613689
65
64
  segments:
66
65
  - 2
67
66
  - 6
@@ -76,7 +75,7 @@ dependencies:
76
75
  requirements:
77
76
  - - ~>
78
77
  - !ruby/object:Gem::Version
79
- hash: 35
78
+ hash: 4175747960814336346
80
79
  segments:
81
80
  - 0
82
81
  - 9
@@ -92,7 +91,7 @@ dependencies:
92
91
  requirements:
93
92
  - - ~>
94
93
  - !ruby/object:Gem::Version
95
- hash: 5
94
+ hash: 3179421635518079399
96
95
  segments:
97
96
  - 0
98
97
  - 7
@@ -108,7 +107,7 @@ dependencies:
108
107
  requirements:
109
108
  - - ~>
110
109
  - !ruby/object:Gem::Version
111
- hash: 5
110
+ hash: 1606453007234795795
112
111
  segments:
113
112
  - 3
114
113
  - 1
@@ -128,6 +127,7 @@ files:
128
127
  - .gitignore
129
128
  - .rspec
130
129
  - .travis.yml
130
+ - CHANGELOG.md
131
131
  - Gemfile
132
132
  - Guardfile
133
133
  - LICENSE
@@ -153,7 +153,6 @@ files:
153
153
  - spec/resource_spec.rb
154
154
  - spec/spec_helper.rb
155
155
  - spec/utils_spec.rb
156
- has_rdoc: true
157
156
  homepage: https://github.com/gocardless/gocardless-ruby
158
157
  licenses: []
159
158
 
@@ -167,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
166
  requirements:
168
167
  - - ">="
169
168
  - !ruby/object:Gem::Version
170
- hash: 3
169
+ hash: 2002549777813010636
171
170
  segments:
172
171
  - 0
173
172
  version: "0"
@@ -176,14 +175,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
175
  requirements:
177
176
  - - ">="
178
177
  - !ruby/object:Gem::Version
179
- hash: 3
178
+ hash: 2002549777813010636
180
179
  segments:
181
180
  - 0
182
181
  version: "0"
183
182
  requirements: []
184
183
 
185
184
  rubyforge_project:
186
- rubygems_version: 1.6.2
185
+ rubygems_version: 1.8.12
187
186
  signing_key:
188
187
  specification_version: 3
189
188
  summary: Ruby wrapper for the GoCardless API
@@ -195,3 +194,4 @@ test_files:
195
194
  - spec/resource_spec.rb
196
195
  - spec/spec_helper.rb
197
196
  - spec/utils_spec.rb
197
+ has_rdoc: