stripe 1.31.0 → 1.58.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +5 -0
  3. data/.travis.yml +2 -12
  4. data/Gemfile +29 -4
  5. data/History.txt +168 -0
  6. data/README.md +134 -0
  7. data/Rakefile +10 -0
  8. data/VERSION +1 -1
  9. data/bin/stripe-console +12 -5
  10. data/lib/data/ca-certificates.crt +3868 -5114
  11. data/lib/stripe/account.rb +41 -21
  12. data/lib/stripe/alipay_account.rb +20 -0
  13. data/lib/stripe/api_operations/create.rb +1 -1
  14. data/lib/stripe/api_operations/delete.rb +1 -1
  15. data/lib/stripe/api_operations/list.rb +1 -2
  16. data/lib/stripe/api_operations/save.rb +87 -0
  17. data/lib/stripe/api_resource.rb +37 -4
  18. data/lib/stripe/apple_pay_domain.rb +12 -0
  19. data/lib/stripe/application_fee.rb +8 -8
  20. data/lib/stripe/application_fee_refund.rb +7 -3
  21. data/lib/stripe/balance_transaction.rb +1 -1
  22. data/lib/stripe/bank_account.rb +9 -5
  23. data/lib/stripe/bitcoin_receiver.rb +6 -6
  24. data/lib/stripe/bitcoin_transaction.rb +1 -1
  25. data/lib/stripe/card.rb +9 -5
  26. data/lib/stripe/charge.rb +30 -12
  27. data/lib/stripe/country_spec.rb +9 -0
  28. data/lib/stripe/coupon.rb +1 -1
  29. data/lib/stripe/customer.rb +6 -4
  30. data/lib/stripe/dispute.rb +2 -2
  31. data/lib/stripe/errors.rb +82 -0
  32. data/lib/stripe/file_upload.rb +1 -1
  33. data/lib/stripe/invoice.rb +3 -3
  34. data/lib/stripe/invoice_item.rb +1 -1
  35. data/lib/stripe/list_object.rb +7 -6
  36. data/lib/stripe/order.rb +10 -2
  37. data/lib/stripe/order_return.rb +9 -0
  38. data/lib/stripe/plan.rb +1 -1
  39. data/lib/stripe/product.rb +2 -10
  40. data/lib/stripe/recipient.rb +1 -1
  41. data/lib/stripe/refund.rb +1 -1
  42. data/lib/stripe/reversal.rb +7 -3
  43. data/lib/stripe/singleton_api_resource.rb +3 -3
  44. data/lib/stripe/sku.rb +2 -2
  45. data/lib/stripe/source.rb +11 -0
  46. data/lib/stripe/stripe_object.rb +167 -91
  47. data/lib/stripe/subscription.rb +15 -9
  48. data/lib/stripe/subscription_item.rb +12 -0
  49. data/lib/stripe/three_d_secure.rb +9 -0
  50. data/lib/stripe/transfer.rb +3 -4
  51. data/lib/stripe/util.rb +100 -28
  52. data/lib/stripe/version.rb +1 -1
  53. data/lib/stripe.rb +283 -140
  54. data/stripe.gemspec +5 -18
  55. data/test/stripe/account_test.rb +55 -9
  56. data/test/stripe/alipay_account_test.rb +11 -0
  57. data/test/stripe/api_operations_test.rb +31 -0
  58. data/test/stripe/api_resource_test.rb +204 -10
  59. data/test/stripe/apple_pay_domain_test.rb +34 -0
  60. data/test/stripe/application_fee_test.rb +8 -5
  61. data/test/stripe/bitcoin_receiver_test.rb +2 -2
  62. data/test/stripe/charge_refund_test.rb +12 -0
  63. data/test/stripe/charge_test.rb +32 -4
  64. data/test/stripe/country_spec_test.rb +43 -0
  65. data/test/stripe/coupon_test.rb +9 -1
  66. data/test/stripe/customer_card_test.rb +2 -2
  67. data/test/stripe/customer_test.rb +24 -1
  68. data/test/stripe/dispute_test.rb +8 -0
  69. data/test/stripe/errors_test.rb +18 -0
  70. data/test/stripe/invoice_item_test.rb +19 -0
  71. data/test/stripe/invoice_test.rb +27 -1
  72. data/test/stripe/list_object_test.rb +36 -15
  73. data/test/stripe/order_return_test.rb +25 -0
  74. data/test/stripe/order_test.rb +21 -1
  75. data/test/stripe/plan_test.rb +31 -0
  76. data/test/stripe/product_test.rb +17 -7
  77. data/test/stripe/recipient_card_test.rb +2 -2
  78. data/test/stripe/recipient_test.rb +21 -0
  79. data/test/stripe/refund_test.rb +10 -1
  80. data/test/stripe/sku_test.rb +15 -6
  81. data/test/stripe/source_test.rb +83 -0
  82. data/test/stripe/stripe_object_test.rb +180 -11
  83. data/test/stripe/subscription_item_test.rb +76 -0
  84. data/test/stripe/subscription_test.rb +161 -37
  85. data/test/stripe/three_d_secure_test.rb +22 -0
  86. data/test/stripe/transfer_test.rb +8 -0
  87. data/test/stripe/util_test.rb +48 -16
  88. data/test/stripe_test.rb +58 -0
  89. data/test/test_data.rb +337 -27
  90. data/test/test_helper.rb +7 -3
  91. metadata +47 -133
  92. data/README.rdoc +0 -68
  93. data/gemfiles/default-with-activesupport.gemfile +0 -10
  94. data/gemfiles/json.gemfile +0 -12
  95. data/gemfiles/yajl.gemfile +0 -12
  96. data/lib/stripe/api_operations/update.rb +0 -58
  97. data/lib/stripe/errors/api_connection_error.rb +0 -4
  98. data/lib/stripe/errors/api_error.rb +0 -4
  99. data/lib/stripe/errors/authentication_error.rb +0 -4
  100. data/lib/stripe/errors/card_error.rb +0 -12
  101. data/lib/stripe/errors/invalid_request_error.rb +0 -11
  102. data/lib/stripe/errors/rate_limit_error.rb +0 -4
  103. data/lib/stripe/errors/stripe_error.rb +0 -26
