stripe 3.2.0 → 5.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +5 -5
  2. data/.editorconfig +10 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +80 -0
  5. data/.rubocop_todo.yml +33 -0
  6. data/.travis.yml +9 -7
  7. data/.vscode/extensions.json +7 -0
  8. data/.vscode/settings.json +8 -0
  9. data/CHANGELOG.md +876 -0
  10. data/CODE_OF_CONDUCT.md +77 -0
  11. data/Gemfile +21 -21
  12. data/History.txt +1 -678
  13. data/README.md +195 -53
  14. data/Rakefile +18 -12
  15. data/VERSION +1 -1
  16. data/bin/stripe-console +5 -3
  17. data/lib/stripe/api_operations/create.rb +3 -1
  18. data/lib/stripe/api_operations/delete.rb +26 -2
  19. data/lib/stripe/api_operations/list.rb +3 -12
  20. data/lib/stripe/api_operations/nested_resource.rb +72 -0
  21. data/lib/stripe/api_operations/request.rb +33 -15
  22. data/lib/stripe/api_operations/save.rb +18 -9
  23. data/lib/stripe/api_resource.rb +60 -10
  24. data/lib/stripe/connection_manager.rb +159 -0
  25. data/lib/stripe/error_object.rb +94 -0
  26. data/lib/stripe/errors.rb +39 -19
  27. data/lib/stripe/instrumentation.rb +82 -0
  28. data/lib/stripe/list_object.rb +54 -22
  29. data/lib/stripe/multipart_encoder.rb +131 -0
  30. data/lib/stripe/oauth.rb +22 -14
  31. data/lib/stripe/object_types.rb +96 -0
  32. data/lib/stripe/{account.rb → resources/account.rb} +72 -34
  33. data/lib/stripe/resources/account_link.rb +9 -0
  34. data/lib/stripe/resources/alipay_account.rb +34 -0
  35. data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +4 -2
  36. data/lib/stripe/resources/application_fee.rb +13 -0
  37. data/lib/stripe/resources/application_fee_refund.rb +30 -0
  38. data/lib/stripe/{balance.rb → resources/balance.rb} +3 -1
  39. data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +3 -5
  40. data/lib/stripe/resources/bank_account.rb +42 -0
  41. data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +6 -5
  42. data/lib/stripe/resources/bitcoin_transaction.rb +15 -0
  43. data/lib/stripe/resources/capability.rb +33 -0
  44. data/lib/stripe/resources/card.rb +37 -0
  45. data/lib/stripe/resources/charge.rb +22 -0
  46. data/lib/stripe/resources/checkout/session.rb +12 -0
  47. data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +3 -5
  48. data/lib/stripe/{coupon.rb → resources/coupon.rb} +4 -2
  49. data/lib/stripe/resources/credit_note.rb +32 -0
  50. data/lib/stripe/resources/credit_note_line_item.rb +7 -0
  51. data/lib/stripe/resources/customer.rb +35 -0
  52. data/lib/stripe/resources/customer_balance_transaction.rb +30 -0
  53. data/lib/stripe/resources/discount.rb +7 -0
  54. data/lib/stripe/resources/dispute.rb +21 -0
  55. data/lib/stripe/resources/ephemeral_key.rb +19 -0
  56. data/lib/stripe/{event.rb → resources/event.rb} +3 -1
  57. data/lib/stripe/resources/exchange_rate.rb +9 -0
  58. data/lib/stripe/resources/file.rb +34 -0
  59. data/lib/stripe/resources/file_link.rb +11 -0
  60. data/lib/stripe/resources/invoice.rb +73 -0
  61. data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +4 -2
  62. data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +3 -1
  63. data/lib/stripe/resources/issuing/authorization.rb +33 -0
  64. data/lib/stripe/resources/issuing/card.rb +24 -0
  65. data/lib/stripe/resources/issuing/card_details.rb +9 -0
  66. data/lib/stripe/resources/issuing/cardholder.rb +13 -0
  67. data/lib/stripe/resources/issuing/dispute.rb +13 -0
  68. data/lib/stripe/resources/issuing/transaction.rb +12 -0
  69. data/lib/stripe/resources/login_link.rb +14 -0
  70. data/lib/stripe/resources/mandate.rb +7 -0
  71. data/lib/stripe/resources/order.rb +32 -0
  72. data/lib/stripe/{order_return.rb → resources/order_return.rb} +3 -5
  73. data/lib/stripe/resources/payment_intent.rb +42 -0
  74. data/lib/stripe/resources/payment_method.rb +32 -0
  75. data/lib/stripe/resources/payout.rb +22 -0
  76. data/lib/stripe/resources/person.rb +31 -0
  77. data/lib/stripe/{plan.rb → resources/plan.rb} +3 -1
  78. data/lib/stripe/{product.rb → resources/product.rb} +5 -3
  79. data/lib/stripe/resources/radar/early_fraud_warning.rb +11 -0
  80. data/lib/stripe/resources/radar/value_list.rb +14 -0
  81. data/lib/stripe/resources/radar/value_list_item.rb +13 -0
  82. data/lib/stripe/{recipient.rb → resources/recipient.rb} +5 -6
  83. data/lib/stripe/resources/recipient_transfer.rb +7 -0
  84. data/lib/stripe/{refund.rb → resources/refund.rb} +3 -1
  85. data/lib/stripe/resources/reporting/report_run.rb +12 -0
  86. data/lib/stripe/resources/reporting/report_type.rb +12 -0
  87. data/lib/stripe/resources/reversal.rb +29 -0
  88. data/lib/stripe/resources/review.rb +20 -0
  89. data/lib/stripe/resources/setup_intent.rb +32 -0
  90. data/lib/stripe/resources/sigma/scheduled_query_run.rb +15 -0
  91. data/lib/stripe/{sku.rb → resources/sku.rb} +5 -3
  92. data/lib/stripe/resources/source.rb +46 -0
  93. data/lib/stripe/resources/source_transaction.rb +7 -0
  94. data/lib/stripe/resources/subscription.rb +25 -0
  95. data/lib/stripe/resources/subscription_item.rb +25 -0
  96. data/lib/stripe/resources/subscription_schedule.rb +32 -0
  97. data/lib/stripe/resources/tax_id.rb +26 -0
  98. data/lib/stripe/resources/tax_rate.rb +11 -0
  99. data/lib/stripe/resources/terminal/connection_token.rb +11 -0
  100. data/lib/stripe/resources/terminal/location.rb +14 -0
  101. data/lib/stripe/resources/terminal/reader.rb +14 -0
  102. data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +3 -1
  103. data/lib/stripe/{token.rb → resources/token.rb} +3 -1
  104. data/lib/stripe/resources/topup.rb +22 -0
  105. data/lib/stripe/resources/transfer.rb +26 -0
  106. data/lib/stripe/resources/usage_record.rb +7 -0
  107. data/lib/stripe/resources/usage_record_summary.rb +7 -0
  108. data/lib/stripe/resources/webhook_endpoint.rb +12 -0
  109. data/lib/stripe/resources.rb +79 -0
  110. data/lib/stripe/singleton_api_resource.rb +10 -4
  111. data/lib/stripe/stripe_client.rb +658 -337
  112. data/lib/stripe/stripe_object.rb +248 -126
  113. data/lib/stripe/stripe_response.rb +55 -21
  114. data/lib/stripe/util.rb +145 -187
  115. data/lib/stripe/version.rb +3 -1
  116. data/lib/stripe/webhook.rb +27 -16
  117. data/lib/stripe.rb +139 -90
  118. data/stripe.gemspec +26 -14
  119. data/test/openapi/README.md +9 -0
  120. data/test/stripe/account_link_test.rb +18 -0
  121. data/test/stripe/account_test.rb +311 -101
  122. data/test/stripe/alipay_account_test.rb +21 -1
  123. data/test/stripe/api_operations_test.rb +57 -8
  124. data/test/stripe/api_resource_test.rb +359 -271
  125. data/test/stripe/apple_pay_domain_test.rb +26 -11
  126. data/test/stripe/application_fee_refund_test.rb +10 -8
  127. data/test/stripe/application_fee_test.rb +49 -3
  128. data/test/stripe/balance_test.rb +4 -2
  129. data/test/stripe/balance_transaction_test.rb +20 -0
  130. data/test/stripe/bank_account_test.rb +11 -11
  131. data/test/stripe/capability_test.rb +45 -0
  132. data/test/stripe/charge_test.rb +25 -18
  133. data/test/stripe/checkout/session_test.rb +41 -0
  134. data/test/stripe/connection_manager_test.rb +163 -0
  135. data/test/stripe/country_spec_test.rb +6 -4
  136. data/test/stripe/coupon_test.rb +29 -10
  137. data/test/stripe/credit_note_test.rb +90 -0
  138. data/test/stripe/customer_balance_transaction_test.rb +37 -0
  139. data/test/stripe/customer_card_test.rb +13 -17
  140. data/test/stripe/customer_test.rb +161 -49
  141. data/test/stripe/dispute_test.rb +19 -8
  142. data/test/stripe/ephemeral_key_test.rb +23 -14
  143. data/test/stripe/errors_test.rb +32 -9
  144. data/test/stripe/exchange_rate_test.rb +20 -0
  145. data/test/stripe/file_link_test.rb +41 -0
  146. data/test/stripe/file_test.rb +87 -0
  147. data/test/stripe/instrumentation_test.rb +74 -0
  148. data/test/stripe/invoice_item_test.rb +31 -18
  149. data/test/stripe/invoice_line_item_test.rb +3 -1
  150. data/test/stripe/invoice_test.rb +158 -39
  151. data/test/stripe/issuing/authorization_test.rb +72 -0
  152. data/test/stripe/issuing/card_test.rb +62 -0
  153. data/test/stripe/issuing/cardholder_test.rb +53 -0
  154. data/test/stripe/issuing/dispute_test.rb +45 -0
  155. data/test/stripe/issuing/transaction_test.rb +48 -0
  156. data/test/stripe/list_object_test.rb +120 -88
  157. data/test/stripe/login_link_test.rb +16 -14
  158. data/test/stripe/mandate_test.rb +14 -0
  159. data/test/stripe/multipart_encoder_test.rb +130 -0
  160. data/test/stripe/oauth_test.rb +69 -50
  161. data/test/stripe/order_return_test.rb +7 -5
  162. data/test/stripe/order_test.rb +39 -14
  163. data/test/stripe/payment_intent_test.rb +107 -0
  164. data/test/stripe/payment_method_test.rb +84 -0
  165. data/test/stripe/payout_test.rb +18 -9
  166. data/test/stripe/person_test.rb +46 -0
  167. data/test/stripe/plan_test.rb +67 -19
  168. data/test/stripe/product_test.rb +28 -14
  169. data/test/stripe/radar/early_fraud_warning_test.rb +22 -0
  170. data/test/stripe/radar/value_list_item_test.rb +48 -0
  171. data/test/stripe/radar/value_list_test.rb +61 -0
  172. data/test/stripe/recipient_test.rb +27 -13
  173. data/test/stripe/refund_test.rb +11 -9
  174. data/test/stripe/reporting/report_run_test.rb +33 -0
  175. data/test/stripe/reporting/report_type_test.rb +22 -0
  176. data/test/stripe/reversal_test.rb +12 -10
  177. data/test/stripe/review_test.rb +27 -0
  178. data/test/stripe/setup_intent_test.rb +84 -0
  179. data/test/stripe/sigma/scheduled_query_run_test.rb +22 -0
  180. data/test/stripe/sku_test.rb +24 -12
  181. data/test/stripe/source_test.rb +70 -19
  182. data/test/stripe/stripe_client_test.rb +867 -326
  183. data/test/stripe/stripe_object_test.rb +284 -182
  184. data/test/stripe/stripe_response_test.rb +73 -24
  185. data/test/stripe/subscription_item_test.rb +47 -15
  186. data/test/stripe/subscription_schedule_test.rb +82 -0
  187. data/test/stripe/subscription_test.rb +41 -19
  188. data/test/stripe/tax_id_test.rb +31 -0
  189. data/test/stripe/tax_rate_test.rb +43 -0
  190. data/test/stripe/terminal/connection_token_test.rb +16 -0
  191. data/test/stripe/terminal/location_test.rb +68 -0
  192. data/test/stripe/terminal/reader_test.rb +62 -0
  193. data/test/stripe/three_d_secure_test.rb +4 -2
  194. data/test/stripe/topup_test.rb +62 -0
  195. data/test/stripe/transfer_test.rb +55 -8
  196. data/test/stripe/usage_record_summary_test.rb +29 -0
  197. data/test/stripe/util_test.rb +173 -84
  198. data/test/stripe/webhook_endpoint_test.rb +59 -0
  199. data/test/stripe/webhook_test.rb +21 -17
  200. data/test/stripe_mock.rb +78 -0
  201. data/test/stripe_test.rb +6 -15
  202. data/test/test_data.rb +28 -26
  203. data/test/test_helper.rb +48 -29
  204. metadata +183 -70
  205. data/lib/stripe/alipay_account.rb +0 -22
  206. data/lib/stripe/application_fee.rb +0 -22
  207. data/lib/stripe/application_fee_refund.rb +0 -20
  208. data/lib/stripe/bank_account.rb +0 -30
  209. data/lib/stripe/bitcoin_transaction.rb +0 -11
  210. data/lib/stripe/card.rb +0 -27
  211. data/lib/stripe/charge.rb +0 -82
  212. data/lib/stripe/customer.rb +0 -79
  213. data/lib/stripe/dispute.rb +0 -17
  214. data/lib/stripe/ephemeral_key.rb +0 -18
  215. data/lib/stripe/file_upload.rb +0 -33
  216. data/lib/stripe/invoice.rb +0 -29
  217. data/lib/stripe/login_link.rb +0 -9
  218. data/lib/stripe/order.rb +0 -29
  219. data/lib/stripe/payout.rb +0 -18
  220. data/lib/stripe/recipient_transfer.rb +0 -6
  221. data/lib/stripe/reversal.rb +0 -20
  222. data/lib/stripe/source.rb +0 -23
  223. data/lib/stripe/subscription.rb +0 -33
  224. data/lib/stripe/subscription_item.rb +0 -14
  225. data/lib/stripe/transfer.rb +0 -18
  226. data/test/api_stub_helpers.rb +0 -0
  227. data/test/stripe/bitcoin_receiver_test.rb +0 -67
  228. data/test/stripe/bitcoin_transaction_test.rb +0 -19
  229. data/test/stripe/file_upload_test.rb +0 -66
  230. data/test/stripe/recipient_card_test.rb +0 -44
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ class PersonTest < Test::Unit::TestCase
7
+ context "#resource_url" do
8
+ should "return a resource URL" do
9
+ person = Stripe::Person.construct_from(
10
+ id: "person_123",
11
+ account: "acct_123"
12
+ )
13
+ assert_equal "/v1/accounts/acct_123/persons/person_123",
14
+ person.resource_url
15
+ end
16
+
17
+ should "raise without an account" do
18
+ person = Stripe::Person.construct_from(id: "person_123")
19
+ assert_raises NotImplementedError do
20
+ person.resource_url
21
+ end
22
+ end
23
+ end
24
+
25
+ should "raise on #retrieve" do
26
+ assert_raises NotImplementedError do
27
+ Stripe::Person.retrieve("person_123")
28
+ end
29
+ end
30
+
31
+ should "raise on #update" do
32
+ assert_raises NotImplementedError do
33
+ Stripe::Person.update("person_123", {})
34
+ end
35
+ end
36
+
37
+ should "be saveable" do
38
+ account = Stripe::Account.retrieve("acct_123")
39
+ person = account.persons.retrieve("person_123")
40
+ person.first_name = "John"
41
+ person.save
42
+ assert_requested :post,
43
+ "#{Stripe.api_base}/v1/accounts/#{person.account}/persons/#{person.id}"
44
+ end
45
+ end
46
+ end
@@ -1,50 +1,98 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
2
4
 
