stripe 3.2.0 → 5.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +10 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +80 -0
- data/.rubocop_todo.yml +33 -0
- data/.travis.yml +9 -7
- data/.vscode/extensions.json +7 -0
- data/.vscode/settings.json +8 -0
- data/CHANGELOG.md +876 -0
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +21 -21
- data/History.txt +1 -678
- data/README.md +195 -53
- data/Rakefile +18 -12
- data/VERSION +1 -1
- data/bin/stripe-console +5 -3
- data/lib/stripe/api_operations/create.rb +3 -1
- data/lib/stripe/api_operations/delete.rb +26 -2
- data/lib/stripe/api_operations/list.rb +3 -12
- data/lib/stripe/api_operations/nested_resource.rb +72 -0
- data/lib/stripe/api_operations/request.rb +33 -15
- data/lib/stripe/api_operations/save.rb +18 -9
- data/lib/stripe/api_resource.rb +60 -10
- data/lib/stripe/connection_manager.rb +159 -0
- data/lib/stripe/error_object.rb +94 -0
- data/lib/stripe/errors.rb +39 -19
- data/lib/stripe/instrumentation.rb +82 -0
- data/lib/stripe/list_object.rb +54 -22
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/oauth.rb +22 -14
- data/lib/stripe/object_types.rb +96 -0
- data/lib/stripe/{account.rb → resources/account.rb} +72 -34
- data/lib/stripe/resources/account_link.rb +9 -0
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +4 -2
- data/lib/stripe/resources/application_fee.rb +13 -0
- data/lib/stripe/resources/application_fee_refund.rb +30 -0
- data/lib/stripe/{balance.rb → resources/balance.rb} +3 -1
- data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +3 -5
- data/lib/stripe/resources/bank_account.rb +42 -0
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +6 -5
- data/lib/stripe/resources/bitcoin_transaction.rb +15 -0
- data/lib/stripe/resources/capability.rb +33 -0
- data/lib/stripe/resources/card.rb +37 -0
- data/lib/stripe/resources/charge.rb +22 -0
- data/lib/stripe/resources/checkout/session.rb +12 -0
- data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +3 -5
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +4 -2
- data/lib/stripe/resources/credit_note.rb +32 -0
- data/lib/stripe/resources/credit_note_line_item.rb +7 -0
- data/lib/stripe/resources/customer.rb +35 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +30 -0
- data/lib/stripe/resources/discount.rb +7 -0
- data/lib/stripe/resources/dispute.rb +21 -0
- data/lib/stripe/resources/ephemeral_key.rb +19 -0
- data/lib/stripe/{event.rb → resources/event.rb} +3 -1
- data/lib/stripe/resources/exchange_rate.rb +9 -0
- data/lib/stripe/resources/file.rb +34 -0
- data/lib/stripe/resources/file_link.rb +11 -0
- data/lib/stripe/resources/invoice.rb +73 -0
- data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +4 -2
- data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +3 -1
- data/lib/stripe/resources/issuing/authorization.rb +33 -0
- data/lib/stripe/resources/issuing/card.rb +24 -0
- data/lib/stripe/resources/issuing/card_details.rb +9 -0
- data/lib/stripe/resources/issuing/cardholder.rb +13 -0
- data/lib/stripe/resources/issuing/dispute.rb +13 -0
- data/lib/stripe/resources/issuing/transaction.rb +12 -0
- data/lib/stripe/resources/login_link.rb +14 -0
- data/lib/stripe/resources/mandate.rb +7 -0
- data/lib/stripe/resources/order.rb +32 -0
- data/lib/stripe/{order_return.rb → resources/order_return.rb} +3 -5
- data/lib/stripe/resources/payment_intent.rb +42 -0
- data/lib/stripe/resources/payment_method.rb +32 -0
- data/lib/stripe/resources/payout.rb +22 -0
- data/lib/stripe/resources/person.rb +31 -0
- data/lib/stripe/{plan.rb → resources/plan.rb} +3 -1
- data/lib/stripe/{product.rb → resources/product.rb} +5 -3
- data/lib/stripe/resources/radar/early_fraud_warning.rb +11 -0
- data/lib/stripe/resources/radar/value_list.rb +14 -0
- data/lib/stripe/resources/radar/value_list_item.rb +13 -0
- data/lib/stripe/{recipient.rb → resources/recipient.rb} +5 -6
- data/lib/stripe/resources/recipient_transfer.rb +7 -0
- data/lib/stripe/{refund.rb → resources/refund.rb} +3 -1
- data/lib/stripe/resources/reporting/report_run.rb +12 -0
- data/lib/stripe/resources/reporting/report_type.rb +12 -0
- data/lib/stripe/resources/reversal.rb +29 -0
- data/lib/stripe/resources/review.rb +20 -0
- data/lib/stripe/resources/setup_intent.rb +32 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +15 -0
- data/lib/stripe/{sku.rb → resources/sku.rb} +5 -3
- data/lib/stripe/resources/source.rb +46 -0
- data/lib/stripe/resources/source_transaction.rb +7 -0
- data/lib/stripe/resources/subscription.rb +25 -0
- data/lib/stripe/resources/subscription_item.rb +25 -0
- data/lib/stripe/resources/subscription_schedule.rb +32 -0
- data/lib/stripe/resources/tax_id.rb +26 -0
- data/lib/stripe/resources/tax_rate.rb +11 -0
- data/lib/stripe/resources/terminal/connection_token.rb +11 -0
- data/lib/stripe/resources/terminal/location.rb +14 -0
- data/lib/stripe/resources/terminal/reader.rb +14 -0
- data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +3 -1
- data/lib/stripe/{token.rb → resources/token.rb} +3 -1
- data/lib/stripe/resources/topup.rb +22 -0
- data/lib/stripe/resources/transfer.rb +26 -0
- data/lib/stripe/resources/usage_record.rb +7 -0
- data/lib/stripe/resources/usage_record_summary.rb +7 -0
- data/lib/stripe/resources/webhook_endpoint.rb +12 -0
- data/lib/stripe/resources.rb +79 -0
- data/lib/stripe/singleton_api_resource.rb +10 -4
- data/lib/stripe/stripe_client.rb +658 -337
- data/lib/stripe/stripe_object.rb +248 -126
- data/lib/stripe/stripe_response.rb +55 -21
- data/lib/stripe/util.rb +145 -187
- data/lib/stripe/version.rb +3 -1
- data/lib/stripe/webhook.rb +27 -16
- data/lib/stripe.rb +139 -90
- data/stripe.gemspec +26 -14
- data/test/openapi/README.md +9 -0
- data/test/stripe/account_link_test.rb +18 -0
- data/test/stripe/account_test.rb +311 -101
- data/test/stripe/alipay_account_test.rb +21 -1
- data/test/stripe/api_operations_test.rb +57 -8
- data/test/stripe/api_resource_test.rb +359 -271
- data/test/stripe/apple_pay_domain_test.rb +26 -11
- data/test/stripe/application_fee_refund_test.rb +10 -8
- data/test/stripe/application_fee_test.rb +49 -3
- data/test/stripe/balance_test.rb +4 -2
- data/test/stripe/balance_transaction_test.rb +20 -0
- data/test/stripe/bank_account_test.rb +11 -11
- data/test/stripe/capability_test.rb +45 -0
- data/test/stripe/charge_test.rb +25 -18
- data/test/stripe/checkout/session_test.rb +41 -0
- data/test/stripe/connection_manager_test.rb +163 -0
- data/test/stripe/country_spec_test.rb +6 -4
- data/test/stripe/coupon_test.rb +29 -10
- data/test/stripe/credit_note_test.rb +90 -0
- data/test/stripe/customer_balance_transaction_test.rb +37 -0
- data/test/stripe/customer_card_test.rb +13 -17
- data/test/stripe/customer_test.rb +161 -49
- data/test/stripe/dispute_test.rb +19 -8
- data/test/stripe/ephemeral_key_test.rb +23 -14
- data/test/stripe/errors_test.rb +32 -9
- data/test/stripe/exchange_rate_test.rb +20 -0
- data/test/stripe/file_link_test.rb +41 -0
- data/test/stripe/file_test.rb +87 -0
- data/test/stripe/instrumentation_test.rb +74 -0
- data/test/stripe/invoice_item_test.rb +31 -18
- data/test/stripe/invoice_line_item_test.rb +3 -1
- data/test/stripe/invoice_test.rb +158 -39
- data/test/stripe/issuing/authorization_test.rb +72 -0
- data/test/stripe/issuing/card_test.rb +62 -0
- data/test/stripe/issuing/cardholder_test.rb +53 -0
- data/test/stripe/issuing/dispute_test.rb +45 -0
- data/test/stripe/issuing/transaction_test.rb +48 -0
- data/test/stripe/list_object_test.rb +120 -88
- data/test/stripe/login_link_test.rb +16 -14
- data/test/stripe/mandate_test.rb +14 -0
- data/test/stripe/multipart_encoder_test.rb +130 -0
- data/test/stripe/oauth_test.rb +69 -50
- data/test/stripe/order_return_test.rb +7 -5
- data/test/stripe/order_test.rb +39 -14
- data/test/stripe/payment_intent_test.rb +107 -0
- data/test/stripe/payment_method_test.rb +84 -0
- data/test/stripe/payout_test.rb +18 -9
- data/test/stripe/person_test.rb +46 -0
- data/test/stripe/plan_test.rb +67 -19
- data/test/stripe/product_test.rb +28 -14
- data/test/stripe/radar/early_fraud_warning_test.rb +22 -0
- data/test/stripe/radar/value_list_item_test.rb +48 -0
- data/test/stripe/radar/value_list_test.rb +61 -0
- data/test/stripe/recipient_test.rb +27 -13
- data/test/stripe/refund_test.rb +11 -9
- data/test/stripe/reporting/report_run_test.rb +33 -0
- data/test/stripe/reporting/report_type_test.rb +22 -0
- data/test/stripe/reversal_test.rb +12 -10
- data/test/stripe/review_test.rb +27 -0
- data/test/stripe/setup_intent_test.rb +84 -0
- data/test/stripe/sigma/scheduled_query_run_test.rb +22 -0
- data/test/stripe/sku_test.rb +24 -12
- data/test/stripe/source_test.rb +70 -19
- data/test/stripe/stripe_client_test.rb +867 -326
- data/test/stripe/stripe_object_test.rb +284 -182
- data/test/stripe/stripe_response_test.rb +73 -24
- data/test/stripe/subscription_item_test.rb +47 -15
- data/test/stripe/subscription_schedule_test.rb +82 -0
- data/test/stripe/subscription_test.rb +41 -19
- data/test/stripe/tax_id_test.rb +31 -0
- data/test/stripe/tax_rate_test.rb +43 -0
- data/test/stripe/terminal/connection_token_test.rb +16 -0
- data/test/stripe/terminal/location_test.rb +68 -0
- data/test/stripe/terminal/reader_test.rb +62 -0
- data/test/stripe/three_d_secure_test.rb +4 -2
- data/test/stripe/topup_test.rb +62 -0
- data/test/stripe/transfer_test.rb +55 -8
- data/test/stripe/usage_record_summary_test.rb +29 -0
- data/test/stripe/util_test.rb +173 -84
- data/test/stripe/webhook_endpoint_test.rb +59 -0
- data/test/stripe/webhook_test.rb +21 -17
- data/test/stripe_mock.rb +78 -0
- data/test/stripe_test.rb +6 -15
- data/test/test_data.rb +28 -26
- data/test/test_helper.rb +48 -29
- metadata +183 -70
- data/lib/stripe/alipay_account.rb +0 -22
- data/lib/stripe/application_fee.rb +0 -22
- data/lib/stripe/application_fee_refund.rb +0 -20
- data/lib/stripe/bank_account.rb +0 -30
- data/lib/stripe/bitcoin_transaction.rb +0 -11
- data/lib/stripe/card.rb +0 -27
- data/lib/stripe/charge.rb +0 -82
- data/lib/stripe/customer.rb +0 -79
- data/lib/stripe/dispute.rb +0 -17
- data/lib/stripe/ephemeral_key.rb +0 -18
- data/lib/stripe/file_upload.rb +0 -33
- data/lib/stripe/invoice.rb +0 -29
- data/lib/stripe/login_link.rb +0 -9
- data/lib/stripe/order.rb +0 -29
- data/lib/stripe/payout.rb +0 -18
- data/lib/stripe/recipient_transfer.rb +0 -6
- data/lib/stripe/reversal.rb +0 -20
- data/lib/stripe/source.rb +0 -23
- data/lib/stripe/subscription.rb +0 -33
- data/lib/stripe/subscription_item.rb +0 -14
- data/lib/stripe/transfer.rb +0 -18
- data/test/api_stub_helpers.rb +0 -0
- data/test/stripe/bitcoin_receiver_test.rb +0 -67
- data/test/stripe/bitcoin_transaction_test.rb +0 -19
- data/test/stripe/file_upload_test.rb +0 -66
- data/test/stripe/recipient_card_test.rb +0 -44
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
module Issuing
|
7
|
+
class CardTest < Test::Unit::TestCase
|
8
|
+
should "be creatable" do
|
9
|
+
card = Stripe::Issuing::Card.create(
|
10
|
+
currency: "usd",
|
11
|
+
type: "physical"
|
12
|
+
)
|
13
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/cards"
|
14
|
+
assert card.is_a?(Stripe::Issuing::Card)
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be listable" do
|
18
|
+
cards = Stripe::Issuing::Card.list
|
19
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cards"
|
20
|
+
assert cards.data.is_a?(Array)
|
21
|
+
assert cards.data[0].is_a?(Stripe::Issuing::Card)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "be retrievable" do
|
25
|
+
card = Stripe::Issuing::Card.retrieve("ic_123")
|
26
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cards/ic_123"
|
27
|
+
assert card.is_a?(Stripe::Issuing::Card)
|
28
|
+
end
|
29
|
+
|
30
|
+
should "be saveable" do
|
31
|
+
card = Stripe::Issuing::Card.retrieve("ic_123")
|
32
|
+
card.metadata["key"] = "value"
|
33
|
+
card.save
|
34
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/cards/ic_123"
|
35
|
+
assert card.is_a?(Stripe::Issuing::Card)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "be updateable" do
|
39
|
+
card = Stripe::Issuing::Card.update("ic_123", metadata: { foo: "bar" })
|
40
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/cards/ic_123"
|
41
|
+
assert card.is_a?(Stripe::Issuing::Card)
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#details" do
|
45
|
+
should "retrieve a card's details" do
|
46
|
+
card_details = Stripe::Issuing::Card.details("ic_123")
|
47
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cards/ic_123/details"
|
48
|
+
assert card_details.is_a?(Stripe::Issuing::CardDetails)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context ".details" do
|
53
|
+
should "retrieve a card's details" do
|
54
|
+
card = Stripe::Issuing::Card.retrieve("ic_123")
|
55
|
+
card_details = card.details
|
56
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cards/ic_123/details"
|
57
|
+
assert card_details.is_a?(Stripe::Issuing::CardDetails)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
module Issuing
|
7
|
+
class CardholderTest < Test::Unit::TestCase
|
8
|
+
should "be creatable" do
|
9
|
+
cardholder = Stripe::Issuing::Cardholder.create(
|
10
|
+
billing: {
|
11
|
+
address: {
|
12
|
+
city: "city",
|
13
|
+
country: "US",
|
14
|
+
line1: "line1",
|
15
|
+
postal_code: "postal_code",
|
16
|
+
},
|
17
|
+
},
|
18
|
+
name: "Jenny Rosen",
|
19
|
+
type: "individual"
|
20
|
+
)
|
21
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/cardholders"
|
22
|
+
assert cardholder.is_a?(Stripe::Issuing::Cardholder)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "be listable" do
|
26
|
+
cardholders = Stripe::Issuing::Cardholder.list
|
27
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cardholders"
|
28
|
+
assert cardholders.data.is_a?(Array)
|
29
|
+
assert cardholders.data[0].is_a?(Stripe::Issuing::Cardholder)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "be retrievable" do
|
33
|
+
cardholder = Stripe::Issuing::Cardholder.retrieve("ich_123")
|
34
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cardholders/ich_123"
|
35
|
+
assert cardholder.is_a?(Stripe::Issuing::Cardholder)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "be saveable" do
|
39
|
+
cardholder = Stripe::Issuing::Cardholder.retrieve("ich_123")
|
40
|
+
cardholder.metadata["key"] = "value"
|
41
|
+
cardholder.save
|
42
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/cardholders/#{cardholder.id}"
|
43
|
+
assert cardholder.is_a?(Stripe::Issuing::Cardholder)
|
44
|
+
end
|
45
|
+
|
46
|
+
should "be updateable" do
|
47
|
+
cardholder = Stripe::Issuing::Cardholder.update("ich_123", metadata: { foo: "bar" })
|
48
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/cardholders/ich_123"
|
49
|
+
assert cardholder.is_a?(Stripe::Issuing::Cardholder)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
module Issuing
|
7
|
+
class DisputeTest < Test::Unit::TestCase
|
8
|
+
should "be creatable" do
|
9
|
+
dispute = Stripe::Issuing::Dispute.create(
|
10
|
+
reason: "fraudulent",
|
11
|
+
disputed_transaction: "ipi_123"
|
12
|
+
)
|
13
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes"
|
14
|
+
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be listable" do
|
18
|
+
disputes = Stripe::Issuing::Dispute.list
|
19
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/disputes"
|
20
|
+
assert disputes.data.is_a?(Array)
|
21
|
+
assert disputes.data[0].is_a?(Stripe::Issuing::Dispute)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "be retrievable" do
|
25
|
+
dispute = Stripe::Issuing::Dispute.retrieve("ich_123")
|
26
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/disputes/ich_123"
|
27
|
+
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
28
|
+
end
|
29
|
+
|
30
|
+
should "be saveable" do
|
31
|
+
dispute = Stripe::Issuing::Dispute.retrieve("ich_123")
|
32
|
+
dispute.metadata["key"] = "value"
|
33
|
+
dispute.save
|
34
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/#{dispute.id}"
|
35
|
+
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "be updateable" do
|
39
|
+
dispute = Stripe::Issuing::Dispute.update("ich_123", metadata: { foo: "bar" })
|
40
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/ich_123"
|
41
|
+
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
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 Issuing
|
7
|
+
class TransactionTest < Test::Unit::TestCase
|
8
|
+
should "be listable" do
|
9
|
+
stub_request(:get, "#{Stripe.api_base}/v1/issuing/transactions")
|
10
|
+
.to_return(body: JSON.generate(object: "list", data: [{ id: "ipi_123", object: "issuing.transaction" }]))
|
11
|
+
|
12
|
+
transactions = Stripe::Issuing::Transaction.list
|
13
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/transactions"
|
14
|
+
assert transactions.data.is_a?(Array)
|
15
|
+
assert transactions.data[0].is_a?(Stripe::Issuing::Transaction)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "be retrievable" do
|
19
|
+
stub_request(:get, "#{Stripe.api_base}/v1/issuing/transactions/ipi_123")
|
20
|
+
.to_return(body: JSON.generate(id: "ipi_123", object: "issuing.transaction"))
|
21
|
+
|
22
|
+
transaction = Stripe::Issuing::Transaction.retrieve("ipi_123")
|
23
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/transactions/ipi_123"
|
24
|
+
assert transaction.is_a?(Stripe::Issuing::Transaction)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be saveable" do
|
28
|
+
stub_request(:post, "#{Stripe.api_base}/v1/issuing/transactions/ipi_123")
|
29
|
+
.to_return(body: JSON.generate(id: "ipi_123", object: "issuing.transaction"))
|
30
|
+
|
31
|
+
transaction = Stripe::Issuing::Transaction.construct_from(id: "ipi_123", object: "issuing.transaction", metadata: {})
|
32
|
+
transaction.metadata["key"] = "value"
|
33
|
+
transaction.save
|
34
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/transactions/#{transaction.id}"
|
35
|
+
assert transaction.is_a?(Stripe::Issuing::Transaction)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "be updateable" do
|
39
|
+
stub_request(:post, "#{Stripe.api_base}/v1/issuing/transactions/ipi_123")
|
40
|
+
.to_return(body: JSON.generate(id: "ipi_123", object: "issuing.transaction"))
|
41
|
+
|
42
|
+
transaction = Stripe::Issuing::Transaction.update("ipi_123", metadata: { foo: "bar" })
|
43
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/transactions/ipi_123"
|
44
|
+
assert transaction.is_a?(Stripe::Issuing::Transaction)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
2
4
|
|
3
5
|
module Stripe
|
4
6
|
class ListObjectTest < Test::Unit::TestCase
|
@@ -8,59 +10,113 @@ module Stripe
|
|
8
10
|
end
|
9
11
|
|
10
12
|
should "provide #count via enumerable" do
|
11
|
-
list = Stripe::ListObject.construct_from({
|
12
|
-
data: [{ object: "charge" }]
|
13
|
-
})
|
13
|
+
list = Stripe::ListObject.construct_from(data: [{ object: "charge" }])
|
14
14
|
assert_equal 1, list.count
|
15
15
|
end
|
16
16
|
|
17
17
|
should "provide #each" do
|
18
18
|
arr = [
|
19
|
-
{ :
|
20
|
-
{ :
|
21
|
-
{ :
|
19
|
+
{ id: 1 },
|
20
|
+
{ id: 2 },
|
21
|
+
{ id: 3 },
|
22
22
|
]
|
23
23
|
expected = Util.convert_to_stripe_object(arr, {})
|
24
|
-
list = Stripe::ListObject.construct_from(
|
24
|
+
list = Stripe::ListObject.construct_from(data: arr)
|
25
25
|
assert_equal expected, list.each.to_a
|
26
26
|
end
|
27
27
|
|
28
|
-
should "provide #
|
28
|
+
should "provide #reverse_each" do
|
29
|
+
arr = [
|
30
|
+
{ id: 1 },
|
31
|
+
{ id: 2 },
|
32
|
+
{ id: 3 },
|
33
|
+
]
|
34
|
+
expected = Util.convert_to_stripe_object(arr.reverse, {})
|
35
|
+
list = Stripe::ListObject.construct_from(data: arr)
|
36
|
+
assert_equal expected, list.reverse_each.to_a
|
37
|
+
end
|
38
|
+
|
39
|
+
should "provide #auto_paging_each that supports forward pagination" do
|
40
|
+
arr = [
|
41
|
+
{ id: 1 },
|
42
|
+
{ id: 2 },
|
43
|
+
{ id: 3 },
|
44
|
+
{ id: 4 },
|
45
|
+
{ id: 5 },
|
46
|
+
{ id: 6 },
|
47
|
+
]
|
48
|
+
expected = Util.convert_to_stripe_object(arr, {})
|
49
|
+
|
50
|
+
# Initial list object to page on. Notably, its last data element will be
|
51
|
+
# used as a cursor to fetch the next page.
|
52
|
+
list = TestListObject.construct_from(data: [{ id: 1 }],
|
53
|
+
has_more: true,
|
54
|
+
url: "/things")
|
55
|
+
list.filters = { limit: 3 }
|
56
|
+
|
57
|
+
# The test will start with the synthetic list object above, and use it as
|
58
|
+
# a starting point to fetch two more pages. The second page indicates
|
59
|
+
# that there are no more elements by setting `has_more` to `false`, and
|
60
|
+
# iteration stops.
|
61
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
62
|
+
.with(query: { starting_after: "1", limit: "3" })
|
63
|
+
.to_return(body: JSON.generate(data: [{ id: 2 }, { id: 3 }, { id: 4 }], has_more: true, url: "/things"))
|
64
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
65
|
+
.with(query: { starting_after: "4", limit: "3" })
|
66
|
+
.to_return(body: JSON.generate(data: [{ id: 5 }, { id: 6 }], has_more: false, url: "/things"))
|
67
|
+
|
68
|
+
assert_equal expected, list.auto_paging_each.to_a
|
69
|
+
end
|
70
|
+
|
71
|
+
should "provide #auto_paging_each that supports backward pagination with `ending_before`" do
|
29
72
|
arr = [
|
30
|
-
{ :
|
31
|
-
{ :
|
32
|
-
{ :
|
73
|
+
{ id: 6 },
|
74
|
+
{ id: 5 },
|
75
|
+
{ id: 4 },
|
76
|
+
{ id: 3 },
|
77
|
+
{ id: 2 },
|
78
|
+
{ id: 1 },
|
33
79
|
]
|
34
80
|
expected = Util.convert_to_stripe_object(arr, {})
|
35
81
|
|
36
|
-
list
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
82
|
+
# Initial list object to page on. Notably, its first data element will be
|
83
|
+
# used as a cursor to fetch the next page.
|
84
|
+
list = TestListObject.construct_from(data: [{ id: 6 }],
|
85
|
+
has_more: true,
|
86
|
+
url: "/things")
|
87
|
+
|
88
|
+
# We also add an `ending_before` filter on the list to simulate backwards
|
89
|
+
# pagination.
|
90
|
+
list.filters = { ending_before: 7, limit: 3 }
|
91
|
+
|
92
|
+
# The test will start with the synthetic list object above, and use it as
|
93
|
+
# a starting point to fetch two more pages. The second page indicates
|
94
|
+
# that there are no more elements by setting `has_more` to `false`, and
|
95
|
+
# iteration stops.
|
96
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
97
|
+
.with(query: { ending_before: "6", limit: "3" })
|
98
|
+
.to_return(body: JSON.generate(data: [{ id: 3 }, { id: 4 }, { id: 5 }], has_more: true, url: "/things"))
|
99
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
100
|
+
.with(query: { ending_before: "3", limit: "3" })
|
101
|
+
.to_return(body: JSON.generate(data: [{ id: 1 }, { id: 2 }], has_more: false, url: "/things"))
|
44
102
|
|
45
103
|
assert_equal expected, list.auto_paging_each.to_a
|
46
104
|
end
|
47
105
|
|
48
106
|
should "provide #auto_paging_each that responds to a block" do
|
49
107
|
arr = [
|
50
|
-
{ :
|
51
|
-
{ :
|
52
|
-
{ :
|
108
|
+
{ id: 1 },
|
109
|
+
{ id: 2 },
|
110
|
+
{ id: 3 },
|
53
111
|
]
|
54
112
|
expected = Util.convert_to_stripe_object(arr, {})
|
55
113
|
|
56
|
-
list = TestListObject.construct_from({
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
with(query: { starting_after: "1" }).
|
63
|
-
to_return(body: JSON.generate({ :data => [{ :id => 2 }, { :id => 3}], :has_more => false }))
|
114
|
+
list = TestListObject.construct_from(data: [{ id: 1 }],
|
115
|
+
has_more: true,
|
116
|
+
url: "/things")
|
117
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
118
|
+
.with(query: { starting_after: "1" })
|
119
|
+
.to_return(body: JSON.generate(data: [{ id: 2 }, { id: 3 }], has_more: false))
|
64
120
|
|
65
121
|
actual = []
|
66
122
|
list.auto_paging_each do |obj|
|
@@ -71,9 +127,9 @@ module Stripe
|
|
71
127
|
end
|
72
128
|
|
73
129
|
should "provide #empty?" do
|
74
|
-
list = Stripe::ListObject.construct_from(
|
130
|
+
list = Stripe::ListObject.construct_from(data: [])
|
75
131
|
assert list.empty?
|
76
|
-
list = Stripe::ListObject.construct_from(
|
132
|
+
list = Stripe::ListObject.construct_from(data: [{}])
|
77
133
|
refute list.empty?
|
78
134
|
end
|
79
135
|
|
@@ -82,38 +138,32 @@ module Stripe
|
|
82
138
|
#
|
83
139
|
|
84
140
|
should "fetch a next page through #next_page" do
|
85
|
-
list = TestListObject.construct_from({
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
with(query: { starting_after: "1" }).
|
92
|
-
to_return(body: JSON.generate({ :data => [{ :id => 2 }], :has_more => false }))
|
141
|
+
list = TestListObject.construct_from(data: [{ id: 1 }],
|
142
|
+
has_more: true,
|
143
|
+
url: "/things")
|
144
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
145
|
+
.with(query: { starting_after: "1" })
|
146
|
+
.to_return(body: JSON.generate(data: [{ id: 2 }], has_more: false))
|
93
147
|
next_list = list.next_page
|
94
148
|
refute next_list.empty?
|
95
149
|
end
|
96
150
|
|
97
151
|
should "fetch a next page through #next_page and respect limit" do
|
98
|
-
list = TestListObject.construct_from({
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
})
|
103
|
-
|
104
|
-
|
105
|
-
with(query: { "expand[]" => "data.source", "limit" => "3", "starting_after" => "1" }).
|
106
|
-
to_return(body: JSON.generate({ :data => [{ :id => 2 }], :has_more => false }))
|
152
|
+
list = TestListObject.construct_from(data: [{ id: 1 }],
|
153
|
+
has_more: true,
|
154
|
+
url: "/things")
|
155
|
+
list.filters = { expand: ["data.source"], limit: 3 }
|
156
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
157
|
+
.with(query: { "expand[]" => "data.source", "limit" => "3", "starting_after" => "1" })
|
158
|
+
.to_return(body: JSON.generate(data: [{ id: 2 }], has_more: false))
|
107
159
|
next_list = list.next_page
|
108
|
-
assert_equal({ :
|
160
|
+
assert_equal({ expand: ["data.source"], limit: 3, starting_after: 1 }, next_list.filters)
|
109
161
|
end
|
110
162
|
|
111
163
|
should "fetch an empty page through #next_page" do
|
112
|
-
list = TestListObject.construct_from({
|
113
|
-
|
114
|
-
|
115
|
-
:url => "/things",
|
116
|
-
})
|
164
|
+
list = TestListObject.construct_from(data: [{ id: 1 }],
|
165
|
+
has_more: false,
|
166
|
+
url: "/things")
|
117
167
|
next_list = list.next_page
|
118
168
|
assert_equal Stripe::ListObject.empty_list, next_list
|
119
169
|
end
|
@@ -123,44 +173,26 @@ module Stripe
|
|
123
173
|
#
|
124
174
|
|
125
175
|
should "fetch a next page through #previous_page" do
|
126
|
-
list = TestListObject.construct_from({
|
127
|
-
|
128
|
-
|
129
|
-
})
|
130
|
-
|
131
|
-
|
132
|
-
to_return(body: JSON.generate({ :data => [{ :id => 1 }] }))
|
176
|
+
list = TestListObject.construct_from(data: [{ id: 2 }],
|
177
|
+
has_more: true,
|
178
|
+
url: "/things")
|
179
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
180
|
+
.with(query: { ending_before: "2" })
|
181
|
+
.to_return(body: JSON.generate(data: [{ id: 1 }], has_more: false))
|
133
182
|
next_list = list.previous_page
|
134
183
|
refute next_list.empty?
|
135
184
|
end
|
136
185
|
|
137
186
|
should "fetch a next page through #previous_page and respect limit" do
|
138
|
-
list = TestListObject.construct_from({
|
139
|
-
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
to_return(body: JSON.generate({ :data => [{ :id => 1 }] }))
|
187
|
+
list = TestListObject.construct_from(data: [{ id: 2 }],
|
188
|
+
has_more: true,
|
189
|
+
url: "/things")
|
190
|
+
list.filters = { expand: ["data.source"], limit: 3 }
|
191
|
+
stub_request(:get, "#{Stripe.api_base}/things")
|
192
|
+
.with(query: { "expand[]" => "data.source", "limit" => "3", "ending_before" => "2" })
|
193
|
+
.to_return(body: JSON.generate(data: [{ id: 1 }], has_more: false))
|
146
194
|
next_list = list.previous_page
|
147
|
-
assert_equal({ :expand
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# backward compatibility
|
152
|
-
#
|
153
|
-
|
154
|
-
# note that the name #all is deprecated, as is using it fetch the next page
|
155
|
-
# in a list
|
156
|
-
should "be able to retrieve full lists given a listobject" do
|
157
|
-
c = Stripe::Charge.all
|
158
|
-
assert c.kind_of?(Stripe::ListObject)
|
159
|
-
assert_equal('/v1/charges', c.resource_url)
|
160
|
-
all = c.all
|
161
|
-
assert all.kind_of?(Stripe::ListObject)
|
162
|
-
assert_equal('/v1/charges', all.resource_url)
|
163
|
-
assert all.data.kind_of?(Array)
|
195
|
+
assert_equal({ ending_before: 2, expand: ["data.source"], limit: 3 }, next_list.filters)
|
164
196
|
end
|
165
197
|
end
|
166
198
|
end
|
@@ -1,35 +1,37 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
2
4
|
|
3
5
|
module Stripe
|
4
6
|
class LoginLinkTest < Test::Unit::TestCase
|
5
7
|
setup do
|
6
8
|
account_fixture = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
9
|
+
"id" => "acct_123",
|
10
|
+
"object" => "account",
|
11
|
+
"login_links" => {
|
12
|
+
"data" => [],
|
13
|
+
"has_more" => false,
|
14
|
+
"object" => "list",
|
15
|
+
"url" => "/v1/accounts/acct_123/login_links",
|
16
|
+
},
|
15
17
|
}
|
16
18
|
@account = Stripe::Account.construct_from(account_fixture)
|
17
19
|
end
|
18
20
|
|
19
21
|
should "not be retrievable" do
|
20
22
|
assert_raises NotImplementedError do
|
21
|
-
Stripe::LoginLink.retrieve(
|
23
|
+
Stripe::LoginLink.retrieve("foo")
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
27
|
should "be creatable" do
|
26
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links")
|
27
|
-
to_return(body: JSON.generate(
|
28
|
+
stub_request(:post, "#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links")
|
29
|
+
.to_return(body: JSON.generate(object: "login_link"))
|
28
30
|
|
29
31
|
login_link = @account.login_links.create
|
30
32
|
assert_requested :post,
|
31
|
-
|
32
|
-
assert login_link.
|
33
|
+
"#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links"
|
34
|
+
assert login_link.is_a?(Stripe::LoginLink)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
class MandateTest < Test::Unit::TestCase
|
7
|
+
should "be retrievable" do
|
8
|
+
schedule = Stripe::Mandate.retrieve("mandate_123")
|
9
|
+
assert_requested :get,
|
10
|
+
"#{Stripe.api_base}/v1/mandates/mandate_123"
|
11
|
+
assert schedule.is_a?(Stripe::Mandate)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|