metadata CHANGED
@@ -1,174 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.31.0
4
+ version: 1.58.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ross Boucher
8
- - Greg Brockman
7
+ - Stripe
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.4'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
17
+ - - ">="
26
18
  - !ruby/object:Gem::Version
27
19
  version: '1.4'
28
- - !ruby/object:Gem::Dependency
29
- name: json
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
20
+ - - "<"
33
21
  - !ruby/object:Gem::Version
34
- version: 1.8.1
22
+ version: '4.0'
35
23
  type: :runtime
36
24
  prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: 1.8.1
42
- - !ruby/object:Gem::Dependency
43
- name: mocha
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: 0.13.2
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: 0.13.2
56
- - !ruby/object:Gem::Dependency
57
- name: shoulda
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: 3.4.0
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: 3.4.0
70
- - !ruby/object:Gem::Dependency
71
- name: test-unit
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: rake
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: byebug
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: pry
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
25
  version_requirements: !ruby/object:Gem::Requirement
122
26
  requirements:
123
27
  - - ">="
124
28
  - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: pry-byebug
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '0'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
29
+ version: '1.4'
30
+ - - "<"
138
31
  - !ruby/object:Gem::Version
139
- version: '0'
32
+ version: '4.0'
140
33
  description: Stripe is the easiest way to accept payments online. See https://stripe.com
141
34
  for details.
142
- email:
143
- - boucher@stripe.com
144
- - gdb@stripe.com
35
+ email: support@stripe.com
145
36
  executables:
146
37
  - stripe-console