3
5
  module Stripe
4
6
  class PlanTest < Test::Unit::TestCase
5
7
  should "be listable" do
6
8
  plans = Stripe::Plan.list
7
9
  assert_requested :get, "#{Stripe.api_base}/v1/plans"
8
- assert plans.data.kind_of?(Array)
9
- assert plans.data[0].kind_of?(Stripe::Plan)
10
+ assert plans.data.is_a?(Array)
11
+ assert plans.data[0].is_a?(Stripe::Plan)
10
12
  end
11
13
 
12
14
  should "be retrievable" do
13
- plan = Stripe::Plan.retrieve("sapphire-elite")
14
- assert_requested :get, "#{Stripe.api_base}/v1/plans/sapphire-elite"
15
- assert plan.kind_of?(Stripe::Plan)
15
+ plan = Stripe::Plan.retrieve("pl_123")
16
+ assert_requested :get, "#{Stripe.api_base}/v1/plans/pl_123"
17
+ assert plan.is_a?(Stripe::Plan)
16
18
  end
17
19
 
18
20
  should "be creatable" do
19
21
  plan = Stripe::Plan.create(
20
22
  amount: 5000,
21
23
  interval: "month",
22
- name: "Sapphire elite",
24
+ nickname: "Sapphire elite",
25
+ currency: "usd"
26
+ )
27
+ assert_requested :post, "#{Stripe.api_base}/v1/plans"
28
+ assert plan.is_a?(Stripe::Plan)
29
+ end
30
+
31
+ should "be creatable with metered configuration" do
32
+ plan = Stripe::Plan.create(
33
+ amount: 5000,
34
+ interval: "month",
35
+ nickname: "Sapphire elite",
23
36
  currency: "usd",
24
- id: "sapphire-elite"
37
+ usage_type: "metered"
25
38
  )
