stripe 4.20.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -4
  3. data/.rubocop_todo.yml +10 -9
  4. data/.travis.yml +2 -6
  5. data/CHANGELOG.md +52 -1
  6. data/Gemfile +2 -12
  7. data/README.md +10 -10
  8. data/Rakefile +8 -7
  9. data/VERSION +1 -1
  10. data/lib/stripe/api_operations/list.rb +0 -6
  11. data/lib/stripe/api_resource.rb +16 -0
  12. data/lib/stripe/connection_manager.rb +131 -0
  13. data/lib/stripe/error_object.rb +94 -0
  14. data/lib/stripe/errors.rb +15 -2
  15. data/lib/stripe/list_object.rb +2 -1
  16. data/lib/stripe/multipart_encoder.rb +131 -0
  17. data/lib/stripe/object_types.rb +1 -4
  18. data/lib/stripe/resources/account.rb +7 -7
  19. data/lib/stripe/resources/account_link.rb +1 -1
  20. data/lib/stripe/resources/alipay_account.rb +1 -1
  21. data/lib/stripe/resources/apple_pay_domain.rb +1 -1
  22. data/lib/stripe/resources/application_fee.rb +1 -12
  23. data/lib/stripe/resources/application_fee_refund.rb +1 -1
  24. data/lib/stripe/resources/balance.rb +1 -1
  25. data/lib/stripe/resources/balance_transaction.rb +1 -5
  26. data/lib/stripe/resources/bank_account.rb +1 -1
  27. data/lib/stripe/resources/bitcoin_receiver.rb +1 -1
  28. data/lib/stripe/resources/bitcoin_transaction.rb +1 -1
  29. data/lib/stripe/resources/capability.rb +1 -1
  30. data/lib/stripe/resources/card.rb +1 -1
  31. data/lib/stripe/resources/charge.rb +7 -69
  32. data/lib/stripe/resources/checkout/session.rb +1 -1
  33. data/lib/stripe/resources/country_spec.rb +1 -1
  34. data/lib/stripe/resources/coupon.rb +1 -1
  35. data/lib/stripe/resources/credit_note.rb +7 -3
  36. data/lib/stripe/resources/customer.rb +5 -66
  37. data/lib/stripe/resources/customer_balance_transaction.rb +1 -1
  38. data/lib/stripe/resources/discount.rb +1 -1
  39. data/lib/stripe/resources/dispute.rb +7 -9
  40. data/lib/stripe/resources/ephemeral_key.rb +1 -1
  41. data/lib/stripe/resources/event.rb +1 -1
  42. data/lib/stripe/resources/exchange_rate.rb +1 -1
  43. data/lib/stripe/resources/file.rb +3 -13
  44. data/lib/stripe/resources/file_link.rb +1 -1
  45. data/lib/stripe/resources/invoice.rb +36 -11
  46. data/lib/stripe/resources/invoice_item.rb +1 -1
  47. data/lib/stripe/resources/invoice_line_item.rb +1 -1
  48. data/lib/stripe/resources/issuing/authorization.rb +13 -5
  49. data/lib/stripe/resources/issuing/card.rb +7 -3
  50. data/lib/stripe/resources/issuing/card_details.rb +1 -1
  51. data/lib/stripe/resources/issuing/cardholder.rb +1 -1
  52. data/lib/stripe/resources/issuing/dispute.rb +1 -1
  53. data/lib/stripe/resources/issuing/transaction.rb +1 -1
  54. data/lib/stripe/resources/login_link.rb +1 -1
  55. data/lib/stripe/resources/order.rb +13 -13
  56. data/lib/stripe/resources/order_return.rb +1 -1
  57. data/lib/stripe/resources/payment_intent.rb +19 -7
  58. data/lib/stripe/resources/payment_method.rb +13 -5
  59. data/lib/stripe/resources/payout.rb +7 -9
  60. data/lib/stripe/resources/person.rb +1 -1
  61. data/lib/stripe/resources/plan.rb +1 -1
  62. data/lib/stripe/resources/product.rb +1 -1
  63. data/lib/stripe/resources/radar/early_fraud_warning.rb +1 -1
  64. data/lib/stripe/resources/radar/value_list.rb +1 -1
  65. data/lib/stripe/resources/radar/value_list_item.rb +1 -1
  66. data/lib/stripe/resources/recipient.rb +1 -5
  67. data/lib/stripe/resources/recipient_transfer.rb +1 -1
  68. data/lib/stripe/resources/refund.rb +1 -1
  69. data/lib/stripe/resources/reporting/report_run.rb +1 -1
  70. data/lib/stripe/resources/reporting/report_type.rb +1 -1
  71. data/lib/stripe/resources/reversal.rb +1 -1
  72. data/lib/stripe/resources/review.rb +7 -3
  73. data/lib/stripe/resources/setup_intent.rb +32 -0
  74. data/lib/stripe/resources/sigma/scheduled_query_run.rb +1 -1
  75. data/lib/stripe/resources/sku.rb +1 -1
  76. data/lib/stripe/resources/source.rb +7 -9
  77. data/lib/stripe/resources/source_transaction.rb +1 -1
  78. data/lib/stripe/resources/subscription.rb +9 -9
  79. data/lib/stripe/resources/subscription_item.rb +4 -1
  80. data/lib/stripe/resources/subscription_schedule.rb +13 -13
  81. data/lib/stripe/resources/tax_id.rb +1 -1
  82. data/lib/stripe/resources/tax_rate.rb +1 -1
  83. data/lib/stripe/resources/terminal/connection_token.rb +1 -1
  84. data/lib/stripe/resources/terminal/location.rb +1 -1
  85. data/lib/stripe/resources/terminal/reader.rb +1 -1
  86. data/lib/stripe/resources/three_d_secure.rb +1 -1
  87. data/lib/stripe/resources/token.rb +1 -1
  88. data/lib/stripe/resources/topup.rb +7 -3
  89. data/lib/stripe/resources/transfer.rb +7 -8
  90. data/lib/stripe/resources/usage_record.rb +1 -17
  91. data/lib/stripe/resources/usage_record_summary.rb +1 -1
  92. data/lib/stripe/resources/webhook_endpoint.rb +1 -1
  93. data/lib/stripe/resources.rb +1 -2
  94. data/lib/stripe/stripe_client.rb +281 -183
  95. data/lib/stripe/stripe_object.rb +4 -23
  96. data/lib/stripe/stripe_response.rb +53 -21
  97. data/lib/stripe/util.rb +14 -11
  98. data/lib/stripe/version.rb +1 -1
  99. data/lib/stripe/webhook.rb +1 -1
  100. data/lib/stripe.rb +56 -15
  101. data/stripe.gemspec +10 -3
  102. data/test/stripe/account_test.rb +0 -16
  103. data/test/stripe/api_operations_test.rb +2 -2
  104. data/test/stripe/api_resource_test.rb +98 -8
  105. data/test/stripe/balance_transaction_test.rb +20 -0
  106. data/test/stripe/charge_test.rb +0 -16
  107. data/test/stripe/connection_manager_test.rb +138 -0
  108. data/test/stripe/customer_test.rb +1 -44
  109. data/test/stripe/errors_test.rb +29 -8
  110. data/test/stripe/file_test.rb +0 -10
  111. data/test/stripe/invoice_test.rb +17 -1
  112. data/test/stripe/list_object_test.rb +0 -16
  113. data/test/stripe/login_link_test.rb +1 -1
  114. data/test/stripe/multipart_encoder_test.rb +130 -0
  115. data/test/stripe/payment_intent_test.rb +2 -2
  116. data/test/stripe/setup_intent_test.rb +84 -0
  117. data/test/stripe/source_test.rb +0 -18
  118. data/test/stripe/stripe_client_test.rb +214 -29
  119. data/test/stripe/stripe_object_test.rb +7 -35
  120. data/test/stripe/stripe_response_test.rb +70 -24
  121. data/test/stripe/subscription_item_test.rb +12 -0
  122. data/test/stripe/subscription_schedule_test.rb +0 -34
  123. data/test/stripe/subscription_test.rb +2 -2
  124. data/test/stripe/webhook_test.rb +2 -2
  125. data/test/stripe_mock.rb +4 -3
  126. data/test/stripe_test.rb +0 -13
  127. data/test/test_helper.rb +10 -5
  128. metadata +23 -43
  129. data/lib/stripe/resources/issuer_fraud_record.rb +0 -9
  130. data/lib/stripe/resources/subscription_schedule_revision.rb +0 -34
  131. data/test/stripe/file_upload_test.rb +0 -79
  132. data/test/stripe/issuer_fraud_record_test.rb +0 -20
  133. data/test/stripe/subscription_schedule_revision_test.rb +0 -37
  134. data/test/stripe/usage_record_test.rb +0 -28