147
38
  extensions: []
148
39
  extra_rdoc_files: []
149
40
  files:
41
+ - ".github/ISSUE_TEMPLATE.md"
150
42
  - ".gitignore"
151
43
  - ".travis.yml"
152
44
  - CONTRIBUTORS
153
45
  - Gemfile
154
46
  - History.txt
155
47
  - LICENSE
156
- - README.rdoc
48
+ - README.md
157
49
  - Rakefile
158
50
  - VERSION
159
51
  - bin/stripe-console
160
- - gemfiles/default-with-activesupport.gemfile
161
- - gemfiles/json.gemfile
162
- - gemfiles/yajl.gemfile
163
52
  - lib/data/ca-certificates.crt
164
53
  - lib/stripe.rb
165
54
  - lib/stripe/account.rb
55
+ - lib/stripe/alipay_account.rb
166
56
  - lib/stripe/api_operations/create.rb
167
57
  - lib/stripe/api_operations/delete.rb
168
58
  - lib/stripe/api_operations/list.rb
169
59
  - lib/stripe/api_operations/request.rb
170
- - lib/stripe/api_operations/update.rb
60
+ - lib/stripe/api_operations/save.rb
171
61
  - lib/stripe/api_resource.rb
62
+ - lib/stripe/apple_pay_domain.rb
172
63
  - lib/stripe/application_fee.rb
173
64
  - lib/stripe/application_fee_refund.rb
174
65
  - lib/stripe/balance.rb
@@ -178,22 +69,18 @@ files:
178
69
  - lib/stripe/bitcoin_transaction.rb
179
70
  - lib/stripe/card.rb
180
71
  - lib/stripe/charge.rb
72
+ - lib/stripe/country_spec.rb
181
73
  - lib/stripe/coupon.rb
182
74
  - lib/stripe/customer.rb
183
75
  - lib/stripe/dispute.rb
184
- - lib/stripe/errors/api_connection_error.rb
185
- - lib/stripe/errors/api_error.rb
186
- - lib/stripe/errors/authentication_error.rb
187
- - lib/stripe/errors/card_error.rb
188
- - lib/stripe/errors/invalid_request_error.rb
189
- - lib/stripe/errors/rate_limit_error.rb
190
- - lib/stripe/errors/stripe_error.rb
76
+ - lib/stripe/errors.rb
191
77
  - lib/stripe/event.rb
192
78
  - lib/stripe/file_upload.rb
193
79
  - lib/stripe/invoice.rb
194
80
  - lib/stripe/invoice_item.rb
195
81
  - lib/stripe/list_object.rb
196
82
  - lib/stripe/order.rb
83
+ - lib/stripe/order_return.rb
197
84
  - lib/stripe/plan.rb
198
85
  - lib/stripe/product.rb
199
86
  - lib/stripe/recipient.rb
@@ -201,15 +88,21 @@ files:
201
88
  - lib/stripe/reversal.rb
202
89
  - lib/stripe/singleton_api_resource.rb
203
90
  - lib/stripe/sku.rb
91
+ - lib/stripe/source.rb
204
92
  - lib/stripe/stripe_object.rb
205
93
  - lib/stripe/subscription.rb
94
+ - lib/stripe/subscription_item.rb
95
+ - lib/stripe/three_d_secure.rb
206
96
  - lib/stripe/token.rb
207
97
  - lib/stripe/transfer.rb
208
98
  - lib/stripe/util.rb
209
99
  - lib/stripe/version.rb
210
100
  - stripe.gemspec
211
101
  - test/stripe/account_test.rb
102
+ - test/stripe/alipay_account_test.rb
103
+ - test/stripe/api_operations_test.rb
212
104
  - test/stripe/api_resource_test.rb
105
+ - test/stripe/apple_pay_domain_test.rb
213
106
  - test/stripe/application_fee_refund_test.rb
214
107
  - test/stripe/application_fee_test.rb