26
39
  assert_requested :post, "#{Stripe.api_base}/v1/plans"
27
- assert plan.kind_of?(Stripe::Plan)
40
+ assert plan.is_a?(Stripe::Plan)
41
+ end
42
+
43
+ should "be creatable with tiered configuration" do
44
+ plan = Stripe::Plan.create(
45
+ interval: "month",
46
+ nickname: "Sapphire elite",
47
+ currency: "usd",
48
+ billing_scheme: "tiered",
49
+ tiers_mode: "volume",
50
+ tiers: [{ up_to: 100, amount: 1000 }, { up_to: "inf", amount: 2000 }]
51
+ )
52
+ assert_requested :post, "#{Stripe.api_base}/v1/plans"
53
+ assert plan.is_a?(Stripe::Plan)
54
+ end
55
+
56
+ should "be creatable with transform_usage" do
57
+ plan = Stripe::Plan.create(
58
+ interval: "month",
59
+ nickname: "Sapphire elite",
60
+ currency: "usd",
61
+ amount: 5000,
62
+ transform_usage: { round: "up", divide_by: 50 }
63
+ )
64
+ assert_requested :post, "#{Stripe.api_base}/v1/plans"
65
+ assert plan.is_a?(Stripe::Plan)
28
66
  end
29
67
 
