stripe 1.20.3 → 1.20.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/VERSION +1 -1
- data/lib/stripe/account.rb +4 -1
- data/lib/stripe/api_resource.rb +1 -1
- data/lib/stripe/singleton_api_resource.rb +1 -1
- data/lib/stripe/util.rb +11 -2
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_test.rb +18 -2
- data/test/stripe/api_resource_test.rb +17 -1
- data/test/stripe/util_test.rb +5 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 1.20.4 2015-03-26
|
2
|
+
|
3
|
+
* Raise an error when explicitly passing nil as the API key on resource methods
|
4
|
+
* Fix error when passing an API key to Balance.retrieve (github issue #232)
|
5
|
+
|
6
|
+
=== 1.20.3 2015-03-13
|
7
|
+
|
8
|
+
* Fixed error when updating certain resources (github issue #224)
|
9
|
+
|
1
10
|
=== 1.20.2 2015-03-10
|
2
11
|
|
3
12
|
* Added support for updating nested hashes besides `metadata` (which was already supported)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.20.
|
1
|
+
1.20.4
|
data/lib/stripe/account.rb
CHANGED
@@ -13,7 +13,8 @@ module Stripe
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# @override To make id optional
|
16
|
-
def self.retrieve(id=
|
16
|
+
def self.retrieve(id=ARGUMENT_NOT_PROVIDED, opts={})
|
17
|
+
id = id.equal?(ARGUMENT_NOT_PROVIDED) ? nil : Util.check_string_argument!(id)
|
17
18
|
# Account used to be a singleton, where this method's signature was `(opts={})`.
|
18
19
|
# For the sake of not breaking folks who pass in an OAuth key in opts, let's lurkily
|
19
20
|
# string match for it.
|
@@ -31,5 +32,7 @@ module Stripe
|
|
31
32
|
opts.delete(:api_base) # the api_base here is a one-off, don't persist it
|
32
33
|
Util.convert_to_stripe_object(response, opts)
|
33
34
|
end
|
35
|
+
|
36
|
+
ARGUMENT_NOT_PROVIDED = Object.new
|
34
37
|
end
|
35
38
|
end
|
data/lib/stripe/api_resource.rb
CHANGED
data/lib/stripe/util.rb
CHANGED
@@ -123,15 +123,24 @@ module Stripe
|
|
123
123
|
# Turn this value into an api_key and a set of headers
|
124
124
|
def self.normalize_opts(opts)
|
125
125
|
case opts
|
126
|
-
when NilClass
|
127
|
-
{}
|
128
126
|
when String
|
129
127
|
{:api_key => opts}
|
130
128
|
when Hash
|
129
|
+
check_api_key!(opts.fetch(:api_key)) if opts.has_key?(:api_key)
|
131
130
|
opts.clone
|
132
131
|
else
|
133
132
|
raise TypeError.new('normalize_opts expects a string or a hash')
|
134
133
|
end
|
135
134
|
end
|
135
|
+
|
136
|
+
def self.check_string_argument!(key)
|
137
|
+
raise TypeError.new("argument must be a string") unless key.is_a?(String)
|
138
|
+
key
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.check_api_key!(key)
|
142
|
+
raise TypeError.new("api_key must be a string") unless key.is_a?(String)
|
143
|
+
key
|
144
|
+
end
|
136
145
|
end
|
137
146
|
end
|
data/lib/stripe/version.rb
CHANGED
data/test/stripe/account_test.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class AccountTest < Test::Unit::TestCase
|
5
|
-
should "
|
5
|
+
should "be retrievable" do
|
6
6
|
resp = {:email => "test+bindings@stripe.com", :charge_enabled => false, :details_submitted => false}
|
7
7
|
@mock.expects(:get).
|
8
8
|
once.
|
@@ -14,7 +14,7 @@ module Stripe
|
|
14
14
|
assert !a.details_submitted
|
15
15
|
end
|
16
16
|
|
17
|
-
should "
|
17
|
+
should "be retrievable via plural endpoint" do
|
18
18
|
resp = {:email => "test+bindings@stripe.com", :charge_enabled => false, :details_submitted => false}
|
19
19
|
@mock.expects(:get).
|
20
20
|
once.
|
@@ -26,6 +26,13 @@ module Stripe
|
|
26
26
|
assert !a.details_submitted
|
27
27
|
end
|
28
28
|
|
29
|
+
should "be retrievable using an API key as the only argument" do
|
30
|
+
account = mock
|
31
|
+
Stripe::Account.expects(:new).once.with(nil, {:api_key => 'sk_foobar'}).returns(account)
|
32
|
+
account.expects(:refresh).once
|
33
|
+
Stripe::Account.retrieve('sk_foobar')
|
34
|
+
end
|
35
|
+
|
29
36
|
should "be updatable" do
|
30
37
|
resp = {
|
31
38
|
:id => 'acct_foo',
|
@@ -62,5 +69,14 @@ module Stripe
|
|
62
69
|
end.returns(test_response({ 'stripe_user_id' => a.id }))
|
63
70
|
a.deauthorize('ca_1234', 'sk_test_1234')
|
64
71
|
end
|
72
|
+
|
73
|
+
should "reject nil api keys" do
|
74
|
+
assert_raise TypeError do
|
75
|
+
Stripe::Account.retrieve(nil)
|
76
|
+
end
|
77
|
+
assert_raise TypeError do
|
78
|
+
Stripe::Account.retrieve(:api_key => nil)
|
79
|
+
end
|
80
|
+
end
|
65
81
|
end
|
66
82
|
end
|
@@ -37,6 +37,15 @@ module Stripe
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
should "using a nil api key should raise an exception" do
|
41
|
+
assert_raises TypeError do
|
42
|
+
Stripe::Customer.all({}, nil)
|
43
|
+
end
|
44
|
+
assert_raises TypeError do
|
45
|
+
Stripe::Customer.all({}, { :api_key => nil })
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
40
49
|
should "specifying api credentials containing whitespace should raise an exception" do
|
41
50
|
Stripe.api_key = "key "
|
42
51
|
assert_raises Stripe::AuthenticationError do
|
@@ -469,7 +478,14 @@ module Stripe
|
|
469
478
|
}
|
470
479
|
})
|
471
480
|
|
472
|
-
@mock.expects(:post).once.with(
|
481
|
+
@mock.expects(:post).once.with(
|
482
|
+
"#{Stripe.api_base}/v1/accounts/myid",
|
483
|
+
nil,
|
484
|
+
any_of(
|
485
|
+
'legal_entity[first_name]=Bob&legal_entity[last_name]=',
|
486
|
+
'legal_entity[last_name]=&legal_entity[first_name]=Bob'
|
487
|
+
)
|
488
|
+
).returns(test_response({"id" => "myid"}))
|
473
489
|
|
474
490
|
acct.legal_entity = {:first_name => 'Bob'}
|
475
491
|
acct.save
|
data/test/stripe/util_test.rb
CHANGED
@@ -25,5 +25,10 @@ module Stripe
|
|
25
25
|
symbolized = Stripe::Util.symbolize_names(start)
|
26
26
|
assert_equal(finish, symbolized)
|
27
27
|
end
|
28
|
+
|
29
|
+
should "normalize_opts should reject nil keys" do
|
30
|
+
assert_raise { Stripe::Util.normalize_opts(nil) }
|
31
|
+
assert_raise { Stripe::Util.normalize_opts(:api_key => nil) }
|
32
|
+
end
|
28
33
|
end
|
29
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.20.
|
4
|
+
version: 1.20.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-03-
|
13
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|