stripe 1.30.0 → 1.30.1
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/History.txt +5 -0
- data/VERSION +1 -1
- data/lib/stripe/api_operations/list.rb +7 -3
- data/lib/stripe/list_object.rb +13 -10
- data/lib/stripe/util.rb +1 -5
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_test.rb +1 -1
- data/test/stripe/list_object_test.rb +26 -8
- data/test/stripe/metadata_test.rb +1 -1
- data/test/stripe/util_test.rb +34 -21
- 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: a744255415d993917d419962d5f1420b8daed37d
|
4
|
+
data.tar.gz: 1c9085d745949c729e3c9caa3e986d16c6373eda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02b09d3707b1861f069cbd46124fe5c03aa86a44f47973a01315156056765404ddc54423b6479141f56cb1cd9ef28679dcfed3147d98e65d11835eb5622a275f
|
7
|
+
data.tar.gz: 1f7d8ccf6eac75aea02b7935587f8448d363601f92f1f5245ebb4639e6f9a6c9f71f0201c88a14d86a6e172dab79351088bd103ae47230718b18a47340dc9c17
|
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
=== 1.30.1 2015-10-10
|
2
|
+
|
3
|
+
* Fix bug that prevent lists of hashes from being URI-encoded properly
|
4
|
+
* Fix bug where filter conditions were not making it fast the first instantiated `ListObject`
|
5
|
+
|
1
6
|
=== 1.30.0 2015-10-09
|
2
7
|
|
3
8
|
* Add `StripeObject#deleted?` for a reliable way to check whether an object is alive
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.30.
|
1
|
+
1.30.1
|
@@ -8,9 +8,13 @@ module Stripe
|
|
8
8
|
response, opts = request(:get, url, filters, opts)
|
9
9
|
obj = ListObject.construct_from(response, opts)
|
10
10
|
|
11
|
-
# set
|
12
|
-
# next and previous pages
|
13
|
-
|
11
|
+
# set filters so that we can fetch the same limit, expansions, and
|
12
|
+
# predicates when accessing the next and previous pages
|
13
|
+
#
|
14
|
+
# just for general cleanliness, remove any paging options
|
15
|
+
obj.filters = filters.dup
|
16
|
+
obj.filters.delete(:ending_before)
|
17
|
+
obj.filters.delete(:starting_after)
|
14
18
|
|
15
19
|
obj
|
16
20
|
end
|
data/lib/stripe/list_object.rb
CHANGED
@@ -4,10 +4,10 @@ module Stripe
|
|
4
4
|
include Stripe::APIOperations::List
|
5
5
|
include Stripe::APIOperations::Request
|
6
6
|
|
7
|
-
# This accessor allows a `ListObject` to inherit
|
8
|
-
# a predecessor. This allows
|
9
|
-
# resources.
|
10
|
-
attr_accessor :
|
7
|
+
# This accessor allows a `ListObject` to inherit various filters that were
|
8
|
+
# given to a predecessor. This allows for things like consistent limits,
|
9
|
+
# expansions, and predicates as a user pages through resources.
|
10
|
+
attr_accessor :filters
|
11
11
|
|
12
12
|
# An empty list object. This is returned from +next+ when we know that
|
13
13
|
# there isn't a next page in order to replicate the behavior of the API
|
@@ -16,6 +16,11 @@ module Stripe
|
|
16
16
|
ListObject.construct_from({ :data => [] }, opts)
|
17
17
|
end
|
18
18
|
|
19
|
+
def initialize(*args)
|
20
|
+
super
|
21
|
+
self.filters = {}
|
22
|
+
end
|
23
|
+
|
19
24
|
def [](k)
|
20
25
|
case k
|
21
26
|
when String, Symbol
|
@@ -75,10 +80,9 @@ module Stripe
|
|
75
80
|
return self.class.empty_list(opts) if !has_more
|
76
81
|
last_id = data.last.id
|
77
82
|
|
78
|
-
params = {
|
79
|
-
:limit => limit, # may be nil
|
83
|
+
params = filters.merge({
|
80
84
|
:starting_after => last_id,
|
81
|
-
}.merge(params)
|
85
|
+
}).merge(params)
|
82
86
|
|
83
87
|
list(params, opts)
|
84
88
|
end
|
@@ -90,10 +94,9 @@ module Stripe
|
|
90
94
|
def previous_page(params={}, opts={})
|
91
95
|
first_id = data.first.id
|
92
96
|
|
93
|
-
params = {
|
97
|
+
params = filters.merge({
|
94
98
|
:ending_before => first_id,
|
95
|
-
|
96
|
-
}.merge(params)
|
99
|
+
}).merge(params)
|
97
100
|
|
98
101
|
list(params, opts)
|
99
102
|
end
|
data/lib/stripe/util.rb
CHANGED
@@ -127,11 +127,7 @@ module Stripe
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
|
131
|
-
# our 1.8.7 test suite where Hash key order is not preserved.
|
132
|
-
#
|
133
|
-
# https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/
|
134
|
-
result.sort_by { |(k, _)| k }
|
130
|
+
result
|
135
131
|
end
|
136
132
|
|
137
133
|
def self.flatten_params_array(value, calculated_key)
|
data/lib/stripe/version.rb
CHANGED
data/test/stripe/account_test.rb
CHANGED
@@ -68,7 +68,7 @@ module Stripe
|
|
68
68
|
|
69
69
|
@mock.expects(:post).
|
70
70
|
once.
|
71
|
-
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[address][line1]=2+Three+Four
|
71
|
+
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[first_name]=Bob&legal_entity[address][line1]=2+Three+Four').
|
72
72
|
returns(make_response(resp))
|
73
73
|
|
74
74
|
a = Stripe::Account.retrieve('acct_foo')
|
@@ -79,11 +79,20 @@ module Stripe
|
|
79
79
|
|
80
80
|
should "fetch a next page through #next_page and respect limit" do
|
81
81
|
list = TestListObject.construct_from({ :data => [{ :id => 1 }], :has_more => true })
|
82
|
-
list.
|
83
|
-
@mock.expects(:get).
|
84
|
-
|
82
|
+
list.filters = { :expand => ['data.source'], :limit => 3 }
|
83
|
+
@mock.expects(:get).with do |url, _, _|
|
84
|
+
# apparently URI.parse in 1.8.7 doesn't support query parameters ...
|
85
|
+
url, query = url.split("?")
|
86
|
+
u = URI.parse(url)
|
87
|
+
params = CGI.parse(query)
|
88
|
+
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
89
|
+
"expand[]" => ["data.source"],
|
90
|
+
"limit" => ["3"],
|
91
|
+
"starting_after" => ["1"],
|
92
|
+
}
|
93
|
+
end.returns(make_response({ :data => [{ :id => 2 }], :has_more => false }))
|
85
94
|
next_list = list.next_page
|
86
|
-
assert_equal 3, next_list.
|
95
|
+
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
87
96
|
end
|
88
97
|
|
89
98
|
should "fetch an empty page through #next_page" do
|
@@ -106,11 +115,20 @@ module Stripe
|
|
106
115
|
|
107
116
|
should "fetch a next page through #previous_page and respect limit" do
|
108
117
|
list = TestListObject.construct_from({ :data => [{ :id => 2 }] })
|
109
|
-
list.
|
110
|
-
@mock.expects(:get).
|
111
|
-
|
118
|
+
list.filters = { :expand => ['data.source'], :limit => 3 }
|
119
|
+
@mock.expects(:get).with do |url, _, _|
|
120
|
+
# apparently URI.parse in 1.8.7 doesn't support query parameters ...
|
121
|
+
url, query = url.split("?")
|
122
|
+
u = URI.parse(url)
|
123
|
+
params = CGI.parse(query)
|
124
|
+
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
125
|
+
"ending_before" => ["2"],
|
126
|
+
"expand[]" => ["data.source"],
|
127
|
+
"limit" => ["3"],
|
128
|
+
}
|
129
|
+
end.returns(make_response({ :data => [{ :id => 1 }] }))
|
112
130
|
next_list = list.previous_page
|
113
|
-
assert_equal 3, next_list.
|
131
|
+
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
114
132
|
end
|
115
133
|
|
116
134
|
#
|
data/test/stripe/util_test.rb
CHANGED
@@ -3,13 +3,14 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
3
3
|
module Stripe
|
4
4
|
class UtilTest < Test::Unit::TestCase
|
5
5
|
should "#encode_parameters should prepare parameters for an HTTP request" do
|
6
|
-
|
7
|
-
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
|
6
|
+
# use array instead of hash for 1.8.7 ordering
|
7
|
+
params = [
|
8
|
+
[:a, 3],
|
9
|
+
[:b, "+foo?"],
|
10
|
+
[:c, "bar&baz"],
|
11
|
+
[:d, { :a => "a", :b => "b" }],
|
12
|
+
[:e, [0, 1]],
|
13
|
+
]
|
13
14
|
assert_equal(
|
14
15
|
"a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1",
|
15
16
|
Stripe::Util.encode_parameters(params)
|
@@ -25,21 +26,33 @@ module Stripe
|
|
25
26
|
end
|
26
27
|
|
27
28
|
should "#flatten_params should encode parameters according to Rails convention" do
|
28
|
-
params =
|
29
|
-
:a
|
30
|
-
:b
|
31
|
-
:c
|
32
|
-
:d
|
33
|
-
:e
|
34
|
-
|
29
|
+
params = [
|
30
|
+
[:a, 3],
|
31
|
+
[:b, "foo?"],
|
32
|
+
[:c, "bar&baz"],
|
33
|
+
[:d, { :a => "a", :b => "b" }],
|
34
|
+
[:e, [0, 1]],
|
35
|
+
[:f, [
|
36
|
+
{ :foo => "1", :bar => "2" },
|
37
|
+
{ :foo => "3", :baz => "4" },
|
38
|
+
]],
|
39
|
+
]
|
35
40
|
assert_equal([
|
36
|
-
["a",
|
37
|
-
["b",
|
38
|
-
["c",
|
39
|
-
["d[a]",
|
40
|
-
["d[b]",
|
41
|
-
["e[]",
|
42
|
-
["e[]",
|
41
|
+
["a", 3],
|
42
|
+
["b", "foo?"],
|
43
|
+
["c", "bar&baz"],
|
44
|
+
["d[a]", "a"],
|
45
|
+
["d[b]", "b"],
|
46
|
+
["e[]", 0],
|
47
|
+
["e[]", 1],
|
48
|
+
|
49
|
+
# *The key here is the order*. In order to be properly interpreted as
|
50
|
+
# an array of hashes on the server, everything from a single hash must
|
51
|
+
# come in at once. A duplicate key in an array triggers a new element.
|
52
|
+
["f[][foo]", "1"],
|
53
|
+
["f[][bar]", "2"],
|
54
|
+
["f[][foo]", "3"],
|
55
|
+
["f[][baz]", "4"],
|
43
56
|
], Stripe::Util.flatten_params(params))
|
44
57
|
end
|
45
58
|
|
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.30.
|
4
|
+
version: 1.30.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Boucher
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|