30
68
  should "be saveable" do
31
- plan = Stripe::Plan.retrieve("sapphire-elite")
32
- plan.metadata['key'] = 'value'
69
+ plan = Stripe::Plan.retrieve("pl_123")
70
+ plan.metadata["key"] = "value"
33
71
  plan.save
34
72
  assert_requested :post, "#{Stripe.api_base}/v1/plans/#{plan.id}"
35
73
  end
36
74
 
37
75
  should "be updateable" do
38
- plan = Stripe::Plan.update("sapphire-elite", metadata: {foo: 'bar'})
39
- assert_requested :post, "#{Stripe.api_base}/v1/plans/sapphire-elite"
40
- assert plan.kind_of?(Stripe::Plan)
76
+ plan = Stripe::Plan.update("pl_123", metadata: { foo: "bar" })
77
+ assert_requested :post, "#{Stripe.api_base}/v1/plans/pl_123"
78
+ assert plan.is_a?(Stripe::Plan)
79
+ end
80
+
81
+ context "#delete" do
82
+ should "be deletable" do
83
+ plan = Stripe::Plan.retrieve("pl_123")
84
+ plan = plan.delete
85
+ assert_requested :delete, "#{Stripe.api_base}/v1/plans/#{plan.id}"
86
+ assert plan.is_a?(Stripe::Plan)
87
+ end
41
88
  end