215
108
  - test/stripe/balance_test.rb
@@ -218,28 +111,37 @@ files:
218
111
  - test/stripe/bitcoin_transaction_test.rb
219
112
  - test/stripe/charge_refund_test.rb
220
113
  - test/stripe/charge_test.rb
114
+ - test/stripe/country_spec_test.rb
221
115
  - test/stripe/coupon_test.rb
222
116
  - test/stripe/customer_card_test.rb
223
117
  - test/stripe/customer_test.rb
224
118
  - test/stripe/dispute_test.rb
119
+ - test/stripe/errors_test.rb
225
120
  - test/stripe/file_upload_test.rb
121
+ - test/stripe/invoice_item_test.rb
226
122
  - test/stripe/invoice_test.rb
227
123
  - test/stripe/list_object_test.rb
228
124
  - test/stripe/metadata_test.rb
125
+ - test/stripe/order_return_test.rb
229
126
  - test/stripe/order_test.rb
127
+ - test/stripe/plan_test.rb
230
128
  - test/stripe/product_test.rb
231
129
  - test/stripe/recipient_card_test.rb
130
+ - test/stripe/recipient_test.rb
232
131
  - test/stripe/refund_test.rb
233
132
  - test/stripe/reversal_test.rb
234
133
  - test/stripe/sku_test.rb
134
+ - test/stripe/source_test.rb
235
135
  - test/stripe/stripe_object_test.rb
136
+ - test/stripe/subscription_item_test.rb
236
137
  - test/stripe/subscription_test.rb
138
+ - test/stripe/three_d_secure_test.rb
237
139
  - test/stripe/transfer_test.rb
238
140
  - test/stripe/util_test.rb
239
141
  - test/stripe_test.rb
240
142
  - test/test_data.rb
241
143
  - test/test_helper.rb
242
- homepage: https://stripe.com/api
144
+ homepage: https://stripe.com/docs/api/ruby
243
145
  licenses:
244
146
  - MIT
245
147
  metadata: {}
@@ -251,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
251
153
  requirements:
252
154
  - - ">="
253
155
  - !ruby/object:Gem::Version
254
- version: '0'
156
+ version: 1.9.3
255
157
  required_rubygems_version: !ruby/object:Gem::Requirement
256
158
  requirements:
257
159
  - - ">="
@@ -265,7 +167,10 @@ specification_version: 4
265
167
  summary: Ruby bindings for the Stripe API
266
168
  test_files:
267
169
  - test/stripe/account_test.rb
170
+ - test/stripe/alipay_account_test.rb
171
+ - test/stripe/api_operations_test.rb
268
172
  - test/stripe/api_resource_test.rb
173
+ - test/stripe/apple_pay_domain_test.rb
269
174
  - test/stripe/application_fee_refund_test.rb
270
175
  - test/stripe/application_fee_test.rb
271
176
  - test/stripe/balance_test.rb
@@ -274,22 +179,31 @@ test_files:
274
179
  - test/stripe/bitcoin_transaction_test.rb
275
180
  - test/stripe/charge_refund_test.rb
276
181
  - test/stripe/charge_test.rb
182
+ - test/stripe/country_spec_test.rb
277
183
  - test/stripe/coupon_test.rb
278
184
  - test/stripe/customer_card_test.rb
279
185
  - test/stripe/customer_test.rb
280
186
  - test/stripe/dispute_test.rb
187
+ - test/stripe/errors_test.rb
281
188
  - test/stripe/file_upload_test.rb
189
+ - test/stripe/invoice_item_test.rb
282
190
  - test/stripe/invoice_test.rb
283
191
  - test/stripe/list_object_test.rb
284
192
  - test/stripe/metadata_test.rb
193
+ - test/stripe/order_return_test.rb
285
194
  - test/stripe/order_test.rb
195
+ - test/stripe/plan_test.rb
286
196
  - test/stripe/product_test.rb
