stripe 1.5.17 → 1.5.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/stripe.rb +22 -2
  2. data/lib/stripe/version.rb +1 -1
  3. metadata +4 -4
data/lib/stripe.rb CHANGED
@@ -76,6 +76,22 @@ module Stripe
76
76
  true
77
77
  end
78
78
  end
79
+
80
+ def self.symbolize_names(object)
81
+ case object
82
+ when Hash
83
+ new = {}
84
+ object.each do |key, value|
85
+ key = key.to_sym rescue key
86
+ new[key] = symbolize_names(value)
87
+ end
88
+ new
89
+ when Array
90
+ object.map { |value| symbolize_names(value) }
91
+ else
92
+ object
93
+ end
94
+ end
79
95
  end
80
96
 
81
97
  module APIOperations
@@ -534,11 +550,14 @@ module Stripe
534
550
  rbody = response.body
535
551
  rcode = response.code
536
552
  begin
537
- resp = JSON.parse(rbody, :symbolize_names => true)
553
+ # Would use :symbolize_names => true, but apparently there is
554
+ # some library out there that makes symbolize_names not work.
555
+ resp = JSON.parse(rbody)
538
556
  rescue JSON::ParseError
539
557
  raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})")
540
558
  end
541
559
 
560
+ resp = Util.symbolize_names(resp)
542
561
  [resp, api_key]
543
562
  end
544
563
 
@@ -550,7 +569,8 @@ module Stripe
550
569
 
551
570
  def self.handle_api_error(rcode, rbody)
552
571
  begin
553
- error_obj = JSON.parse(rbody, :symbolize_names => true)
572
+ error_obj = JSON.parse(rbody)
573
+ error_obj = Util.symbolize_names(error_obj)
554
574
  error = error_obj[:error] or raise StripeError.new
555
575
  rescue JSON::ParserError, StripeError
556
576
  raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})")
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.5.17'
2
+ VERSION = '1.5.18'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 17
10
- version: 1.5.17
9
+ - 18
10
+ version: 1.5.18
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ross Boucher
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-26 00:00:00 Z
19
+ date: 2011-10-04 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rest-client