data/test/test_helper.rb CHANGED
@@ -17,7 +17,7 @@ require ::File.expand_path("test_data", __dir__)
17
17
  require ::File.expand_path("stripe_mock", __dir__)
18
18
 
19
19
  # If changing this number, please also change it in `.travis.yml`.
20
- MOCK_MINIMUM_VERSION = "0.58.0".freeze
20
+ MOCK_MINIMUM_VERSION = "0.63.0"
21
21
  MOCK_PORT = Stripe::StripeMock.start
22
22
 
23
23
  # Disable all real network connections except those that are outgoing to
@@ -28,16 +28,21 @@ WebMock.disable_net_connect!(allow: "localhost:#{MOCK_PORT}")
28
28
  # we can print one error and fail fast so that it's more clear to the user how
29
29
  # they should fix the problem.
30
30
  begin
31
- conn = Faraday::Connection.new("http://localhost:#{MOCK_PORT}")
32
- resp = conn.get("/")
33
- version = resp.headers["Stripe-Mock-Version"]
31
+ resp = Net::HTTP.get_response(URI("http://localhost:#{MOCK_PORT}/"))
32
+ version = resp["Stripe-Mock-Version"]
33
+
34
+ if version.nil?
35
+ abort("Couldn't find `Stripe-Mock-Version` in response from " \
36
+ "`localhost:#{MOCK_PORT}`. Is the service running there stripe-mock?")
37
+ end
38
+
34
39
  if version != "master" &&