287
197
  - test/stripe/recipient_card_test.rb
198
+ - test/stripe/recipient_test.rb
288
199
  - test/stripe/refund_test.rb
289
200
  - test/stripe/reversal_test.rb
290
201
  - test/stripe/sku_test.rb
202
+ - test/stripe/source_test.rb
291
203
  - test/stripe/stripe_object_test.rb
204
+ - test/stripe/subscription_item_test.rb
292
205
  - test/stripe/subscription_test.rb
206
+ - test/stripe/three_d_secure_test.rb
293
207
  - test/stripe/transfer_test.rb
294
208
  - test/stripe/util_test.rb
295
209
  - test/stripe_test.rb
data/README.rdoc DELETED
@@ -1,68 +0,0 @@
1
- = Stripe Ruby bindings {<img src="https://travis-ci.org/stripe/stripe-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/stripe/stripe-ruby]
2
-
3
- The Stripe Ruby bindings provide a small SDK for convenient access to the
4
- Stripe API from applications written in the Ruby language. It provides a
5
- pre-defined set of classes for API resources that initialize themselves
6
- dynamically from API responses which allows the bindings to tolerate a number
7
- of different versions of the API.
8
-
9
- The bindings also provide other features. For example:
10
-
11
- * Easy configuration path for fast setup and use.
12
- * Helpers for pagination.
13
- * Tracking of "fresh" values in API resources so that partial updates can be
14
- executed.
15
- * Built-in mechanisms for the serialization of parameters according to the
16
- expectations of Stripe's API.
17
-
18
- == Documentation
19
-
20
- {Ruby API Docs}[https://stripe.com/docs/api/ruby#intro]
21
-
22
- == Installation
23
-
24
- You don't need this source code unless you want to modify the gem. If
25
- you just want to use the Stripe Ruby bindings, you should run:
26
-
27
- gem install stripe
28
-
29
- If you want to build the gem from source:
30
-
31
- gem build stripe.gemspec
32
-
33
- == Requirements
34
-
35
- * Ruby 1.8.7 or above. (Ruby 1.8.6 may work if you load
36
- ActiveSupport.) For Ruby versions before 1.9.2, you'll need to add this to your Gemfile:
37
-
38
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.2')
39
- gem 'rest-client', '~> 1.6.8'
40
- end
41
-
42
-
43
- * rest-client, json
44
-
45
- == Bundler
46
-
47
- If you are installing via bundler, you should be sure to use the https
48
- rubygems source in your Gemfile, as any gems fetched over http could potentially be
49
- compromised in transit and alter the code of gems fetched securely over https:
50
-
51
- source 'https://rubygems.org'
52
-
53
- gem 'rails'
54
- gem 'stripe'
55
-
56
- == Development
57
-
58
- Run all tests:
59
-
60
- bundle exec rake
61
-
62
- Run a single test suite:
63
-
64
- bundle exec ruby -Ilib/ test/stripe/util_test.rb
65
-
66
- Run a single test:
67
-
68
- bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.symbols/
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => File.join(File.dirname(__FILE__), "..")
3
-
4
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
5
- gem 'i18n', '< 0.7'
6
- gem 'rest-client', '~> 1.6.8'
7
- gem 'activesupport', '~> 3.2'
8
- else
9
- gem 'activesupport'
10
- end
@@ -1,12 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => File.join(File.dirname(__FILE__), "..")
3
-
4
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
5
- gem 'i18n', '< 0.7'
6
- gem 'rest-client', '~> 1.6.8'
7
- gem 'activesupport', '~> 3.2'
8
- else
9
- gem 'activesupport'
10
- end
11
-
12
- gem 'json'
@@ -1,12 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => File.join(File.dirname(__FILE__), "..")
3
-
4
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
5
- gem 'i18n', '< 0.7'
6
- gem 'rest-client', '~> 1.6.8'
7
- gem 'activesupport', '~> 3.2'
8
- else
9
- gem 'activesupport'
10
- end
11
-
12
- gem 'yajl-ruby'
@@ -1,58 +0,0 @@
1
- module Stripe
2
- module APIOperations
3
- module Update
4
- # Creates or updates an API resource.
5
- #
6
- # If the resource doesn't yet have an assigned ID and the resource is one
7
- # that can be created, then the method attempts to create the resource.
8
- # The resource is updated otherwise.
9
- #
10
- # ==== Attributes
11
- #
12
- # * +params+ - Overrides any parameters in the resource's serialized data
13
- # and includes them in the create or update. If +:req_url:+ is included
14
- # in the list, it overrides the update URL used for the create or
15
- # update.
16
- def save(params={})
17
- # Let the caller override the URL but avoid serializing it.
18
- req_url = params.delete(:req_url) || save_url
19
-
20
- # We started unintentionally (sort of) allowing attributes send to
21
- # +save+ to override values used during the update. So as not to break
22
- # the API, this makes that official here.
23
- update_attributes(params)
24
-
25
- # Now remove any parameters that look like object attributes.
26
- params = params.reject { |k, _| respond_to?(k) }
27
-
28
- values = self.class.serialize_params(self).merge(params)
29
-
30
- if values.length > 0
31
- # note that id gets removed here our call to #url above has already
32
- # generated a uri for this object with an identifier baked in
33
- values.delete(:id)
34
-
35
- response, opts = request(:post, req_url, values)
36
- initialize_from(response, opts)
37
- end
38
- self
39
- end
40
-
41
- private
42
-
43
- def save_url
44
- # This switch essentially allows us "upsert"-like functionality. If the
45
- # API resource doesn't have an ID set (suggesting that it's new) and
46
- # its class responds to .create (which comes from
47
- # Stripe::APIOperations::Create), then use the URL to create a new
48
- # resource. Otherwise, generate a URL based on the object's identifier
49
- # for a normal update.
50
- if self[:id] == nil && self.class.respond_to?(:create)
51
- self.class.url
52
- else
53
- url
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,4 +0,0 @@
1
- module Stripe
2
- class APIConnectionError < StripeError
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Stripe
2
- class APIError < StripeError
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Stripe
2
- class AuthenticationError < StripeError
3
- end
4
- end
@@ -1,12 +0,0 @@
1
- module Stripe
2
- class CardError < StripeError
3
- attr_reader :param, :code
4
-
5
- def initialize(message, param, code, http_status=nil, http_body=nil, json_body=nil,
6
- http_headers=nil)
7
- super(message, http_status, http_body, json_body, http_headers)
8
- @param = param
9
- @code = code
10
- end
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- module Stripe
2
- class InvalidRequestError < StripeError
3
- attr_accessor :param
4
-
5
- def initialize(message, param, http_status=nil, http_body=nil, json_body=nil,
6
- http_headers=nil)
7
- super(message, http_status, http_body, json_body, http_headers)
8
- @param = param
9
- end
10
- end
11
- end
@@ -1,4 +0,0 @@
1
- module Stripe
2
- class RateLimitError < StripeError
3
- end
4
- end
@@ -1,26 +0,0 @@
1
- module Stripe
2
- class StripeError < StandardError
3
- attr_reader :message
4
- attr_reader :http_status
5
- attr_reader :http_body
6
- attr_reader :http_headers
7
- attr_reader :request_id
8
- attr_reader :json_body
9
-
10
- def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil,
11
- http_headers=nil)
12
- @message = message
13
- @http_status = http_status
14
- @http_body = http_body
15
- @http_headers = http_headers || {}
16
- @json_body = json_body
17
- @request_id = @http_headers[:request_id]
18
- end
19
-
20
- def to_s
21
- status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
22
- id_string = @request_id.nil? ? "" : "(Request #{@request_id}) "
23
- "#{status_string}#{id_string}#{@message}"
24
- end
25
- end
26
- end