42
89
 
43
- should "be deletable" do
44
- plan = Stripe::Plan.retrieve("sapphire-elite")
45
- plan = plan.delete
46
- assert_requested :delete, "#{Stripe.api_base}/v1/plans/#{plan.id}"
47
- assert plan.kind_of?(Stripe::Plan)
90
+ context ".delete" do
91
+ should "be deletable" do
92
+ plan = Stripe::Plan.delete("pl_123")
93
+ assert_requested :delete, "#{Stripe.api_base}/v1/plans/pl_123"
94
+ assert plan.is_a?(Stripe::Plan)
95
+ end
48
96
  end
49
97
  end
50
98
  end
@@ -1,45 +1,59 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
2
4
 
3
5
  module Stripe
4
6
  class ProductTest < Test::Unit::TestCase
5
7
  should "be listable" do
6
8
  products = Stripe::Product.list
7
9
  assert_requested :get, "#{Stripe.api_base}/v1/products"
8
- assert products.data.kind_of?(Array)
9
- assert products.data[0].kind_of?(Stripe::Product)
10
+ assert products.data.is_a?(Array)
11
+ assert products.data[0].is_a?(Stripe::Product)
10
12
  end
11
13
 
12
14
  should "be retrievable" do
13
15
  product = Stripe::Product.retrieve("prod_123")
14
16
  assert_requested :get, "#{Stripe.api_base}/v1/products/prod_123"
15
- assert product.kind_of?(Stripe::Product)
17
+ assert product.is_a?(Stripe::Product)
16
18
  end
17
19
 
18
20
  should "be creatable" do