35
40
  Gem::Version.new(version) < Gem::Version.new(MOCK_MINIMUM_VERSION)
36
41
  abort("Your version of stripe-mock (#{version}) is too old. The minimum " \
37
42
  "version to run this test suite is #{MOCK_MINIMUM_VERSION}. Please " \
38
43
  "see its repository for upgrade instructions.")
39
44
  end
40
- rescue Faraday::ConnectionFailed
45
+ rescue Errno::ECONNREFUSED
41
46
  abort("Couldn't reach stripe-mock at `localhost:#{MOCK_PORT}`. Is " \
42
47
  "it running? Please see README for setup instructions.")
43
48
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-25 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: faraday
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.13'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.13'
27
- - !ruby/object:Gem::Dependency
28
- name: net-http-persistent
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '3.0'
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: Stripe is the easiest way to accept payments online. See https://stripe.com
42
14
  for details.
43
15
  email: support@stripe.com
@@ -73,8 +45,11 @@ files:
73
45
  - lib/stripe/api_operations/request.rb
74
46
  - lib/stripe/api_operations/save.rb
75
47
  - lib/stripe/api_resource.rb
48
+ - lib/stripe/connection_manager.rb
49
+ - lib/stripe/error_object.rb
76
50
  - lib/stripe/errors.rb
77
51
  - lib/stripe/list_object.rb
52
+ - lib/stripe/multipart_encoder.rb
78
53
  - lib/stripe/oauth.rb
79
54
  - lib/stripe/object_types.rb
80
55
  - lib/stripe/resources.rb
@@ -108,7 +83,6 @@ files:
108
83
  - lib/stripe/resources/invoice.rb
