stripe 5.22.0 → 5.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +142 -0
  3. data/Gemfile +0 -1
  4. data/Makefile +7 -0
  5. data/README.md +32 -27
  6. data/VERSION +1 -1
  7. data/lib/stripe/api_operations/create.rb +1 -1
  8. data/lib/stripe/api_operations/delete.rb +7 -3
  9. data/lib/stripe/api_operations/list.rb +1 -1
  10. data/lib/stripe/api_operations/nested_resource.rb +6 -5
  11. data/lib/stripe/api_operations/request.rb +54 -5
  12. data/lib/stripe/api_operations/save.rb +7 -4
  13. data/lib/stripe/api_operations/search.rb +19 -0
  14. data/lib/stripe/api_resource.rb +13 -19
  15. data/lib/stripe/api_resource_test_helpers.rb +47 -0
  16. data/lib/stripe/connection_manager.rb +51 -10
  17. data/lib/stripe/error_object.rb +2 -3
  18. data/lib/stripe/instrumentation.rb +3 -1
  19. data/lib/stripe/list_object.rb +2 -2
  20. data/lib/stripe/oauth.rb +7 -6
  21. data/lib/stripe/object_types.rb +21 -1
  22. data/lib/stripe/resources/account.rb +5 -9
  23. data/lib/stripe/resources/account_link.rb +1 -0
  24. data/lib/stripe/resources/apple_pay_domain.rb +1 -0
  25. data/lib/stripe/resources/application_fee.rb +1 -0
  26. data/lib/stripe/resources/application_fee_refund.rb +2 -1
  27. data/lib/stripe/resources/balance.rb +1 -0
  28. data/lib/stripe/resources/balance_transaction.rb +1 -0
  29. data/lib/stripe/resources/bank_account.rb +2 -1
  30. data/lib/stripe/resources/billing_portal/configuration.rb +14 -0
  31. data/lib/stripe/resources/billing_portal/session.rb +1 -0
  32. data/lib/stripe/resources/bitcoin_receiver.rb +1 -0
  33. data/lib/stripe/resources/bitcoin_transaction.rb +3 -2
  34. data/lib/stripe/resources/capability.rb +2 -1
  35. data/lib/stripe/resources/card.rb +1 -0
  36. data/lib/stripe/resources/cash_balance.rb +22 -0
  37. data/lib/stripe/resources/charge.rb +10 -0
  38. data/lib/stripe/resources/checkout/session.rb +12 -0
  39. data/lib/stripe/resources/country_spec.rb +1 -0
  40. data/lib/stripe/resources/coupon.rb +1 -0
  41. data/lib/stripe/resources/credit_note.rb +3 -2
  42. data/lib/stripe/resources/credit_note_line_item.rb +1 -0
  43. data/lib/stripe/resources/customer.rb +41 -2
  44. data/lib/stripe/resources/customer_balance_transaction.rb +3 -2
  45. data/lib/stripe/resources/discount.rb +1 -0
  46. data/lib/stripe/resources/dispute.rb +1 -0
  47. data/lib/stripe/resources/ephemeral_key.rb +1 -0
  48. data/lib/stripe/resources/event.rb +1 -0
  49. data/lib/stripe/resources/exchange_rate.rb +1 -0
  50. data/lib/stripe/resources/file.rb +3 -1
  51. data/lib/stripe/resources/file_link.rb +1 -0
  52. data/lib/stripe/resources/financial_connections/account.rb +31 -0
  53. data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
  54. data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
  55. data/lib/stripe/resources/financial_connections/session.rb +12 -0
  56. data/lib/stripe/resources/funding_instructions.rb +16 -0
  57. data/lib/stripe/resources/identity/verification_report.rb +12 -0
  58. data/lib/stripe/resources/identity/verification_session.rb +35 -0
  59. data/lib/stripe/resources/invoice.rb +12 -2
  60. data/lib/stripe/resources/invoice_item.rb +1 -0
  61. data/lib/stripe/resources/invoice_line_item.rb +1 -0
  62. data/lib/stripe/resources/issuing/authorization.rb +1 -0
  63. data/lib/stripe/resources/issuing/card.rb +1 -0
  64. data/lib/stripe/resources/issuing/card_details.rb +2 -1
  65. data/lib/stripe/resources/issuing/cardholder.rb +1 -0
  66. data/lib/stripe/resources/issuing/dispute.rb +12 -0
  67. data/lib/stripe/resources/issuing/transaction.rb +1 -0
  68. data/lib/stripe/resources/line_item.rb +1 -0
  69. data/lib/stripe/resources/login_link.rb +1 -0
  70. data/lib/stripe/resources/mandate.rb +1 -0
  71. data/lib/stripe/resources/order.rb +1 -0
  72. data/lib/stripe/resources/order_return.rb +1 -0
  73. data/lib/stripe/resources/payment_intent.rb +40 -0
  74. data/lib/stripe/resources/payment_link.rb +23 -0
  75. data/lib/stripe/resources/payment_method.rb +1 -0
  76. data/lib/stripe/resources/payout.rb +11 -0
  77. data/lib/stripe/resources/person.rb +1 -0
  78. data/lib/stripe/resources/plan.rb +1 -0
  79. data/lib/stripe/resources/price.rb +10 -0
  80. data/lib/stripe/resources/product.rb +10 -0
  81. data/lib/stripe/resources/promotion_code.rb +12 -0
  82. data/lib/stripe/resources/quote.rb +105 -0
  83. data/lib/stripe/resources/radar/early_fraud_warning.rb +1 -0
  84. data/lib/stripe/resources/radar/value_list.rb +1 -0
  85. data/lib/stripe/resources/radar/value_list_item.rb +1 -0
  86. data/lib/stripe/resources/recipient.rb +1 -0
  87. data/lib/stripe/resources/refund.rb +31 -0
  88. data/lib/stripe/resources/reporting/report_run.rb +1 -0
  89. data/lib/stripe/resources/reporting/report_type.rb +1 -0
  90. data/lib/stripe/resources/reversal.rb +3 -2
  91. data/lib/stripe/resources/review.rb +1 -0
  92. data/lib/stripe/resources/setup_attempt.rb +10 -0
  93. data/lib/stripe/resources/setup_intent.rb +11 -0
  94. data/lib/stripe/resources/shipping_rate.rb +12 -0
  95. data/lib/stripe/resources/sigma/scheduled_query_run.rb +1 -0
  96. data/lib/stripe/resources/sku.rb +1 -0
  97. data/lib/stripe/resources/source.rb +4 -3
  98. data/lib/stripe/resources/source_transaction.rb +1 -0
  99. data/lib/stripe/resources/subscription.rb +10 -0
  100. data/lib/stripe/resources/subscription_item.rb +2 -1
  101. data/lib/stripe/resources/subscription_schedule.rb +1 -0
  102. data/lib/stripe/resources/tax_code.rb +10 -0
  103. data/lib/stripe/resources/tax_id.rb +1 -0
  104. data/lib/stripe/resources/tax_rate.rb +1 -0
  105. data/lib/stripe/resources/terminal/configuration.rb +15 -0
  106. data/lib/stripe/resources/terminal/connection_token.rb +1 -0
  107. data/lib/stripe/resources/terminal/location.rb +1 -0
  108. data/lib/stripe/resources/terminal/reader.rb +61 -0
  109. data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
  110. data/lib/stripe/resources/three_d_secure.rb +1 -0
  111. data/lib/stripe/resources/token.rb +1 -0
  112. data/lib/stripe/resources/topup.rb +1 -0
  113. data/lib/stripe/resources/transfer.rb +1 -0
  114. data/lib/stripe/resources/usage_record.rb +1 -0
  115. data/lib/stripe/resources/usage_record_summary.rb +1 -0
  116. data/lib/stripe/resources/webhook_endpoint.rb +1 -0
  117. data/lib/stripe/resources.rb +18 -0
  118. data/lib/stripe/search_result_object.rb +86 -0
  119. data/lib/stripe/stripe_client.rb +252 -114
  120. data/lib/stripe/stripe_configuration.rb +194 -0
  121. data/lib/stripe/stripe_object.rb +24 -1
  122. data/lib/stripe/stripe_response.rb +80 -52
  123. data/lib/stripe/util.rb +62 -7
  124. data/lib/stripe/version.rb +1 -1
  125. data/lib/stripe.rb +39 -168
  126. data/stripe.gemspec +12 -5
  127. metadata +29 -190
  128. data/.editorconfig +0 -10
  129. data/.gitattributes +0 -4
  130. data/.github/ISSUE_TEMPLATE.md +0 -5
  131. data/.gitignore +0 -8
  132. data/.rubocop.yml +0 -80
  133. data/.rubocop_todo.yml +0 -33
  134. data/.travis.yml +0 -40
  135. data/.vscode/extensions.json +0 -7
  136. data/.vscode/settings.json +0 -8
  137. data/test/openapi/README.md +0 -9
  138. data/test/stripe/account_link_test.rb +0 -18
  139. data/test/stripe/account_test.rb +0 -412
  140. data/test/stripe/alipay_account_test.rb +0 -37
  141. data/test/stripe/api_operations_test.rb +0 -80
  142. data/test/stripe/api_resource_test.rb +0 -646
  143. data/test/stripe/apple_pay_domain_test.rb +0 -46
  144. data/test/stripe/application_fee_refund_test.rb +0 -37
  145. data/test/stripe/application_fee_test.rb +0 -58
  146. data/test/stripe/balance_test.rb +0 -13
  147. data/test/stripe/balance_transaction_test.rb +0 -20
  148. data/test/stripe/bank_account_test.rb +0 -36
  149. data/test/stripe/billing_portal/session_test.rb +0 -18
  150. data/test/stripe/capability_test.rb +0 -45
  151. data/test/stripe/charge_test.rb +0 -64
  152. data/test/stripe/checkout/session_test.rb +0 -53
  153. data/test/stripe/connection_manager_test.rb +0 -163
  154. data/test/stripe/country_spec_test.rb +0 -20
  155. data/test/stripe/coupon_test.rb +0 -61
  156. data/test/stripe/credit_note_test.rb +0 -90
  157. data/test/stripe/customer_balance_transaction_test.rb +0 -37
  158. data/test/stripe/customer_card_test.rb +0 -42
  159. data/test/stripe/customer_test.rb +0 -226
  160. data/test/stripe/dispute_test.rb +0 -51
  161. data/test/stripe/ephemeral_key_test.rb +0 -93
  162. data/test/stripe/errors_test.rb +0 -53
  163. data/test/stripe/exchange_rate_test.rb +0 -20
  164. data/test/stripe/file_link_test.rb +0 -41
  165. data/test/stripe/file_test.rb +0 -87
  166. data/test/stripe/instrumentation_test.rb +0 -74
  167. data/test/stripe/invoice_item_test.rb +0 -66
  168. data/test/stripe/invoice_line_item_test.rb +0 -8
  169. data/test/stripe/invoice_test.rb +0 -229
  170. data/test/stripe/issuing/authorization_test.rb +0 -72
  171. data/test/stripe/issuing/card_test.rb +0 -74
  172. data/test/stripe/issuing/cardholder_test.rb +0 -53
  173. data/test/stripe/issuing/dispute_test.rb +0 -35
  174. data/test/stripe/issuing/transaction_test.rb +0 -48
  175. data/test/stripe/list_object_test.rb +0 -202
  176. data/test/stripe/login_link_test.rb +0 -37
  177. data/test/stripe/mandate_test.rb +0 -14
  178. data/test/stripe/multipart_encoder_test.rb +0 -130
  179. data/test/stripe/oauth_test.rb +0 -104
  180. data/test/stripe/order_return_test.rb +0 -21
  181. data/test/stripe/order_test.rb +0 -82
  182. data/test/stripe/payment_intent_test.rb +0 -107
  183. data/test/stripe/payment_method_test.rb +0 -84
  184. data/test/stripe/payout_test.rb +0 -57
  185. data/test/stripe/person_test.rb +0 -46
  186. data/test/stripe/plan_test.rb +0 -98
  187. data/test/stripe/price_test.rb +0 -48
  188. data/test/stripe/product_test.rb +0 -59
  189. data/test/stripe/radar/early_fraud_warning_test.rb +0 -22
  190. data/test/stripe/radar/value_list_item_test.rb +0 -48
  191. data/test/stripe/radar/value_list_test.rb +0 -61
  192. data/test/stripe/recipient_test.rb +0 -62
  193. data/test/stripe/refund_test.rb +0 -39
  194. data/test/stripe/reporting/report_run_test.rb +0 -33
  195. data/test/stripe/reporting/report_type_test.rb +0 -22
  196. data/test/stripe/reversal_test.rb +0 -43
  197. data/test/stripe/review_test.rb +0 -27
  198. data/test/stripe/setup_intent_test.rb +0 -84
  199. data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
  200. data/test/stripe/sku_test.rb +0 -60
  201. data/test/stripe/source_test.rb +0 -119
  202. data/test/stripe/stripe_client_test.rb +0 -1291
  203. data/test/stripe/stripe_object_test.rb +0 -500
  204. data/test/stripe/stripe_response_test.rb +0 -95
  205. data/test/stripe/subscription_item_test.rb +0 -84
  206. data/test/stripe/subscription_schedule_test.rb +0 -82
  207. data/test/stripe/subscription_test.rb +0 -80
  208. data/test/stripe/tax_id_test.rb +0 -31
  209. data/test/stripe/tax_rate_test.rb +0 -43
  210. data/test/stripe/terminal/connection_token_test.rb +0 -16
  211. data/test/stripe/terminal/location_test.rb +0 -68
  212. data/test/stripe/terminal/reader_test.rb +0 -62
  213. data/test/stripe/three_d_secure_test.rb +0 -23
  214. data/test/stripe/topup_test.rb +0 -62
  215. data/test/stripe/transfer_test.rb +0 -88
  216. data/test/stripe/usage_record_summary_test.rb +0 -29
  217. data/test/stripe/util_test.rb +0 -402
  218. data/test/stripe/webhook_endpoint_test.rb +0 -59
  219. data/test/stripe/webhook_test.rb +0 -135
  220. data/test/stripe_mock.rb +0 -78
  221. data/test/stripe_test.rb +0 -50
  222. data/test/test_data.rb +0 -61
  223. data/test/test_helper.rb +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f512dbfd8ec9e22989c36487ae9e342331d79e3a2d29a247faa5e683874f6751