19
- _ = Stripe::Product.create(
20
- name: "My Product"
21
+ product = Stripe::Product.create(
22
+ name: "My Product",
23
+ type: "good"
21
24
  )
22
25
  assert_requested :post, "#{Stripe.api_base}/v1/products"
26
+ assert product.is_a?(Stripe::Product)
23
27
  end
24
28
 
25
29
  should "be saveable" do
26
30
  product = Stripe::Product.retrieve("prod_123")
27
- product.metadata['key'] = 'value'
31
+ product.metadata["key"] = "value"
28
32
  product.save
29
33
  assert_requested :post, "#{Stripe.api_base}/v1/products/#{product.id}"
30
34
  end
31
35
 
32
36
  should "be updateable" do
33
- product = Stripe::Product.update("prod_123", metadata: {foo: 'bar'})
37
+ product = Stripe::Product.update("prod_123", metadata: { foo: "bar" })
34
38
  assert_requested :post, "#{Stripe.api_base}/v1/products/prod_123"
35
- assert product.kind_of?(Stripe::Product)
39
+ assert product.is_a?(Stripe::Product)
36
40
  end
37
41
 
38
- should "be deletable" do
39
- product = Stripe::Product.retrieve("prod_123")
40
- product = product.delete
41
- assert_requested :delete, "#{Stripe.api_base}/v1/products/#{product.id}"
42
- assert product.kind_of?(Stripe::Product)
42
+ context "#delete" do
43
+ should "be deletable" do
44
+ product = Stripe::Product.retrieve("prod_123")
45
+ product = product.delete
46
+ assert_requested :delete, "#{Stripe.api_base}/v1/products/#{product.id}"
47
+ assert product.is_a?(Stripe::Product)
48
+ end
49
+ end
50
+
51
+ context ".delete" do
52
+ should "be deletable" do
53
+ product = Stripe::Product.delete("prod_123")
54
+ assert_requested :delete, "#{Stripe.api_base}/v1/products/prod_123"
55
+ assert product.is_a?(Stripe::Product)
56
+ end
43
57
  end
44
58
  end
45
59
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ module Radar
7
+ class EarlyFraudWarningTest < Test::Unit::TestCase
8
+ should "be listable" do
9
+ warnings = Stripe::Radar::EarlyFraudWarning.list
10
+ assert_requested :get, "#{Stripe.api_base}/v1/radar/early_fraud_warnings"
11
+ assert warnings.data.is_a?(Array)
12
+ assert warnings.data[0].is_a?(Stripe::Radar::EarlyFraudWarning)
13
+ end
14
+
15
+ should "be retrievable" do
16
+ warning = Stripe::Radar::EarlyFraudWarning.retrieve("issfr_123")
17
+ assert_requested :get, "#{Stripe.api_base}/v1/radar/early_fraud_warnings/issfr_123"
18
+ assert warning.is_a?(Stripe::Radar::EarlyFraudWarning)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ module Radar
7
+ class ValueListItemTest < Test::Unit::TestCase
8
+ should "be listable" do
9
+ items = Stripe::Radar::ValueListItem.list(value_list: "rsl_123")
10
+ assert_requested :get, "#{Stripe.api_base}/v1/radar/value_list_items?value_list=rsl_123"
11
+ assert items.data.is_a?(Array)
12
+ assert items.first.is_a?(Stripe::Radar::ValueListItem)
13
+ end
14
+
15
+ should "be retrievable" do
16
+ item = Stripe::Radar::ValueListItem.retrieve("rsli_123")
17
+ assert_requested :get, "#{Stripe.api_base}/v1/radar/value_list_items/rsli_123"
18
+ assert item.is_a?(Stripe::Radar::ValueListItem)
19
+ end
20
+
21
+ should "be creatable" do
22
+ item = Stripe::Radar::ValueListItem.create(
23
+ value_list: "rsl_123",
24
+ value: "value"
25
+ )
26
+ assert_requested :post, "#{Stripe.api_base}/v1/radar/value_list_items"
27
+ assert item.is_a?(Stripe::Radar::ValueListItem)
28
+ end
29
+
30
+ context "#delete" do
31
+ should "be deletable" do
32
+ list = Stripe::Radar::ValueListItem.retrieve("rsli_123")
33
+ list = list.delete
34
+ assert_requested :delete, "#{Stripe.api_base}/v1/radar/value_list_items/rsli_123"
35
+ assert list.is_a?(Stripe::Radar::ValueListItem)
36
+ end
37
+ end
38
+
39
+ context ".delete" do
40
+ should "be deletable" do
41
+ list = Stripe::Radar::ValueListItem.delete("rsli_123")
42
+ assert_requested :delete, "#{Stripe.api_base}/v1/radar/value_list_items/rsli_123"
43
+ assert list.is_a?(Stripe::Radar::ValueListItem)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ module Radar
7
+ class ValueListTest < Test::Unit::TestCase
8
+ should "be listable" do
9
+ lists = Stripe::Radar::ValueList.list
10
+ assert_requested :get, "#{Stripe.api_base}/v1/radar/value_lists"
11
+ assert lists.data.is_a?(Array)
12
+ assert lists.first.is_a?(Stripe::Radar::ValueList)
13
+ end
14
+
15
+ should "be retrievable" do
16
+ list = Stripe::Radar::ValueList.retrieve("rsl_123")
17
+ assert_requested :get, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123"
18
+ assert list.is_a?(Stripe::Radar::ValueList)
19
+ end
20
+
21
+ should "be creatable" do
22
+ list = Stripe::Radar::ValueList.create(
23
+ alias: "list_alias",
24
+ name: "list_name"
25
+ )
26
+ assert_requested :post, "#{Stripe.api_base}/v1/radar/value_lists"
27
+ assert list.is_a?(Stripe::Radar::ValueList)
28
+ end
29
+
30
+ should "be saveable" do
31
+ list = Stripe::Radar::ValueList.retrieve("rsl_123")
32
+ list.metadata["key"] = "value"
33
+ list.save
34
+ assert_requested :post, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123"
35
+ end
36
+
37
+ should "be updateable" do
38
+ list = Stripe::Radar::ValueList.update("rsl_123", metadata: { key: "value" })
39
+ assert_requested :post, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123"
40
+ assert list.is_a?(Stripe::Radar::ValueList)
41
+ end
42
+
43
+ context "#delete" do
44
+ should "be deletable" do
45
+ list = Stripe::Radar::ValueList.retrieve("rsl_123")
46
+ list = list.delete
47
+ assert_requested :delete, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123"
48
+ assert list.is_a?(Stripe::Radar::ValueList)
49
+ end
50
+ end
51
+
52
+ context ".delete" do
53
+ should "be deletable" do
54
+ list = Stripe::Radar::ValueList.delete("rsl_123")
55
+ assert_requested :delete, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123"
56
+ assert list.is_a?(Stripe::Radar::ValueList)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,18 +1,20 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
2
4
 
3
5
  module Stripe
4
6
  class RecipientTest < Test::Unit::TestCase
5
7
  should "be listable" do
6
8
  recipients = Stripe::Recipient.list
7
9
  assert_requested :get, "#{Stripe.api_base}/v1/recipients"
8
- assert recipients.data.kind_of?(Array)
9
- assert recipients.data[0].kind_of?(Stripe::Recipient)
10
+ assert recipients.data.is_a?(Array)
11
+ assert recipients.data[0].is_a?(Stripe::Recipient)
10
12
  end
11
13
 
12
14
  should "be retrievable" do
13
15
  recipient = Stripe::Recipient.retrieve("rp_123")
14
16
  assert_requested :get, "#{Stripe.api_base}/v1/recipients/rp_123"
15
- assert recipient.kind_of?(Stripe::Recipient)
17
+ assert recipient.is_a?(Stripe::Recipient)
16
18
  end
17
19
 
18
20
  should "be creatable" do
@@ -21,28 +23,40 @@ module Stripe
21
23
  type: "individual"
22
24
  )