109
84
  - lib/stripe/resources/invoice_item.rb
110
85
  - lib/stripe/resources/invoice_line_item.rb
111
- - lib/stripe/resources/issuer_fraud_record.rb
112
86
  - lib/stripe/resources/issuing/authorization.rb
113
87
  - lib/stripe/resources/issuing/card.rb
114
88
  - lib/stripe/resources/issuing/card_details.rb
@@ -134,6 +108,7 @@ files:
134
108
  - lib/stripe/resources/reporting/report_type.rb
135
109
  - lib/stripe/resources/reversal.rb
136
110
  - lib/stripe/resources/review.rb
111
+ - lib/stripe/resources/setup_intent.rb
137
112
  - lib/stripe/resources/sigma/scheduled_query_run.rb
138
113
  - lib/stripe/resources/sku.rb
139
114
  - lib/stripe/resources/source.rb
@@ -141,7 +116,6 @@ files:
141
116
  - lib/stripe/resources/subscription.rb
142
117
  - lib/stripe/resources/subscription_item.rb
143
118
  - lib/stripe/resources/subscription_schedule.rb
144
- - lib/stripe/resources/subscription_schedule_revision.rb
145
119
  - lib/stripe/resources/tax_id.rb
146
120
  - lib/stripe/resources/tax_rate.rb
147
121
  - lib/stripe/resources/terminal/connection_token.rb
@@ -173,10 +147,12 @@ files:
173
147
  - test/stripe/application_fee_refund_test.rb
174
148
  - test/stripe/application_fee_test.rb
175
149
  - test/stripe/balance_test.rb
150
+ - test/stripe/balance_transaction_test.rb
176
151
  - test/stripe/bank_account_test.rb
177
152
  - test/stripe/capability_test.rb
178
153
  - test/stripe/charge_test.rb
179
154
  - test/stripe/checkout/session_test.rb
155
+ - test/stripe/connection_manager_test.rb
180
156
  - test/stripe/country_spec_test.rb
181
157
  - test/stripe/coupon_test.rb
182
158
  - test/stripe/credit_note_test.rb
@@ -189,11 +165,9 @@ files:
189
165
  - test/stripe/exchange_rate_test.rb
190
166
  - test/stripe/file_link_test.rb
191
167
  - test/stripe/file_test.rb
192
- - test/stripe/file_upload_test.rb
193
168
  - test/stripe/invoice_item_test.rb
194
169
  - test/stripe/invoice_line_item_test.rb
195
170
  - test/stripe/invoice_test.rb
196
- - test/stripe/issuer_fraud_record_test.rb
197
171
  - test/stripe/issuing/authorization_test.rb
198
172
  - test/stripe/issuing/card_test.rb
199
173
  - test/stripe/issuing/cardholder_test.rb
@@ -201,6 +175,7 @@ files:
201
175
  - test/stripe/issuing/transaction_test.rb
202
176
  - test/stripe/list_object_test.rb
203
177
  - test/stripe/login_link_test.rb
178
+ - test/stripe/multipart_encoder_test.rb
204
179
  - test/stripe/oauth_test.rb
205
180
  - test/stripe/order_return_test.rb
206
181
  - test/stripe/order_test.rb
@@ -219,6 +194,7 @@ files:
219
194
  - test/stripe/reporting/report_type_test.rb
220
195
  - test/stripe/reversal_test.rb
221
196
  - test/stripe/review_test.rb
197
+ - test/stripe/setup_intent_test.rb
222
198
  - test/stripe/sigma/scheduled_query_run_test.rb
223
199
  - test/stripe/sku_test.rb
224
200
  - test/stripe/source_test.rb
@@ -227,7 +203,6 @@ files:
227
203
  - test/stripe/stripe_object_test.rb
228
204
  - test/stripe/stripe_response_test.rb
229
205
  - test/stripe/subscription_item_test.rb
230
- - test/stripe/subscription_schedule_revision_test.rb
231
206
  - test/stripe/subscription_schedule_test.rb
