stripe 1.10.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/lib/stripe.rb +6 -7
- data/lib/stripe/api_operations/update.rb +2 -2
- data/lib/stripe/stripe_object.rb +12 -3
- data/lib/stripe/version.rb +1 -1
- data/stripe.gemspec +1 -1
- data/test/stripe/stripe_object_test.rb +11 -4
- data/test/test_helper.rb +1 -1
- metadata +7 -14
- data/lib/stripe/json.rb +0 -21
data/History.txt
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
=== 1.10.1 2014-02-03
|
2
|
+
|
3
|
+
* Fix marshaling of StripeObjects
|
4
|
+
|
1
5
|
=== 1.10.0 2014-01-29
|
2
6
|
|
3
7
|
* Support for multiple subscriptions per customer
|
8
|
+
* Allow #save to take opts (for :expand)
|
9
|
+
* Testing ruby 2.1.0
|
10
|
+
* Replace multi_json with json
|
11
|
+
* Fix #try and #respond_to? on StripeObjects
|
4
12
|
|
5
13
|
=== 1.9.9 2013-12-02
|
6
14
|
|
data/README.rdoc
CHANGED
@@ -15,12 +15,12 @@ If you want to build the gem from source:
|
|
15
15
|
|
16
16
|
* Ruby 1.8.7 or above. (Ruby 1.8.6 may work if you load
|
17
17
|
ActiveSupport.)
|
18
|
-
* rest-client,
|
18
|
+
* rest-client, json
|
19
19
|
|
20
20
|
== Mirrors
|
21
21
|
|
22
22
|
The stripe gem is mirrored on Rubygems, so you should be able to
|
23
|
-
install it via <tt>gem install stripe</tt> if desired. We recommend using
|
23
|
+
install it via <tt>gem install stripe</tt> if desired. We recommend using
|
24
24
|
the https://code.stripe.com mirror so all code is fetched over SSL.
|
25
25
|
|
26
26
|
Note that if you are installing via bundler, you should be sure to use the https
|
@@ -29,7 +29,7 @@ comprimised in transit and alter the code of gems fetched securely over https:
|
|
29
29
|
|
30
30
|
source 'https://code.stripe.com'
|
31
31
|
source 'https://rubygems.org'
|
32
|
-
|
32
|
+
|
33
33
|
gem 'rails'
|
34
34
|
gem 'stripe'
|
35
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.10.
|
1
|
+
1.10.1
|
data/lib/stripe.rb
CHANGED
@@ -4,7 +4,7 @@ require 'cgi'
|
|
4
4
|
require 'set'
|
5
5
|
require 'openssl'
|
6
6
|
require 'rest_client'
|
7
|
-
require '
|
7
|
+
require 'json'
|
8
8
|
|
9
9
|
# Version
|
10
10
|
require 'stripe/version'
|
@@ -17,7 +17,6 @@ require 'stripe/api_operations/list'
|
|
17
17
|
|
18
18
|
# Resources
|
19
19
|
require 'stripe/util'
|
20
|
-
require 'stripe/json'
|
21
20
|
require 'stripe/stripe_object'
|
22
21
|
require 'stripe/api_resource'
|
23
22
|
require 'stripe/singleton_api_resource'
|
@@ -180,7 +179,7 @@ module Stripe
|
|
180
179
|
headers[:stripe_version] = api_version if api_version
|
181
180
|
|
182
181
|
begin
|
183
|
-
headers.update(:x_stripe_client_user_agent =>
|
182
|
+
headers.update(:x_stripe_client_user_agent => JSON.generate(user_agent))
|
184
183
|
rescue => e
|
185
184
|
headers.update(:x_stripe_client_raw_user_agent => user_agent.inspect,
|
186
185
|
:error => "#{e} (#{e.class})")
|
@@ -195,8 +194,8 @@ module Stripe
|
|
195
194
|
begin
|
196
195
|
# Would use :symbolize_names => true, but apparently there is
|
197
196
|
# some library out there that makes symbolize_names not work.
|
198
|
-
response =
|
199
|
-
rescue
|
197
|
+
response = JSON.parse(response.body)
|
198
|
+
rescue JSON::ParserError
|
200
199
|
raise general_api_error(response.code, response.body)
|
201
200
|
end
|
202
201
|
|
@@ -210,11 +209,11 @@ module Stripe
|
|
210
209
|
|
211
210
|
def self.handle_api_error(rcode, rbody)
|
212
211
|
begin
|
213
|
-
error_obj =
|
212
|
+
error_obj = JSON.parse(rbody)
|
214
213
|
error_obj = Util.symbolize_names(error_obj)
|
215
214
|
error = error_obj[:error] or raise StripeError.new # escape from parsing
|
216
215
|
|
217
|
-
rescue
|
216
|
+
rescue JSON::ParserError, StripeError
|
218
217
|
raise general_api_error(rcode, rbody)
|
219
218
|
end
|
220
219
|
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -36,12 +36,12 @@ module Stripe
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def to_s(*args)
|
39
|
-
|
39
|
+
JSON.pretty_generate(@values)
|
40
40
|
end
|
41
41
|
|
42
42
|
def inspect()
|
43
43
|
id_string = (self.respond_to?(:id) && !self.id.nil?) ? " id=#{self.id}" : ""
|
44
|
-
"#<#{self.class}:0x#{self.object_id.to_s(16)}#{id_string}> JSON: " +
|
44
|
+
"#<#{self.class}:0x#{self.object_id.to_s(16)}#{id_string}> JSON: " + JSON.pretty_generate(@values)
|
45
45
|
end
|
46
46
|
|
47
47
|
def refresh_from(values, api_key, partial=false)
|
@@ -87,7 +87,7 @@ module Stripe
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def to_json(*a)
|
90
|
-
|
90
|
+
JSON.generate(@values)
|
91
91
|
end
|
92
92
|
|
93
93
|
def as_json(*a)
|
@@ -102,6 +102,15 @@ module Stripe
|
|
102
102
|
@values.each(&blk)
|
103
103
|
end
|
104
104
|
|
105
|
+
def _dump(level)
|
106
|
+
Marshal.dump([@values, @api_key])
|
107
|
+
end
|
108
|
+
|
109
|
+
def self._load(args)
|
110
|
+
values, api_key = Marshal.load(args)
|
111
|
+
construct_from(values, api_key)
|
112
|
+
end
|
113
|
+
|
105
114
|
if RUBY_VERSION < '1.9.2'
|
106
115
|
def respond_to?(symbol)
|
107
116
|
@values.has_key?(symbol) || super
|
data/lib/stripe/version.rb
CHANGED
data/stripe.gemspec
CHANGED
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_dependency('rest-client', '~> 1.4')
|
16
16
|
s.add_dependency('mime-types', '~> 1.25')
|
17
|
-
s.add_dependency('
|
17
|
+
s.add_dependency('json', '~> 1.8.1')
|
18
18
|
|
19
19
|
s.add_development_dependency('mocha', '~> 0.13.2')
|
20
20
|
s.add_development_dependency('shoulda', '~> 3.4.0')
|
@@ -3,11 +3,18 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
3
3
|
module Stripe
|
4
4
|
class StripeObjectTest < Test::Unit::TestCase
|
5
5
|
should "implement #respond_to correctly" do
|
6
|
-
obj = Stripe::StripeObject.construct_from({ :
|
7
|
-
|
6
|
+
obj = Stripe::StripeObject.construct_from({ :id => 1, :foo => 'bar' })
|
8
7
|
assert obj.respond_to?(:id)
|
9
|
-
assert obj.respond_to?(:
|
10
|
-
assert !obj.respond_to?(:
|
8
|
+
assert obj.respond_to?(:foo)
|
9
|
+
assert !obj.respond_to?(:baz)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "marshal a stripe object correctly" do
|
13
|
+
obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' }, 'apikey')
|
14
|
+
m = Marshal.load(Marshal.dump(obj))
|
15
|
+
assert_equal m.id, 1
|
16
|
+
assert_equal m.name, 'Stripe'
|
17
|
+
assert_equal m.api_key, 'apikey'
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
data/test/test_helper.rb
CHANGED
@@ -26,7 +26,7 @@ end
|
|
26
26
|
def test_response(body, code=200)
|
27
27
|
# When an exception is raised, restclient clobbers method_missing. Hence we
|
28
28
|
# can't just use the stubs interface.
|
29
|
-
body =
|
29
|
+
body = JSON.generate(body) if !(body.kind_of? String)
|
30
30
|
m = mock
|
31
31
|
m.instance_variable_set('@stripe_values', { :body => body, :code => code })
|
32
32
|
def m.body; @stripe_values[:body]; 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.10.
|
4
|
+
version: 1.10.1
|
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: 2014-
|
13
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -45,27 +45,21 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.25'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: json
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.4
|
55
|
-
- - <
|
52
|
+
- - ~>
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
54
|
+
version: 1.8.1
|
58
55
|
type: :runtime
|
59
56
|
prerelease: false
|
60
57
|
version_requirements: !ruby/object:Gem::Requirement
|
61
58
|
none: false
|
62
59
|
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.0.4
|
66
|
-
- - <
|
60
|
+
- - ~>
|
67
61
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
62
|
+
version: 1.8.1
|
69
63
|
- !ruby/object:Gem::Dependency
|
70
64
|
name: mocha
|
71
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +171,6 @@ files:
|
|
177
171
|
- lib/stripe/event.rb
|
178
172
|
- lib/stripe/invoice.rb
|
179
173
|
- lib/stripe/invoice_item.rb
|
180
|
-
- lib/stripe/json.rb
|
181
174
|
- lib/stripe/list_object.rb
|
182
175
|
- lib/stripe/plan.rb
|
183
176
|
- lib/stripe/recipient.rb
|
data/lib/stripe/json.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Stripe
|
2
|
-
module JSON
|
3
|
-
if MultiJson.respond_to?(:dump)
|
4
|
-
def self.dump(*args)
|
5
|
-
MultiJson.dump(*args)
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.load(*args)
|
9
|
-
MultiJson.load(*args)
|
10
|
-
end
|
11
|
-
else
|
12
|
-
def self.dump(*args)
|
13
|
-
MultiJson.encode(*args)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.load(*args)
|
17
|
-
MultiJson.decode(*args)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|