23
25
  assert_requested :post, "#{Stripe.api_base}/v1/recipients"
24
- assert recipient.kind_of?(Stripe::Recipient)
26
+ assert recipient.is_a?(Stripe::Recipient)
25
27
  end
26
28
 
27
29
  should "be saveable" do
28
30
  recipient = Stripe::Recipient.retrieve("rp_123")
29
- recipient.metadata['key'] = 'value'
31
+ recipient.metadata["key"] = "value"
30
32
  recipient.save
31
33
  assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{recipient.id}"
32
34
  end
33
35
 
34
36
  should "be updateable" do
35
- recipient = Stripe::Recipient.update("rp_123", metadata: {foo: 'bar'})
37
+ recipient = Stripe::Recipient.update("rp_123", metadata: { foo: "bar" })
36
38
  assert_requested :post, "#{Stripe.api_base}/v1/recipients/rp_123"
37
- assert recipient.kind_of?(Stripe::Recipient)
39
+ assert recipient.is_a?(Stripe::Recipient)
38
40
  end
39
41
 
40
42
  should "be deletable" do
41
- recipient = Stripe::Recipient.retrieve("rp_123")
42
- recipient = recipient.delete
43
- assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{recipient.id}"
44
- assert recipient.kind_of?(Stripe::Recipient)
43
+ end
44
+
45
+ context "#delete" do
46
+ should "be deletable" do
47
+ recipient = Stripe::Recipient.retrieve("rp_123")
48
+ recipient = recipient.delete
49
+ assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{recipient.id}"
50
+ assert recipient.is_a?(Stripe::Recipient)
51
+ end
52
+ end
53
+
54
+ context ".delete" do
55
+ should "be deletable" do
56
+ recipient = Stripe::Recipient.delete("rp_123")
57
+ assert_requested :delete, "#{Stripe.api_base}/v1/recipients/rp_123"
58
+ assert recipient.is_a?(Stripe::Recipient)
59
+ end
45
60
  end
46
61
  end
47
62
  end
48
-
@@ -1,37 +1,39 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
2
4
 
3
5
  module Stripe
4
6
  class RefundTest < Test::Unit::TestCase
5
7
  should "be listable" do
6
8
  refunds = Stripe::Refund.list
7
9
  assert_requested :get, "#{Stripe.api_base}/v1/refunds"
8
- assert refunds.data.kind_of?(Array)
9
- assert refunds.first.kind_of?(Stripe::Refund)
10
+ assert refunds.data.is_a?(Array)
11
+ assert refunds.first.is_a?(Stripe::Refund)
10
12
  end
11
13
 
12
14
  should "be retrievable" do
13
15
  refund = Stripe::Refund.retrieve("re_123")
14
16
  assert_requested :get, "#{Stripe.api_base}/v1/refunds/re_123"
15
- assert refund.kind_of?(Stripe::Refund)
17
+ assert refund.is_a?(Stripe::Refund)
16
18
  end
17
19
 
18
20
  should "be creatable" do
19
- refund = Stripe::Refund.create(:charge => "ch_123")
21
+ refund = Stripe::Refund.create(charge: "ch_123")
20
22
  assert_requested :post, "#{Stripe.api_base}/v1/refunds"
21
- assert refund.kind_of?(Stripe::Refund)
23
+ assert refund.is_a?(Stripe::Refund)
22
24
  end
23
25
 
24
26
  should "be saveable" do
25
27
  refund = Stripe::Refund.retrieve("re_123")
26
- refund.metadata['key'] = 'value'
28
+ refund.metadata["key"] = "value"
27
29
  refund.save
28
30
  assert_requested :post, "#{Stripe.api_base}/v1/refunds/#{refund.id}"
29
31
  end
30
32
 
31
33
  should "be updateable" do