232
207
  - test/stripe/subscription_test.rb
233
208
  - test/stripe/tax_id_test.rb
@@ -239,7 +214,6 @@ files:
239
214
  - test/stripe/topup_test.rb
240
215
  - test/stripe/transfer_test.rb
241
216
  - test/stripe/usage_record_summary_test.rb
242
- - test/stripe/usage_record_test.rb
243
217
  - test/stripe/util_test.rb
244
218
  - test/stripe/webhook_endpoint_test.rb
245
219
  - test/stripe/webhook_test.rb
@@ -250,7 +224,13 @@ files:
250
224
  homepage: https://stripe.com/docs/api/ruby
251
225
  licenses:
252
226
  - MIT
253
- metadata: {}
227
+ metadata:
228
+ bug_tracker_uri: https://github.com/stripe/stripe-ruby/issues
229
+ changelog_uri: https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md
230
+ documentation_uri: https://stripe.com/docs/api/ruby
231
+ github_repo: ssh://github.com/stripe/stripe-ruby
232
+ homepage_uri: https://stripe.com/docs/api/ruby
233
+ source_code_uri: https://github.com/stripe/stripe-ruby
254
234
  post_install_message:
255
235
  rdoc_options: []
256
236
  require_paths:
@@ -259,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
259
239
  requirements:
260
240
  - - ">="
261
241
  - !ruby/object:Gem::Version
262
- version: 2.1.0
242
+ version: 2.3.0
263
243
  required_rubygems_version: !ruby/object:Gem::Requirement
264
244
  requirements:
265
245
  - - ">="
@@ -282,10 +262,12 @@ test_files:
282
262
  - test/stripe/application_fee_refund_test.rb
283
263
  - test/stripe/application_fee_test.rb
284
264
  - test/stripe/balance_test.rb
265
+ - test/stripe/balance_transaction_test.rb
285
266
  - test/stripe/bank_account_test.rb
286
267
  - test/stripe/capability_test.rb
287
268
  - test/stripe/charge_test.rb
288
269
  - test/stripe/checkout/session_test.rb
270
+ - test/stripe/connection_manager_test.rb
289
271
  - test/stripe/country_spec_test.rb
290
272
  - test/stripe/coupon_test.rb
291
273
  - test/stripe/credit_note_test.rb
@@ -298,11 +280,9 @@ test_files:
298
280
  - test/stripe/exchange_rate_test.rb
299
281
  - test/stripe/file_link_test.rb
300
282
  - test/stripe/file_test.rb
301
- - test/stripe/file_upload_test.rb
302
283
  - test/stripe/invoice_item_test.rb
303
284
  - test/stripe/invoice_line_item_test.rb
304
285
  - test/stripe/invoice_test.rb
305
- - test/stripe/issuer_fraud_record_test.rb
306
286
  - test/stripe/issuing/authorization_test.rb
307
287
  - test/stripe/issuing/card_test.rb
308
288
  - test/stripe/issuing/cardholder_test.rb
@@ -310,6 +290,7 @@ test_files:
310
290
  - test/stripe/issuing/transaction_test.rb
311
291
  - test/stripe/list_object_test.rb
312
292
  - test/stripe/login_link_test.rb
293
+ - test/stripe/multipart_encoder_test.rb
313
294
  - test/stripe/oauth_test.rb
314
295
  - test/stripe/order_return_test.rb
315
296
  - test/stripe/order_test.rb
@@ -328,6 +309,7 @@ test_files:
328
309
  - test/stripe/reporting/report_type_test.rb
329
310
  - test/stripe/reversal_test.rb
330
311
  - test/stripe/review_test.rb
312
+ - test/stripe/setup_intent_test.rb
331
313
  - test/stripe/sigma/scheduled_query_run_test.rb
332
314
  - test/stripe/sku_test.rb
333
315
  - test/stripe/source_test.rb
@@ -336,7 +318,6 @@ test_files:
336
318
  - test/stripe/stripe_object_test.rb