4
- data.tar.gz: 3ec2a701958afc3a5163bb980cb89608cf791df71d721394d21c8c05d25b8f86
3
+ metadata.gz: 7e81cc3af76a8942f879c1b312bbcc6ad27257cb9b68f9a63df76bd430ff9cf8
4
+ data.tar.gz: c83f7ae353941a10279ba76237f64e700f0e6bce06fe9475250b85308f72d57f
5
5
  SHA512:
6
- metadata.gz: 1376b1aab1ba28a97ce42bc1411a50f48997f54143ba70778cea3ff94600b57a2c93a3064d4c403cffcd917059bc954c3399a31a0ccf2d61b616d7b9d4e7b1d7
7
- data.tar.gz: 12104e8d2a4b2374fca5789980f55b728037213cce9e02c46a1bb3b296b0745e9c1dd9f875bda408b74288390c655d44df5ed7c87aa7fcb8d6eb98c571dcf140
6
+ metadata.gz: 4b4aff3650ae5933a0fae274bf1fe1e142f8361fbd0b3734502ce317a82492bda2124e155ff335b311abbda1d9751fdbc15e4a1754c94fe8b6d8a24e206b599e
7
+ data.tar.gz: f23307331d6ded3934361f9fff180a0ecda5df30bb3f5708e359d3b0712ed5262873b2220400d124544b113249a7ff5f1ae885cef381b9a8b3aa6388295527a7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,147 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.55.0 - 2022-05-05
4
+ * [#1055](https://github.com/stripe/stripe-ruby/pull/1055) API Updates
5
+ * Add support for new resources `FinancialConnections.AccountOwner`, `FinancialConnections.AccountOwnership`, `FinancialConnections.Account`, and `FinancialConnections.Session`
6
+
7
+
8
+ ## 5.54.0 - 2022-05-03
9
+ * [#1053](https://github.com/stripe/stripe-ruby/pull/1053) API Updates
10
+ * Add support for new resource `CashBalance`
11
+
12
+ ## 5.53.0 - 2022-04-21
13
+ * [#1050](https://github.com/stripe/stripe-ruby/pull/1050) API Updates
14
+ * Add support for `expire` test helper method on resource `Refund`
15
+
16
+ ## 5.52.0 - 2022-04-18
17
+ * [#1046](https://github.com/stripe/stripe-ruby/pull/1046) [#1047](https://github.com/stripe/stripe-ruby/pull/1047) API Updates
18
+ * Add support for new resources `FundingInstructions` and `Terminal.Configuration`
19
+
20
+ ## 5.51.0 - 2022-04-15
21
+ * [#1046](https://github.com/stripe/stripe-ruby/pull/1046) This release was incomplete and was yanked from RubyGems immediately after it was published.
22
+
23
+ ## 5.50.0 - 2022-04-13
24
+ * [#1045](https://github.com/stripe/stripe-ruby/pull/1045) API Updates
25
+ * Add support for `increment_authorization` method on resource `PaymentIntent`
26
+
27
+ ## 5.49.0 - 2022-04-08
28
+ * [#1043](https://github.com/stripe/stripe-ruby/pull/1043) API Updates
29
+ * Add support for `apply_customer_balance` method on resource `PaymentIntent`
30
+
31
+ ## 5.48.0 - 2022-03-30
32
+ * [#1041](https://github.com/stripe/stripe-ruby/pull/1041) API Updates
33
+ * Add support for `cancel_action`, `process_payment_intent`, `process_setup_intent`, and `set_reader_display` methods on resource `Terminal.Reader`
34
+
35
+ ## 5.47.0 - 2022-03-29
36
+ * [#1040](https://github.com/stripe/stripe-ruby/pull/1040) API Updates
37
+ * Add support for Search API
38
+ * Add support for `search` method on resources `Charge`, `Customer`, `Invoice`, `PaymentIntent`, `Price`, `Product`, and `Subscription`
39
+
40
+ * [#1034](https://github.com/stripe/stripe-ruby/pull/1034) Add supporting classes for test helper generation
41
+
42
+ ## 5.46.0 - 2022-03-23
43
+ * [#1039](https://github.com/stripe/stripe-ruby/pull/1039) API Updates
44
+ * Add support for `cancel` method on resource `Refund`
45
+ * [#992](https://github.com/stripe/stripe-ruby/pull/992) Add support for Search API
46
+
47
+ ## 5.45.0 - 2022-03-01
48
+ * [#1035](https://github.com/stripe/stripe-ruby/pull/1035) API Updates
49
+ * Add support for new resource `TestHelpers.TestClock`
50
+
51
+ ## 5.44.0 - 2022-02-16
52
+ * [#1032](https://github.com/stripe/stripe-ruby/pull/1032) API Updates
53
+ * Add support for `verify_microdeposits` method on resources `PaymentIntent` and `SetupIntent`
54
+
55
+ ## 5.43.0 - 2022-01-20
56
+ * [#1031](https://github.com/stripe/stripe-ruby/pull/1031) API Updates
57
+ * Add support for new resource `PaymentLink`
58
+
59
+ ## 5.42.0 - 2021-12-13
60
+ * [#1022](https://github.com/stripe/stripe-ruby/pull/1022) Add connection manager logging and include object IDs in logging.
61
+
62
+ ## 5.41.0 - 2021-11-16
63
+ * [#1017](https://github.com/stripe/stripe-ruby/pull/1017) API Updates
64
+ * Add support for new resource `ShippingRate`
65
+
66
+ ## 5.40.0 - 2021-11-11
67
+ * [#1015](https://github.com/stripe/stripe-ruby/pull/1015) API Updates
68
+ * Add support for `expire` method on resource `Checkout.Session`
69
+ * [#1013](https://github.com/stripe/stripe-ruby/pull/1013) Add tests for child resources.
70
+ * [#1012](https://github.com/stripe/stripe-ruby/pull/1012) Add tests for namespaced resources.
71
+ * [#1011](https://github.com/stripe/stripe-ruby/pull/1011) codegen: 3 more files
72
+
73
+ ## 5.39.0 - 2021-10-11
74
+ * [#1010](https://github.com/stripe/stripe-ruby/pull/1010) API Updates
75
+ * Add support for `list_payment_methods` method on resource `Customer`
76
+
77
+ ## 5.38.0 - 2021-08-10
78
+ * [#993](https://github.com/stripe/stripe-ruby/pull/993) Add `request_id` to RequestEndEvent
79
+ * [#991](https://github.com/stripe/stripe-ruby/pull/991) Codegen more files
80
+ * [#989](https://github.com/stripe/stripe-ruby/pull/989) Remove unused API error types from docs.
81
+
82
+ ## 5.37.0 - 2021-07-14
83
+ * [#988](https://github.com/stripe/stripe-ruby/pull/988) API Updates
84
+ * Add support for `list_computed_upfront_line_items` method on resource `Quote`
85
+
86
+ ## 5.36.0 - 2021-07-09
87
+ * [#987](https://github.com/stripe/stripe-ruby/pull/987) Add support for `Quote` API
88
+
89
+ ## 5.35.0 - 2021-06-30
90
+ * [#985](https://github.com/stripe/stripe-ruby/pull/985) Update normalize_opts to use dup instead of clone.
91
+ * [#982](https://github.com/stripe/stripe-ruby/pull/982) Deprecate travis
92
+ * [#983](https://github.com/stripe/stripe-ruby/pull/983) Add support for making a request and receiving the response as a stream.
93
+
94
+ ## 5.34.0 - 2021-06-04
95
+ * [#981](https://github.com/stripe/stripe-ruby/pull/981) API Updates
96
+ * Add support for `TaxCode` API.
97
+
98
+ ## 5.33.0 - 2021-05-19
99
+ * [#979](https://github.com/stripe/stripe-ruby/pull/979) Add support for the Identify VerificationSession and VerificationReport APIs
100
+
101
+ ## 5.32.1 - 2021-04-05
102
+ * Correct use of regexp `match` in gemspec for old versions of Ruby
103
+
104
+ ## 5.32.0 - 2021-04-05
105
+ * [#973](https://github.com/stripe/stripe-ruby/pull/973) Reduce packed gem size
106
+
107
+ ## 5.31.0 - 2021-04-02
108
+ * [#968](https://github.com/stripe/stripe-ruby/pull/968) Allow StripeClient to be configured per instance
109
+ * [#971](https://github.com/stripe/stripe-ruby/pull/971) On config change, only clear connection managers for changed config
110
+ * [#972](https://github.com/stripe/stripe-ruby/pull/972) Rename `Stripe.configuration` to `Stripe.config`
111
+ * [#970](https://github.com/stripe/stripe-ruby/pull/970) Reserve some critical field names when adding `StripeObject` accessors
112
+ * [#967](https://github.com/stripe/stripe-ruby/pull/967) CI: github actions
113
+
114
+ ## 5.30.0 - 2021-02-22
115
+ * [#965](https://github.com/stripe/stripe-ruby/pull/965) Add support for the Billing Portal Configuration API
116
+
117
+ ## 5.29.1 - 2021-02-09
118
+ * [#964](https://github.com/stripe/stripe-ruby/pull/964) Fix return value of `Customer#delete_discount`
119
+
120
+ ## 5.29.0 - 2021-01-05
121
+ * [#952](https://github.com/stripe/stripe-ruby/pull/952) Allow client_id configuration on instance config
122
+
123
+ ## 5.28.0 - 2020-10-14
124
+ * [#950](https://github.com/stripe/stripe-ruby/pull/950) Add configuration option for `write_timeout` for connections on Ruby 2.6+
125
+
126
+ ## 5.27.0 - 2020-10-14
127
+ * [#951](https://github.com/stripe/stripe-ruby/pull/951) Add support for the Payout Reverse API
128
+
129
+ ## 5.26.0 - 2020-09-29
130
+ * [#949](https://github.com/stripe/stripe-ruby/pull/949) Add support for the `SetupAttempt` resource and List API
131
+
132
+ ## 5.25.0 - 2020-09-02
133
+ * [#944](https://github.com/stripe/stripe-ruby/pull/944) Add support for the Issuing Dispute Submit API
134
+
135
+ ## 5.24.0 - 2020-08-26
136
+ * [#939](https://github.com/stripe/stripe-ruby/pull/939) Extract configurations into separate object
137
+ * [#940](https://github.com/stripe/stripe-ruby/pull/940) Fix typo in documentation of `stripe_object.rb`
138
+
139
+ ## 5.23.1 - 2020-08-05
140
+ * [#936](https://github.com/stripe/stripe-ruby/pull/936) Rename API resource's `request` method
141
+
142
+ ## 5.23.0 - 2020-08-05
143
+ * [#937](https://github.com/stripe/stripe-ruby/pull/937) Add support for the `PromotionCode` resource and APIs
144
+
3
145
  ## 5.22.0 - 2020-05-11
4
146
  * [#918](https://github.com/stripe/stripe-ruby/pull/918) Add support for the `LineItem` resource and APIs
5
147
 
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  group :development do
8
- gem "coveralls", require: false
9
8
  gem "mocha", "~> 0.13.2"
10
9
  gem "rack", ">= 2.0.6"
11
10
  gem "rake"
data/Makefile ADDED
@@ -0,0 +1,7 @@
1
+ .PHONY: update-version codegen-format
2
+ update-version:
3
+ @echo "$(VERSION)" > VERSION
4
+ @perl -pi -e 's|VERSION = "[.\d]+"|VERSION = "$(VERSION)"|' lib/stripe/version.rb
5
+
6
+ codegen-format:
7
+ bundle exec rubocop -o /dev/null --auto-correct
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/stripe.svg)](https://badge.fury.io/rb/stripe)
4
4
  [![Build Status](https://travis-ci.org/stripe/stripe-ruby.svg?branch=master)](https://travis-ci.org/stripe/stripe-ruby)
5
- [![Coverage Status](https://coveralls.io/repos/github/stripe/stripe-ruby/badge.svg?branch=master)](https://coveralls.io/github/stripe/stripe-ruby?branch=master)
6
5
 
7
6
  The Stripe Ruby library provides convenient access to the Stripe API from
8
7
  applications written in the Ruby language. It includes a pre-defined set of
@@ -19,7 +18,10 @@ The library also provides other features. For example:
19
18
 
20
19
  ## Documentation
21
20
 
22
- See the [Ruby API docs](https://stripe.com/docs/api/ruby#intro).
21
+ See the [Ruby API docs](https://stripe.com/docs/api?lang=ruby).
22
+
23
+ See [video demonstrations][youtube-playlist] covering how to use the library.
24
+
23
25
 
24
26
  ## Installation
25
27
 
@@ -60,14 +62,14 @@ available in your [Stripe Dashboard][api-keys]. Set `Stripe.api_key` to its
60
62
  value:
61
63
 
62
64
  ```ruby
63
- require "stripe"
64
- Stripe.api_key = "sk_test_..."
65
+ require 'stripe'
66
+ Stripe.api_key = 'sk_test_...'
65
67
 
66
68
  # list customers
67
69
  Stripe::Customer.list()
68
70
 
69
71
  # retrieve single customer
70
- Stripe::Customer.retrieve("cus_123456789")
72
+ Stripe::Customer.retrieve('cus_123456789')
71
73
  ```
72
74
 
73
75
  ### Per-request Configuration
@@ -82,38 +84,38 @@ require "stripe"
82
84
  Stripe::Customer.list(
83
85
  {},
84
86
  {
85
- api_key: "sk_test_...",
86
- stripe_account: "acct_...",
87
- stripe_version: "2018-02-28",
87
+ api_key: 'sk_test_...',
88
+ stripe_account: 'acct_...',
89
+ stripe_version: '2018-02-28',
88
90
  }
89
91
  )
90
92
 
91
93
  Stripe::Customer.retrieve(
92
- "cus_123456789",
94
+ 'cus_123456789',
93
95
  {
94
- api_key: "sk_test_...",
95
- stripe_account: "acct_...",
96
- stripe_version: "2018-02-28",
96
+ api_key: 'sk_test_...',
97
+ stripe_account: 'acct_...',
98
+ stripe_version: '2018-02-28',
97
99
  }
98
100
  )
99
101
 
100
102
  Stripe::Customer.retrieve(
101
103
  {
102
- id: "cus_123456789",
104
+ id: 'cus_123456789',
103
105
  expand: %w(balance_transaction)
104
106
  },
105
107
  {
106
- stripe_version: "2018-02-28",
107
- api_key: "sk_test_...",
108
+ stripe_version: '2018-02-28',
109
+ api_key: 'sk_test_...',
108
110
  }
109
111
  )
110
112
 
111
113
  Stripe::Customer.capture(
112
- "cus_123456789",
114
+ 'cus_123456789',
113
115
  {},
114
116
  {
115
- stripe_version: "2018-02-28",
116
- api_key: "sk_test_...",
117
+ stripe_version: '2018-02-28',
118
+ api_key: 'sk_test_...',
117
119
  }
118
120
  )
119
121
  ```
@@ -136,7 +138,7 @@ method:
136
138
  ```ruby
137
139
  client = Stripe::StripeClient.new
138
140
  customer, resp = client.request do
139
- Stripe::Customer.retrieve("cus_123456789",)
141
+ Stripe::Customer.retrieve('cus_123456789',)
140
142
  end
141
143
  puts resp.request_id
142
144
  ```
@@ -146,7 +148,7 @@ puts resp.request_id
146
148
  A proxy can be configured with `Stripe.proxy`:
147
149
 
148
150
  ```ruby
149
- Stripe.proxy = "https://user:pass@example.com:1234"
151
+ Stripe.proxy = 'https://user:pass@example.com:1234'
150
152
  ```
151
153
 
152
154
  ### Configuring an API Version
@@ -155,7 +157,7 @@ By default, the library will use the API version pinned to the account making
155
157
  a request. This can be overridden with this global option:
156
158
 
157
159
  ```ruby
158
- Stripe.api_version = "2018-02-28"
160
+ Stripe.api_version = '2018-02-28'
159
161
  ```
160
162
 
161
163
  See [versioning in the API reference][versioning] for more information.
@@ -166,7 +168,7 @@ By default, the library will use its own internal bundle of known CA
166
168
  certificates, but it's possible to configure your own:
167
169
 
168
170
  ```ruby
169
- Stripe.ca_bundle_path = "path/to/ca/bundle"
171
+ Stripe.ca_bundle_path = 'path/to/ca/bundle'
170
172
  ```
171
173
 
172
174
  ### Configuring Automatic Retries
@@ -186,11 +188,12 @@ retries are safe.
186
188
 
187
189
  ### Configuring Timeouts
188
190
 
189
- Open and read timeouts are configurable:
191
+ Open, read and write timeouts are configurable:
190
192
 
191
193
  ```ruby
192
194
  Stripe.open_timeout = 30 # in seconds
193
195
  Stripe.read_timeout = 80
196
+ Stripe.write_timeout = 30 # only supported on Ruby 2.6+
194
197
  ```
195
198
 
196
199
  Please take care to set conservative read timeouts. Some API requests can take
@@ -249,6 +252,7 @@ a success or error. Receives `RequestEndEvent` with the following properties:
249
252
  - `path`: Request path. (`String`)
250
253
  - `user_data`: A hash on which users may have set arbitrary data in
251
254
  `request_begin`. See above for more information. (`Hash`)
255
+ - `request_id`. HTTP request identifier.
252
256
 
253
257
  #### Example
254
258
 
@@ -258,7 +262,7 @@ For example:
258
262
  Stripe::Instrumentation.subscribe(:request_end) do |request_event|
259
263
  tags = {
260
264
  method: request_event.method,
261
- resource: request_event.path.split("/")[2],
265
+ resource: request_event.path.split('/')[2],
262
266
  code: request_event.http_status,
263
267
  retries: request_event.num_retries
264
268
  }
@@ -272,7 +276,7 @@ If you're writing a plugin that uses the library, we'd appreciate it if you
272
276
  identified using `#set_app_info`:
273
277
 
274
278
  ```ruby
275
- Stripe.set_app_info("MyAwesomePlugin", version: "1.2.34", url: "https://myawesomeplugin.info");
279
+ Stripe.set_app_info('MyAwesomePlugin', version: '1.2.34', url: 'https://myawesomeplugin.info')
276
280
  ```
277
281
 
278
282
  This information is passed along when the library makes calls to the Stripe
@@ -336,9 +340,10 @@ Update the bundled [stripe-mock] by editing the version number found in
336
340
  [api-keys]: https://dashboard.stripe.com/account/apikeys
337
341
  [connect]: https://stripe.com/connect
338
342
  [curl]: http://curl.haxx.se/docs/caextract.html
339
- [idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
343
+ [idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=ruby
340
344
  [stripe-mock]: https://github.com/stripe/stripe-mock
341
- [versioning]: https://stripe.com/docs/api/ruby#versioning
345
+ [versioning]: https://stripe.com/docs/api/versioning?lang=ruby
346
+ [youtube-playlist]: https://www.youtube.com/playlist?list=PLy1nL-pvL2M50RmP6ie-gdcSnfOuQCRYk
342
347
 
343
348
  <!--
344
349
  # vim: set tw=79:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.22.0
1
+ 5.55.0
@@ -4,7 +4,7 @@ module Stripe
4
4
  module APIOperations
5
5
  module Create
6
6
  def create(params = {}, opts = {})
7
- resp, opts = request(:post, resource_url, params, opts)
7
+ resp, opts = execute_resource_request(:post, resource_url, params, opts)
8
8
  Util.convert_to_stripe_object(resp.data, opts)
9
9
  end
10
10
  end
@@ -15,15 +15,19 @@ module Stripe
15
15
  # * +opts+ - A Hash of additional options (separate from the params /
16
16
  # object values) to be added to the request. E.g. to allow for an
17
17
  # idempotency_key to be passed in the request headers, or for the
18
- # api_key to be overwritten. See {APIOperations::Request.request}.
18
+ # api_key to be overwritten. See
19
+ # {APIOperations::Request.execute_resource_request}.
19
20
  def delete(id, params = {}, opts = {})
20
- resp, opts = request(:delete, "#{resource_url}/#{id}", params, opts)
21
+ resp, opts = execute_resource_request(:delete,
22
+ "#{resource_url}/#{id}",
23
+ params, opts)
21
24
  Util.convert_to_stripe_object(resp.data, opts)
22
25
  end
23
26
  end
24
27
 
25
28
  def delete(params = {}, opts = {})
26
- resp, opts = request(:delete, resource_url, params, opts)
29
+ resp, opts = execute_resource_request(:delete, resource_url,
30
+ params, opts)
27
31
  initialize_from(resp.data, opts)
28
32
  end
29
33
 
@@ -6,7 +6,7 @@ module Stripe
6
6
  def list(filters = {}, opts = {})
7
7
  opts = Util.normalize_opts(opts)
8
8
 
9
- resp, opts = request(:get, resource_url, filters, opts)
9
+ resp, opts = execute_resource_request(:get, resource_url, filters, opts)
10
10
  obj = ListObject.construct_from(resp.data, opts)
11
11
 
12
12
  # set filters so that we can fetch the same limit, expansions, and
@@ -31,35 +31,36 @@ module Stripe
31
31
  define_singleton_method(:"create_#{resource}") \
32
32
  do |id, params = {}, opts = {}|
33
33
  url = send(resource_url_method, id)
34
- resp, opts = request(:post, url, params, opts)
34
+ resp, opts = execute_resource_request(:post, url, params, opts)
35
35
  Util.convert_to_stripe_object(resp.data, opts)
36
36
  end
37
37
  when :retrieve
38
38
  define_singleton_method(:"retrieve_#{resource}") \
39
39
  do |id, nested_id, opts = {}|
40
40
  url = send(resource_url_method, id, nested_id)
41
- resp, opts = request(:get, url, {}, opts)
41
+ resp, opts = execute_resource_request(:get, url, {}, opts)
42
42
  Util.convert_to_stripe_object(resp.data, opts)
43
43
  end
44
44
  when :update
45
45
  define_singleton_method(:"update_#{resource}") \
46
46
  do |id, nested_id, params = {}, opts = {}|
47
47
  url = send(resource_url_method, id, nested_id)
48
- resp, opts = request(:post, url, params, opts)
48
+ resp, opts = execute_resource_request(:post, url, params, opts)
49
49
  Util.convert_to_stripe_object(resp.data, opts)
50
50
  end
51
51
  when :delete
52
52
  define_singleton_method(:"delete_#{resource}") \
53
53
  do |id, nested_id, params = {}, opts = {}|
54
54
  url = send(resource_url_method, id, nested_id)
55
- resp, opts = request(:delete, url, params, opts)
55
+ resp, opts = execute_resource_request(:delete, url, params,
56
+ opts)
56
57
  Util.convert_to_stripe_object(resp.data, opts)
57
58
  end
58
59
  when :list
59
60
  define_singleton_method(:"list_#{resource_plural}") \
60
61
  do |id, params = {}, opts = {}|
61
62
  url = send(resource_url_method, id)
62
- resp, opts = request(:get, url, params, opts)
63
+ resp, opts = execute_resource_request(:get, url, params, opts)
63
64
  Util.convert_to_stripe_object(resp.data, opts)
64
65
  end
65
66
  else
@@ -4,7 +4,30 @@ module Stripe
4
4
  module APIOperations
5
5
  module Request
6
6
  module ClassMethods
7
- def request(method, url, params = {}, opts = {})
7
+ def execute_resource_request(method, url,
8
+ params = {}, opts = {})
9
+ execute_resource_request_internal(
10
+ :execute_request, method, url, params, opts
11
+ )
12
+ end
13
+
14
+ def execute_resource_request_stream(method, url,
15
+ params = {}, opts = {},
16
+ &read_body_chunk_block)
17
+ execute_resource_request_internal(
18
+ :execute_request_stream,
19
+ method,
20
+ url,
21
+ params,
22
+ opts,
23
+ &read_body_chunk_block
24
+ )
25
+ end
26
+
27
+ private def execute_resource_request_internal(client_request_method_sym,
28
+ method, url,
29
+ params, opts,
30
+ &read_body_chunk_block)
8
31
  params ||= {}
9
32
 
10
33
  error_on_invalid_params(params)
@@ -21,10 +44,12 @@ module Stripe
21
44
  client = headers.delete(:client)
22
45
  # Assume all remaining opts must be headers
23
46
 
24
- resp, opts[:api_key] = client.execute_request(
47
+ resp, opts[:api_key] = client.send(
48
+ client_request_method_sym,
25
49
  method, url,
26
50
  api_base: api_base, api_key: api_key,
27
- headers: headers, params: params
51
+ headers: headers, params: params,
52
+ &read_body_chunk_block
28
53
  )
29
54
 
30
55
  # Hash#select returns an array before 1.9
@@ -36,6 +61,17 @@ module Stripe
36
61
  [resp, opts_to_persist]
37
62
  end
38
63
 
64
+ # This method used to be called `request`, but it's such a short name
65
+ # that it eventually conflicted with the name of a field on an API
66
+ # resource (specifically, `Event#request`), so it was renamed to
67
+ # something more unique.
68
+ #
69
+ # The former name had been around for just about forever though, and
70
+ # although all internal uses have been renamed, I've left this alias in
71
+ # place for backwards compatibility. Consider removing it on the next
72
+ # major.
73
+ alias request execute_resource_request
74
+
39
75
  private def error_on_non_string_user_opts(opts)
40
76
  Util::OPTS_USER_SPECIFIED.each do |opt|
41
77
  next unless opts.key?(opt)
@@ -71,10 +107,23 @@ module Stripe
71
107
  base.extend(ClassMethods)
72
108
  end
73
109
 
74
- protected def request(method, url, params = {}, opts = {})
110
+ protected def execute_resource_request(method, url,
111
+ params = {}, opts = {})
75
112
  opts = @opts.merge(Util.normalize_opts(opts))
76
- self.class.request(method, url, params, opts)
113
+ self.class.execute_resource_request(method, url, params, opts)
77
114
  end
115
+
116
+ protected def execute_resource_request_stream(method, url,
117
+ params = {}, opts = {},
118
+ &read_body_chunk_block)
119
+ opts = @opts.merge(Util.normalize_opts(opts))
120
+ self.class.execute_resource_request_stream(
121
+ method, url, params, opts, &read_body_chunk_block
122
+ )
123
+ end
124
+
125
+ # See notes on `alias` above.
126
+ alias request execute_resource_request
78
127
  end
79
128
  end
80
129
  end
@@ -15,7 +15,8 @@ module Stripe
15
15
  # * +opts+ - A Hash of additional options (separate from the params /
16
16
  # object values) to be added to the request. E.g. to allow for an
17
17
  # idempotency_key to be passed in the request headers, or for the
18
- # api_key to be overwritten. See {APIOperations::Request.request}.
18
+ # api_key to be overwritten. See
19
+ # {APIOperations::Request.execute_resource_request}.
19
20
  def update(id, params = {}, opts = {})
20
21
  params.each_key do |k|
21
22
  if protected_fields.include?(k)
@@ -23,7 +24,8 @@ module Stripe
23
24
  end
24
25
  end
25
26
 
26
- resp, opts = request(:post, "#{resource_url}/#{id}", params, opts)
27
+ resp, opts = execute_resource_request(:post, "#{resource_url}/#{id}",
28
+ params, opts)
27
29
  Util.convert_to_stripe_object(resp.data, opts)
28
30
  end
29
31
  end
@@ -43,7 +45,8 @@ module Stripe
43
45
  # * +opts+ - A Hash of additional options (separate from the params /
44
46
  # object values) to be added to the request. E.g. to allow for an
45
47
  # idempotency_key to be passed in the request headers, or for the
46
- # api_key to be overwritten. See {APIOperations::Request.request}.
48
+ # api_key to be overwritten. See
49
+ # {APIOperations::Request.execute_resource_request}.
47
50
  def save(params = {}, opts = {})
48
51
  # We started unintentionally (sort of) allowing attributes sent to
49
52
  # +save+ to override values used during the update. So as not to break
@@ -59,7 +62,7 @@ module Stripe
59
62
  # generated a uri for this object with an identifier baked in
60
63
  values.delete(:id)
61
64
 
62
- resp, opts = request(:post, save_url, values, opts)
65
+ resp, opts = execute_resource_request(:post, save_url, values, opts)
63
66
  initialize_from(resp.data, opts)
64
67
  end
65
68
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ module APIOperations
5
+ module Search
6
+ def _search(search_url, filters = {}, opts = {})
7
+ opts = Util.normalize_opts(opts)
8
+
9
+ resp, opts = execute_resource_request(:get, search_url, filters, opts)
10
+ obj = SearchResultObject.construct_from(resp.data, opts)
11
+
12
+ # set filters so that we can fetch the same limit and query
13
+ # when accessing the next page
14
+ obj.filters = filters.dup
15
+ obj
16
+ end
17
+ end
18
+ end
19
+ end
@@ -63,22 +63,7 @@ module Stripe
63
63
  # adds a `capture` class method to the resource class that, when called,
64
64
  # will send a POST request to `/v1/<object_name>/capture`.
65
65
  def self.custom_method(name, http_verb:, http_path: nil)
66
- unless %i[get post delete].include?(http_verb)
67
- raise ArgumentError,
68
- "Invalid http_verb value: #{http_verb.inspect}. Should be one " \
69
- "of :get, :post or :delete."
70
- end
71
- http_path ||= name.to_s
72
- define_singleton_method(name) do |id, params = {}, opts = {}|
73
- unless id.is_a?(String)
74
- raise ArgumentError,
75
- "id should be a string representing the ID of an API resource"
76
- end
77
-
78
- url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
79
- resp, opts = request(http_verb, url, params, opts)
80
- Util.convert_to_stripe_object(resp.data, opts)
81
- end
66
+ Util.custom_method self, self, name, http_verb, http_path
82
67
  end
83
68
 
84
69
  def resource_url
@@ -93,7 +78,8 @@ module Stripe
93
78
  end
94
79
 
95
80
  def refresh
96
- resp, opts = request(:get, resource_url, @retrieve_params)
81
+ resp, opts = execute_resource_request(:get, resource_url,
82
+ @retrieve_params)
97
83
  initialize_from(resp.data, opts)
98
84
  end
99
85
 
@@ -104,8 +90,8 @@ module Stripe
104
90
  instance
105
91
  end
106
92
 
107
- protected def request_stripe_object(method:, path:, params:, opts: {})
108
- resp, opts = request(method, path, params, opts)
93
+ def request_stripe_object(method:, path:, params:, opts: {})
94
+ resp, opts = execute_resource_request(method, path, params, opts)
109
95
 
110
96
  # If we're getting back this thing, update; otherwise, instantiate.
111
97
  if Util.object_name_matches_class?(resp.data[:object], self.class)
@@ -114,5 +100,13 @@ module Stripe
114
100
  Util.convert_to_stripe_object(resp.data, opts)
115
101
  end
116
102
  end
103
+
104
+ protected def request_stream(method:, path:, params:, opts: {},
105
+ &read_body_chunk_block)
106
+ resp, = execute_resource_request_stream(
107
+ method, path, params, opts, &read_body_chunk_block
108
+ )
109
+ resp
110
+ end
117
111
  end
118
112
  end