32
- refund = Stripe::Refund.update("re_123", metadata: { key: 'value' })
34
+ refund = Stripe::Refund.update("re_123", metadata: { key: "value" })
33
35
  assert_requested :post, "#{Stripe.api_base}/v1/refunds/re_123"
34
- assert refund.kind_of?(Stripe::Refund)
36
+ assert refund.is_a?(Stripe::Refund)
35
37
  end
36
38
  end
37
39
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ module Reporting
7
+ class ReportRunTest < Test::Unit::TestCase
8
+ should "be creatable" do
9
+ report_run = Stripe::Reporting::ReportRun.create(
10
+ parameters: {
11
+ connected_account: "acct_123",
12
+ },
13
+ report_type: "activity.summary.1"
14
+ )
15
+ assert_requested :post, "#{Stripe.api_base}/v1/reporting/report_runs"
16
+ assert report_run.is_a?(Stripe::Reporting::ReportRun)
17
+ end
18
+
19
+ should "be listable" do
20
+ report_runs = Stripe::Reporting::ReportRun.list
21
+ assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_runs"
22
+ assert report_runs.data.is_a?(Array)
23
+ assert report_runs.data[0].is_a?(Stripe::Reporting::ReportRun)
24
+ end
25
+
26
+ should "be retrievable" do
27
+ report_run = Stripe::Reporting::ReportRun.retrieve("frr_123")
28
+ assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_runs/frr_123"
29
+ assert report_run.is_a?(Stripe::Reporting::ReportRun)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ module Reporting
7
+ class ReportTypeTest < Test::Unit::TestCase
8
+ should "be listable" do
9
+ report_types = Stripe::Reporting::ReportType.list
10
+ assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_types"
11
+ assert report_types.data.is_a?(Array)
12
+ assert report_types.data[0].is_a?(Stripe::Reporting::ReportType)
13
+ end
14
+
15
+ should "be retrievable" do
16
+ report_type = Stripe::Reporting::ReportType.retrieve("activity.summary.1")
17
+ assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_types/activity.summary.1"
18
+ assert report_type.is_a?(Stripe::Reporting::ReportType)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,4 +1,6 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
2
4
 
3
5
  module Stripe
4
6
  class ReversalTest < Test::Unit::TestCase
@@ -9,16 +11,16 @@ module Stripe
9
11
  should "be listable" do
10
12
  reversals = @transfer.reversals.list
11
13
  assert_requested :get,
12
- "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
13
- assert reversals.data.kind_of?(Array)
14
- assert reversals.data[0].kind_of?(Stripe::Reversal)
14
+ "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
15
+ assert reversals.data.is_a?(Array)
16
+ assert reversals.data[0].is_a?(Stripe::Reversal)
15
17
  end
16
18
 
17
19
  should "be retrievable" do
18
20
  reversal = @transfer.reversals.retrieve("trr_123")
19
21
  assert_requested :get,
20
- "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/trr_123"
21
- assert reversal.kind_of?(Stripe::Reversal)
22
+ "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/trr_123"
23
+ assert reversal.is_a?(Stripe::Reversal)
22
24
  end
23
25
 
24
26
  should "be creatable" do
@@ -26,16 +28,16 @@ module Stripe
26
28
  amount: 100
27
29
  )
28
30
  assert_requested :post,
29
- "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
30
- assert reversal.kind_of?(Stripe::Reversal)
31
+ "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
32
+ assert reversal.is_a?(Stripe::Reversal)
31
33
  end
32
34
 
33
35
  should "be saveable" do
34
36
  reversal = @transfer.reversals.retrieve("trr_123")
35
- reversal.metadata['key'] = 'value'
37
+ reversal.metadata["key"] = "value"
36
38
  reversal.save
37
39
  assert_requested :post,
38
- "#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/#{reversal.id}"
40
+ "#{Stripe.api_base}/v1/transfers/#{reversal.transfer}/reversals/#{reversal.id}"
39
41
  end
40
42
  end
41
43
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../test_helper", __dir__)
4
+
5
+ module Stripe
6
+ class ReviewTest < Test::Unit::TestCase
7
+ should "be listable" do
8
+ reviews = Stripe::Review.list
9
+ assert_requested :get, "#{Stripe.api_base}/v1/reviews"
10
+ assert reviews.data.is_a?(Array)
11
+ assert reviews.first.is_a?(Stripe::Review)
12
+ end
13
+
14
+ should "be retrievable" do
15
+ review = Stripe::Review.retrieve("prv_123")
16
+ assert_requested :get, "#{Stripe.api_base}/v1/reviews/prv_123"
17
+ assert review.is_a?(Stripe::Review)
18
+ end
19
+
20
+ should "be approvable" do
21
+ review = Stripe::Review.retrieve("prv_123")
22
+ review.approve
23
+ assert_requested :post, "#{Stripe.api_base}/v1/reviews/prv_123/approve"
24
+ assert review.is_a?(Stripe::Review)
25
+ end
26
+ end
27
+ end