337
319
  - test/stripe/stripe_response_test.rb
338
320
  - test/stripe/subscription_item_test.rb
339
- - test/stripe/subscription_schedule_revision_test.rb
340
321
  - test/stripe/subscription_schedule_test.rb
341
322
  - test/stripe/subscription_test.rb
342
323
  - test/stripe/tax_id_test.rb
@@ -348,7 +329,6 @@ test_files:
348
329
  - test/stripe/topup_test.rb
349
330
  - test/stripe/transfer_test.rb
350
331
  - test/stripe/usage_record_summary_test.rb
351
- - test/stripe/usage_record_test.rb
352
332
  - test/stripe/util_test.rb
353
333
  - test/stripe/webhook_endpoint_test.rb
354
334
  - test/stripe/webhook_test.rb
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Stripe
4
- class IssuerFraudRecord < APIResource
5
- extend Stripe::APIOperations::List
6
-
7
- OBJECT_NAME = "issuer_fraud_record".freeze
8
- end
9
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Stripe
4
- class SubscriptionScheduleRevision < APIResource
5
- extend Stripe::APIOperations::List
6
-
7
- OBJECT_NAME = "subscription_schedule_revision".freeze
8
-
9
- def resource_url
10
- if !respond_to?(:schedule) || schedule.nil?
11
- raise NotImplementedError,
12
- "Subscription schedule revisions cannot be accessed without a " \
13
- "subscription schedule ID."
14
- end
15
- "#{SubscriptionSchedule.resource_url}/#{CGI.escape(schedule)}" \
16
- "/revisions/#{CGI.escape(id)}"
17
- end
18
-
19
- def self.retrieve(_id, _opts = {})
20
- raise NotImplementedError,
21
- "Subscription schedule revisions cannot be retrieved without a " \
22
- "subscription schedule ID. Retrieve a subscribtion schedule " \
23
- "revision using `SubscriptionSchedule.retrieve_revision(" \
24
- "'schedule_id', 'revision_id')`"
25
- end
26
-
27
- def self.list(_id, _opts = {})
28
- raise NotImplementedError,
29
- "Subscription schedule revisions cannot be listed without a " \
30
- "subscription schedule ID. List subscribtion schedule revisions " \
31
- "using `SubscriptionSchedule.list_revisions('schedule_id')`"
32
- end
33
- end
34
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- # This is a strict copy of `FileTest`, except that it uses
7
- # `Stripe::FileUpload` instead of `Stripe::File`.
8
- class FileUploadTest < Test::Unit::TestCase
9
- should "be listable" do
10
- files = Stripe::FileUpload.list
11
- assert_requested :get, "#{Stripe.api_base}/v1/files"
12
- assert files.data.is_a?(Array)
13
- assert files.data[0].is_a?(Stripe::FileUpload)
14
- end
15
-
16
- should "be retrievable" do
17
- file = Stripe::FileUpload.retrieve("file_123")
18
- assert_requested :get, "#{Stripe.api_base}/v1/files/file_123"
19
- assert file.is_a?(Stripe::FileUpload)
20
- end
21
-
22
- context ".create" do
23
- setup do
24
- # We don't point to the same host for the API and uploads in
25
- # production, but `stripe-mock` supports both APIs.
26
- Stripe.uploads_base = Stripe.api_base
27
-
28
- # Set `api_base` to `nil` to ensure that these requests are _not_ sent
29
- # to the default API hostname. `api_base` is reset when each test
30
- # starts so this won't affect the global state.
31
- Stripe.api_base = nil
32
- end
33
-
34
- should "be creatable with a File" do
35
- file = Stripe::FileUpload.create(
36
- purpose: "dispute_evidence",
37
- file: ::File.new(__FILE__),
38
- file_link_data: { create: true }
39
- )
40
- assert_requested :post, "#{Stripe.uploads_base}/v1/files"
41
- assert file.is_a?(Stripe::FileUpload)
42
- end
43
-
44
- should "be creatable with a Tempfile" do
45
- tempfile = Tempfile.new("foo")
46
- tempfile.write("Hello world")
47
- tempfile.rewind
48
-
49
- file = Stripe::FileUpload.create(
50
- purpose: "dispute_evidence",
51
- file: tempfile,
52
- file_link_data: { create: true }
53
- )
54
- assert_requested :post, "#{Stripe.uploads_base}/v1/files"
55
- assert file.is_a?(Stripe::FileUpload)
56
- end
57
-
58
- should "be creatable with Faraday::UploadIO" do
59
- file = Stripe::FileUpload.create(
60
- purpose: "dispute_evidence",
61
- file: Faraday::UploadIO.new(::File.new(__FILE__), nil),
62
- file_link_data: { create: true }
63
- )
64
- assert_requested :post, "#{Stripe.uploads_base}/v1/files"
65
- assert file.is_a?(Stripe::FileUpload)
66
- end
67
- end
68
-
69
- should "be deserializable when `object=file`" do
70
- file = Stripe::Util.convert_to_stripe_object({ object: "file" }, {})
71
- assert file.is_a?(Stripe::FileUpload)
72
- end
73
-
74
- should "be deserializable when `object=file_upload`" do
75
- file = Stripe::Util.convert_to_stripe_object({ object: "file_upload" }, {})
76
- assert file.is_a?(Stripe::FileUpload)
77
- end
78
- end
79
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class IssuerFraudRecordTest < Test::Unit::TestCase
7
- should "be listable" do
8
- issfrs = Stripe::IssuerFraudRecord.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/issuer_fraud_records"
10
- assert issfrs.data.is_a?(Array)
11
- assert issfrs.data[0].is_a?(Stripe::IssuerFraudRecord)
12
- end
13
-
14
- should "be retrievable" do
15
- issfr = Stripe::IssuerFraudRecord.retrieve("issfr_123")
16
- assert_requested :get, "#{Stripe.api_base}/v1/issuer_fraud_records/issfr_123"
17
- assert issfr.is_a?(Stripe::IssuerFraudRecord)
18
- end
19
- end
20
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class SubscriptionScheduleRevisionTest < Test::Unit::TestCase
7
- context "#resource_url" do
8
- should "return a resource URL" do
9
- revision = Stripe::SubscriptionScheduleRevision.construct_from(
10
- id: "sub_sched_rev_123",
11
- schedule: "sub_sched_123"
12
- )
13
- assert_equal "/v1/subscription_schedules/sub_sched_123/revisions/sub_sched_rev_123",
14
- revision.resource_url
15
- end
16
-
17
- should "raise without a subscription schedule" do
18
- revision = Stripe::SubscriptionScheduleRevision.construct_from(id: "sub_sched_rev_123")
19
- assert_raises NotImplementedError do
20
- revision.resource_url
21
- end
22
- end
23
- end
24
-
25
- should "raise on #retrieve" do
26
- assert_raises NotImplementedError do
27
- Stripe::SubscriptionScheduleRevision.retrieve("sub_sched_rev_123")
28
- end
29
- end
30
-
31
- should "raise on #list" do
32
- assert_raises NotImplementedError do
33
- Stripe::SubscriptionScheduleRevision.list("sub_sched_rev_123", {})
34
- end
35
- end
36
- end
37
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class UsageRecordTest < Test::Unit::TestCase
7
- should "be creatable" do
8
- usage_record = Stripe::UsageRecord.create(
9
- quantity: 5000,
10
- subscription_item: "si_abc",
11
- timestamp: Time.now.to_i,
12
- action: "increment"
13
- )
14
- assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_abc/usage_records"
15
- assert usage_record.is_a?(Stripe::UsageRecord)
16
- end
17
-
18
- should "raise when subscription_item is missing" do
19
- assert_raise ArgumentError do
20
- Stripe::UsageRecord.create(
21
- quantity: 5000,
22
- timestamp: Time.now.to_i,
23
- action: "increment"
24
- )
25
- end
26
- end
27
- end
28
- end