From 50e685196aab88dab13137c07fd84d8e3f138b65 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 19 Mar 2020 11:39:47 -0700 Subject: [PATCH] Support for asynchronous autopagination (#1947) --- .../Services/Accounts/AccountService.cs | 7 + .../ApplePayDomains/ApplePayDomainService.cs | 7 + .../ApplicationFeeRefundService.cs | 7 + .../ApplicationFees/ApplicationFeeService.cs | 7 + .../BalanceTransactionService.cs | 7 + .../BankAccounts/BankAccountService.cs | 7 + .../Capabilities/CapabilityService.cs | 7 + src/Stripe.net/Services/Cards/CardService.cs | 7 + .../Services/Charges/ChargeService.cs | 7 + .../Checkout/Sessions/SessionService.cs | 7 + .../CountrySpecs/CountrySpecService.cs | 7 + .../Services/Coupons/CouponService.cs | 7 + .../Services/CreditNotes/CreditNoteService.cs | 21 + .../CustomerBalanceTransactionService.cs | 7 + .../Services/Customers/CustomerService.cs | 7 + .../Services/Disputes/DisputeService.cs | 7 + .../Services/Events/EventService.cs | 7 + .../ExchangeRates/ExchangeRateService.cs | 7 + .../ExternalAccountService.cs | 7 + .../Services/FileLinks/FileLinkService.cs | 7 + src/Stripe.net/Services/Files/FileService.cs | 7 + .../InvoiceItems/InvoiceItemService.cs | 7 + .../Services/Invoices/InvoiceService.cs | 21 + .../Authorizations/AuthorizationService.cs | 7 + .../Issuing/Cardholders/CardholderService.cs | 7 + .../Services/Issuing/Cards/CardService.cs | 7 + .../Issuing/Disputes/DisputeService.cs | 7 + .../Transactions/TransactionService.cs | 7 + .../Services/Orders/OrderService.cs | 7 + .../PaymentIntents/PaymentIntentService.cs | 7 + .../PaymentMethods/PaymentMethodService.cs | 7 + .../Services/Payouts/PayoutService.cs | 7 + .../Services/Persons/PersonService.cs | 7 + src/Stripe.net/Services/Plans/PlanService.cs | 7 + .../Services/Products/ProductService.cs | 7 + .../EarlyFraudWarningService.cs | 7 + .../ValueListItems/ValueListItemService.cs | 7 + .../Radar/ValueLists/ValueListService.cs | 7 + .../Services/Refunds/RefundService.cs | 7 + .../Reporting/ReportRuns/ReportRunService.cs | 7 + .../ReportTypes/ReportTypeService.cs | 7 + .../Services/Reviews/ReviewService.cs | 7 + .../SetupIntents/SetupIntentService.cs | 7 + .../ScheduledQueryRunService.cs | 7 + src/Stripe.net/Services/Skus/SkuService.cs | 7 + .../SourceTransactionService.cs | 7 + .../Services/Sources/SourceService.cs | 7 + .../SubscriptionItemService.cs | 7 + .../SubscriptionScheduleService.cs | 7 + .../Subscriptions/SubscriptionService.cs | 7 + .../Services/TaxIds/TaxIdService.cs | 7 + .../Services/TaxRates/TaxRateService.cs | 7 + .../Terminal/Locations/LocationService.cs | 7 + .../Terminal/Readers/ReaderService.cs | 7 + .../Services/Topups/TopupService.cs | 7 + .../TransferReversalService.cs | 7 + .../Services/Transfers/TransferService.cs | 7 + .../UsageRecordSummaryService.cs | 7 + .../WebhookEndpointService.cs | 7 + src/Stripe.net/Services/_base/Service.cs | 104 ++++- .../Services/_base/ServiceNested.cs | 15 + .../Services/_interfaces/IListable.cs | 4 + .../Services/_interfaces/INestedListable.cs | 4 + src/Stripe.net/Stripe.net.csproj | 9 + .../Services/Accounts/AccountServiceTest.cs | 16 +- .../ApplePayDomainServiceTest.cs | 16 +- .../ApplicationFeeRefundServiceTest.cs | 16 +- .../ApplicationFeeServiceTest.cs | 16 +- src/StripeTests/Services/AutoPagingTest.cs | 361 +++++++++++++++++- .../BalanceTransactionServiceTest.cs | 16 +- .../BankAccounts/BankAccountServiceTest.cs | 13 +- .../Capabilities/CapabilityServiceTest.cs | 16 +- .../Services/Cards/CardServiceTest.cs | 13 +- .../Services/Charges/ChargeServiceTest.cs | 16 +- .../Services/Checkout/SessionServiceTest.cs | 16 +- .../CountrySpecs/CountrySpecServiceTest.cs | 16 +- .../Services/Coupons/CouponServiceTest.cs | 16 +- .../CreditNotes/CreditNoteServiceTest.cs | 48 ++- .../CustomerBalanceTransactionServiceTest.cs | 16 +- .../Services/Customers/CustomerServiceTest.cs | 16 +- .../Services/Disputes/DisputeServiceTest.cs | 16 +- .../Services/Events/EventServiceTest.cs | 16 +- .../ExchangeRates/ExchangeRateServiceTest.cs | 16 +- .../ExternalAccountServiceTest.cs | 13 +- .../Services/FileLinks/FileLinkServiceTest.cs | 16 +- .../Services/Files/FileServiceTest.cs | 16 +- .../InvoiceItems/InvoiceItemServiceTest.cs | 16 +- .../Services/Invoices/InvoiceServiceTest.cs | 48 ++- .../AuthorizationServiceTest.cs | 15 +- .../Cardholders/CardholderServiceTest.cs | 15 +- .../Issuing/Cards/IssuingCardServiceTest.cs | 15 +- .../Disputes/IssuingDisputeServiceTest.cs | 15 +- .../Transactions/TransactionServiceTest.cs | 15 +- .../Services/Orders/OrderServiceTest.cs | 16 +- .../PaymentIntentServiceTest.cs | 16 +- .../PaymentMethodServiceTest.cs | 16 +- .../Services/Payouts/PayoutServiceTest.cs | 16 +- .../Services/Persons/PersonServiceTest.cs | 16 +- .../Services/Plans/PlanServiceTest.cs | 16 +- .../Services/Products/ProductServiceTest.cs | 16 +- .../EarlyFraudWarningServiceTest.cs | 16 +- .../ValueListItemServiceTest.cs | 16 +- .../Radar/ValueLists/ValueListServiceTest.cs | 16 +- .../Services/Refunds/RefundServiceTest.cs | 16 +- .../ReportRuns/ReportRunServiceTest.cs | 13 +- .../ReportTypes/ReportTypeServiceTest.cs | 13 +- .../Services/Reviews/ReviewServiceTest.cs | 16 +- .../SetupIntents/SetupIntentServiceTest.cs | 16 +- .../ScheduledQueryRunServiceTest.cs | 16 +- .../Services/Skus/SkuServiceTest.cs | 16 +- .../SourceTransactionServiceTest.cs | 16 +- .../Services/Sources/SourceServiceTest.cs | 13 +- .../SubscriptionItemServiceTest.cs | 16 +- .../SubscriptionScheduleServiceTest.cs | 16 +- .../Subscriptions/SubscriptionServiceTest.cs | 16 +- .../Services/TaxIds/TaxIdServiceTest.cs | 16 +- .../Services/TaxRates/TaxRateServiceTest.cs | 16 +- .../Terminal/Locations/LocationServiceTest.cs | 16 +- .../Terminal/Readers/ReaderServiceTest.cs | 16 +- .../Services/Topups/TopupServiceTest.cs | 16 +- .../TransferReversalServiceTest.cs | 16 +- .../Services/Transfers/TransferServiceTest.cs | 16 +- .../UsageRecordSummaryServiceTest.cs | 16 +- .../WebhookEndpointServiceTest.cs | 16 +- src/StripeTests/Services/_base/ServiceTest.cs | 7 + src/StripeTests/StripeTests.csproj | 10 + 126 files changed, 1759 insertions(+), 181 deletions(-) diff --git a/src/Stripe.net/Services/Accounts/AccountService.cs b/src/Stripe.net/Services/Accounts/AccountService.cs index 79004cc10d..7f95aa052a 100644 --- a/src/Stripe.net/Services/Accounts/AccountService.cs +++ b/src/Stripe.net/Services/Accounts/AccountService.cs @@ -80,6 +80,13 @@ public virtual IEnumerable ListAutoPaging(AccountListOptions options = return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(AccountListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Account Reject(string accountId, AccountRejectOptions options, RequestOptions requestOptions = null) { return this.Request(HttpMethod.Post, $"{this.InstanceUrl(accountId)}/reject", options, requestOptions); diff --git a/src/Stripe.net/Services/ApplePayDomains/ApplePayDomainService.cs b/src/Stripe.net/Services/ApplePayDomains/ApplePayDomainService.cs index 0a488d0c79..6487b58d65 100644 --- a/src/Stripe.net/Services/ApplePayDomains/ApplePayDomainService.cs +++ b/src/Stripe.net/Services/ApplePayDomains/ApplePayDomainService.cs @@ -66,5 +66,12 @@ public virtual IEnumerable ListAutoPaging(ApplePayDomainListOpti { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ApplePayDomainListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/ApplicationFeeRefunds/ApplicationFeeRefundService.cs b/src/Stripe.net/Services/ApplicationFeeRefunds/ApplicationFeeRefundService.cs index 1c14588b2c..c49bda29b2 100644 --- a/src/Stripe.net/Services/ApplicationFeeRefunds/ApplicationFeeRefundService.cs +++ b/src/Stripe.net/Services/ApplicationFeeRefunds/ApplicationFeeRefundService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(string applicati return this.ListNestedEntitiesAutoPaging(applicationFeeId, options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string applicationFeeId, ApplicationFeeRefundListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(applicationFeeId, options, requestOptions, cancellationToken); + } +#endif + public virtual ApplicationFeeRefund Update(string applicationFeeId, string refundId, ApplicationFeeRefundUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(applicationFeeId, refundId, options, requestOptions); diff --git a/src/Stripe.net/Services/ApplicationFees/ApplicationFeeService.cs b/src/Stripe.net/Services/ApplicationFees/ApplicationFeeService.cs index 4fa64b7ad4..f7aa805007 100644 --- a/src/Stripe.net/Services/ApplicationFees/ApplicationFeeService.cs +++ b/src/Stripe.net/Services/ApplicationFees/ApplicationFeeService.cs @@ -45,5 +45,12 @@ public virtual IEnumerable ListAutoPaging(ApplicationFeeListOpti { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ApplicationFeeListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/BalanceTransactions/BalanceTransactionService.cs b/src/Stripe.net/Services/BalanceTransactions/BalanceTransactionService.cs index 10ec6c4b95..4cb5e1d970 100644 --- a/src/Stripe.net/Services/BalanceTransactions/BalanceTransactionService.cs +++ b/src/Stripe.net/Services/BalanceTransactions/BalanceTransactionService.cs @@ -45,5 +45,12 @@ public virtual IEnumerable ListAutoPaging(BalanceTransaction { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(BalanceTransactionListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/BankAccounts/BankAccountService.cs b/src/Stripe.net/Services/BankAccounts/BankAccountService.cs index 1e8dcc5212..dabb2ee453 100644 --- a/src/Stripe.net/Services/BankAccounts/BankAccountService.cs +++ b/src/Stripe.net/Services/BankAccounts/BankAccountService.cs @@ -70,6 +70,13 @@ public virtual IEnumerable ListAutoPaging(string customerId, BankAc return this.ListNestedEntitiesAutoPaging(customerId, options ?? new BankAccountListOptions(), requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string customerId, BankAccountListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(customerId, options ?? new BankAccountListOptions(), requestOptions, cancellationToken); + } +#endif + public virtual BankAccount Update(string customerId, string bankAccountId, BankAccountUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(customerId, bankAccountId, options, requestOptions); diff --git a/src/Stripe.net/Services/Capabilities/CapabilityService.cs b/src/Stripe.net/Services/Capabilities/CapabilityService.cs index 5a563475d2..12a4071e11 100644 --- a/src/Stripe.net/Services/Capabilities/CapabilityService.cs +++ b/src/Stripe.net/Services/Capabilities/CapabilityService.cs @@ -47,6 +47,13 @@ public virtual IEnumerable ListAutoPaging(string accountId, Capabili return this.ListNestedEntitiesAutoPaging(accountId, options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string accountId, CapabilityListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(accountId, options, requestOptions, cancellationToken); + } +#endif + public virtual Capability Update(string accountId, string capabilityId, CapabilityUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(accountId, capabilityId, options, requestOptions); diff --git a/src/Stripe.net/Services/Cards/CardService.cs b/src/Stripe.net/Services/Cards/CardService.cs index b017355323..6cc92553f5 100644 --- a/src/Stripe.net/Services/Cards/CardService.cs +++ b/src/Stripe.net/Services/Cards/CardService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(string customerId, CardListOptio return this.ListNestedEntitiesAutoPaging(customerId, options ?? new CardListOptions(), requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string customerId, CardListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(customerId, options ?? new CardListOptions(), requestOptions, cancellationToken); + } +#endif + public virtual Card Update(string customerId, string cardId, CardUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(customerId, cardId, options, requestOptions); diff --git a/src/Stripe.net/Services/Charges/ChargeService.cs b/src/Stripe.net/Services/Charges/ChargeService.cs index 100c5e0eae..b086e9d966 100644 --- a/src/Stripe.net/Services/Charges/ChargeService.cs +++ b/src/Stripe.net/Services/Charges/ChargeService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(ChargeListOptions options = nu return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ChargeListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Charge Update(string chargeId, ChargeUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(chargeId, options, requestOptions); diff --git a/src/Stripe.net/Services/Checkout/Sessions/SessionService.cs b/src/Stripe.net/Services/Checkout/Sessions/SessionService.cs index 7619145956..83fe0b83c1 100644 --- a/src/Stripe.net/Services/Checkout/Sessions/SessionService.cs +++ b/src/Stripe.net/Services/Checkout/Sessions/SessionService.cs @@ -58,5 +58,12 @@ public virtual IEnumerable ListAutoPaging(SessionListOptions options = { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(SessionListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/CountrySpecs/CountrySpecService.cs b/src/Stripe.net/Services/CountrySpecs/CountrySpecService.cs index 196dee8412..0c717733d3 100644 --- a/src/Stripe.net/Services/CountrySpecs/CountrySpecService.cs +++ b/src/Stripe.net/Services/CountrySpecs/CountrySpecService.cs @@ -44,5 +44,12 @@ public virtual IEnumerable ListAutoPaging(CountrySpecListOptions op { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(CountrySpecListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Coupons/CouponService.cs b/src/Stripe.net/Services/Coupons/CouponService.cs index c5fed17660..8514c8283e 100644 --- a/src/Stripe.net/Services/Coupons/CouponService.cs +++ b/src/Stripe.net/Services/Coupons/CouponService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(CouponListOptions options = nu return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(CouponListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Coupon Update(string couponId, CouponUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(couponId, options, requestOptions); diff --git a/src/Stripe.net/Services/CreditNotes/CreditNoteService.cs b/src/Stripe.net/Services/CreditNotes/CreditNoteService.cs index d38567cf0c..c8a5571bff 100644 --- a/src/Stripe.net/Services/CreditNotes/CreditNoteService.cs +++ b/src/Stripe.net/Services/CreditNotes/CreditNoteService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(CreditNoteListOptions opti return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(CreditNoteListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual StripeList ListLineItems(string creditnoteId, CreditNoteListLineItemsOptions options = null, RequestOptions requestOptions = null) { return this.Request>(HttpMethod.Get, $"{this.InstanceUrl(creditnoteId)}/lines", options, requestOptions); @@ -73,6 +80,13 @@ public virtual IEnumerable ListLineItemsAutoPaging(string cr return this.ListRequestAutoPaging($"{this.InstanceUrl(creditnoteId)}/lines", options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListLineItemsAutoPagingAsync(string creditnoteId, CreditNoteListLineItemsOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListRequestAutoPagingAsync($"{this.InstanceUrl(creditnoteId)}/lines", options, requestOptions, cancellationToken); + } +#endif + public virtual StripeList ListPreviewLineItems(CreditNoteListPreviewLineItemsOptions options = null, RequestOptions requestOptions = null) { return this.Request>(HttpMethod.Get, $"{this.InstanceUrl("preview")}/lines", options, requestOptions); @@ -88,6 +102,13 @@ public virtual IEnumerable ListPreviewLineItemsAutoPaging(Cr return this.ListRequestAutoPaging($"{this.InstanceUrl("preview")}/lines", options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListPreviewLineItemsAutoPagingAsync(CreditNoteListPreviewLineItemsOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListRequestAutoPagingAsync($"{this.InstanceUrl("preview")}/lines", options, requestOptions, cancellationToken); + } +#endif + public virtual CreditNote Preview(CreditNotePreviewOptions options, RequestOptions requestOptions = null) { return this.Request(HttpMethod.Get, $"{this.ClassUrl()}/preview", options, requestOptions); diff --git a/src/Stripe.net/Services/CustomerBalanceTransactions/CustomerBalanceTransactionService.cs b/src/Stripe.net/Services/CustomerBalanceTransactions/CustomerBalanceTransactionService.cs index e61b7be44b..434ee4c3e3 100644 --- a/src/Stripe.net/Services/CustomerBalanceTransactions/CustomerBalanceTransactionService.cs +++ b/src/Stripe.net/Services/CustomerBalanceTransactions/CustomerBalanceTransactionService.cs @@ -57,6 +57,13 @@ public virtual IEnumerable ListAutoPaging(string cus return this.ListNestedEntitiesAutoPaging(customerId, options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string customerId, CustomerBalanceTransactionListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(customerId, options, requestOptions, cancellationToken); + } +#endif + public virtual CustomerBalanceTransaction Update(string customerId, string transactionId, CustomerBalanceTransactionUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(customerId, transactionId, options, requestOptions); diff --git a/src/Stripe.net/Services/Customers/CustomerService.cs b/src/Stripe.net/Services/Customers/CustomerService.cs index 1b801940eb..4f80941ec0 100644 --- a/src/Stripe.net/Services/Customers/CustomerService.cs +++ b/src/Stripe.net/Services/Customers/CustomerService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(CustomerListOptions options return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(CustomerListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Customer Update(string customerId, CustomerUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(customerId, options, requestOptions); diff --git a/src/Stripe.net/Services/Disputes/DisputeService.cs b/src/Stripe.net/Services/Disputes/DisputeService.cs index 31e403a375..913ee5cacb 100644 --- a/src/Stripe.net/Services/Disputes/DisputeService.cs +++ b/src/Stripe.net/Services/Disputes/DisputeService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(DisputeListOptions options = return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(DisputeListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Dispute Update(string disputeId, DisputeUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(disputeId, options, requestOptions); diff --git a/src/Stripe.net/Services/Events/EventService.cs b/src/Stripe.net/Services/Events/EventService.cs index 2a03c0ea15..cd9c8b95a6 100644 --- a/src/Stripe.net/Services/Events/EventService.cs +++ b/src/Stripe.net/Services/Events/EventService.cs @@ -44,5 +44,12 @@ public virtual IEnumerable ListAutoPaging(EventListOptions options = null { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(EventListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/ExchangeRates/ExchangeRateService.cs b/src/Stripe.net/Services/ExchangeRates/ExchangeRateService.cs index 5af2280ecb..8b78420dd6 100644 --- a/src/Stripe.net/Services/ExchangeRates/ExchangeRateService.cs +++ b/src/Stripe.net/Services/ExchangeRates/ExchangeRateService.cs @@ -44,5 +44,12 @@ public virtual IEnumerable ListAutoPaging(ExchangeRateListOptions { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ExchangeRateListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/ExternalAccounts/ExternalAccountService.cs b/src/Stripe.net/Services/ExternalAccounts/ExternalAccountService.cs index 9ce4d7f428..17a2740ce1 100644 --- a/src/Stripe.net/Services/ExternalAccounts/ExternalAccountService.cs +++ b/src/Stripe.net/Services/ExternalAccounts/ExternalAccountService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(string accountId, Ex return this.ListNestedEntitiesAutoPaging(accountId, options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string accountId, ExternalAccountListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(accountId, options, requestOptions, cancellationToken); + } +#endif + public virtual IExternalAccount Update(string accountId, string externalAccountId, ExternalAccountUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(accountId, externalAccountId, options, requestOptions); diff --git a/src/Stripe.net/Services/FileLinks/FileLinkService.cs b/src/Stripe.net/Services/FileLinks/FileLinkService.cs index bb010d5a6c..50048239a6 100644 --- a/src/Stripe.net/Services/FileLinks/FileLinkService.cs +++ b/src/Stripe.net/Services/FileLinks/FileLinkService.cs @@ -57,6 +57,13 @@ public virtual IEnumerable ListAutoPaging(FileLinkListOptions options return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(FileLinkListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual FileLink Update(string fileLinkId, FileLinkUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(fileLinkId, options, requestOptions); diff --git a/src/Stripe.net/Services/Files/FileService.cs b/src/Stripe.net/Services/Files/FileService.cs index 1d770b33f7..0bb9e0be1f 100644 --- a/src/Stripe.net/Services/Files/FileService.cs +++ b/src/Stripe.net/Services/Files/FileService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(FileListOptions options = null, return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(FileListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + private RequestOptions SetupRequestOptionsForFilesRequest(RequestOptions requestOptions) { if (requestOptions == null) diff --git a/src/Stripe.net/Services/InvoiceItems/InvoiceItemService.cs b/src/Stripe.net/Services/InvoiceItems/InvoiceItemService.cs index 2de5b60979..150bba5cd2 100644 --- a/src/Stripe.net/Services/InvoiceItems/InvoiceItemService.cs +++ b/src/Stripe.net/Services/InvoiceItems/InvoiceItemService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(InvoiceItemListOptions op return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(InvoiceItemListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual InvoiceItem Update(string invoiceitemId, InvoiceItemUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(invoiceitemId, options, requestOptions); diff --git a/src/Stripe.net/Services/Invoices/InvoiceService.cs b/src/Stripe.net/Services/Invoices/InvoiceService.cs index 420802972e..35b3afd893 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceService.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceService.cs @@ -80,6 +80,13 @@ public virtual IEnumerable ListAutoPaging(InvoiceListOptions options = return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(InvoiceListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual StripeList ListLineItems(string invoiceId, InvoiceListLineItemsOptions options = null, RequestOptions requestOptions = null) { return this.Request>(HttpMethod.Get, $"{this.InstanceUrl(invoiceId)}/lines", options, requestOptions); @@ -95,6 +102,13 @@ public virtual IEnumerable ListLineItemsAutoPaging(string invoi return this.ListRequestAutoPaging($"{this.InstanceUrl(invoiceId)}/lines", options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListLineItemsAutoPagingAsync(string invoiceId, InvoiceListLineItemsOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListRequestAutoPagingAsync($"{this.InstanceUrl(invoiceId)}/lines", options, requestOptions, cancellationToken); + } +#endif + public virtual StripeList ListUpcomingLineItems(UpcomingInvoiceListLineItemsOptions options = null, RequestOptions requestOptions = null) { return this.Request>(HttpMethod.Get, $"{this.InstanceUrl("upcoming")}/lines", options, requestOptions); @@ -110,6 +124,13 @@ public virtual IEnumerable ListUpcomingLineItemsAutoPaging(Upco return this.ListRequestAutoPaging($"{this.InstanceUrl("upcoming")}/lines", options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListUpcomingLineItemsAutoPagingAsync(UpcomingInvoiceListLineItemsOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListRequestAutoPagingAsync($"{this.InstanceUrl("upcoming")}/lines", options, requestOptions, cancellationToken); + } +#endif + public virtual Invoice MarkUncollectible(string invoiceId, InvoiceMarkUncollectibleOptions options = null, RequestOptions requestOptions = null) { return this.Request(HttpMethod.Post, $"{this.InstanceUrl(invoiceId)}/mark_uncollectible", options, requestOptions); diff --git a/src/Stripe.net/Services/Issuing/Authorizations/AuthorizationService.cs b/src/Stripe.net/Services/Issuing/Authorizations/AuthorizationService.cs index 1e6486b750..7a46615934 100644 --- a/src/Stripe.net/Services/Issuing/Authorizations/AuthorizationService.cs +++ b/src/Stripe.net/Services/Issuing/Authorizations/AuthorizationService.cs @@ -67,6 +67,13 @@ public virtual IEnumerable ListAutoPaging(AuthorizationListOption return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(AuthorizationListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Authorization Update(string authorizationId, AuthorizationUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(authorizationId, options, requestOptions); diff --git a/src/Stripe.net/Services/Issuing/Cardholders/CardholderService.cs b/src/Stripe.net/Services/Issuing/Cardholders/CardholderService.cs index 7be3d02aaa..c647556412 100644 --- a/src/Stripe.net/Services/Issuing/Cardholders/CardholderService.cs +++ b/src/Stripe.net/Services/Issuing/Cardholders/CardholderService.cs @@ -57,6 +57,13 @@ public virtual IEnumerable ListAutoPaging(CardholderListOptions opti return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(CardholderListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Cardholder Update(string cardholderId, CardholderUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(cardholderId, options, requestOptions); diff --git a/src/Stripe.net/Services/Issuing/Cards/CardService.cs b/src/Stripe.net/Services/Issuing/Cards/CardService.cs index a30a6e0409..6021e0763e 100644 --- a/src/Stripe.net/Services/Issuing/Cards/CardService.cs +++ b/src/Stripe.net/Services/Issuing/Cards/CardService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(CardListOptions options = null, return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(CardListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Card Update(string cardId, CardUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(cardId, options, requestOptions); diff --git a/src/Stripe.net/Services/Issuing/Disputes/DisputeService.cs b/src/Stripe.net/Services/Issuing/Disputes/DisputeService.cs index 21c4077ee2..569fed3908 100644 --- a/src/Stripe.net/Services/Issuing/Disputes/DisputeService.cs +++ b/src/Stripe.net/Services/Issuing/Disputes/DisputeService.cs @@ -57,6 +57,13 @@ public virtual IEnumerable ListAutoPaging(DisputeListOptions options = return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(DisputeListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Dispute Update(string disputeId, DisputeUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(disputeId, options, requestOptions); diff --git a/src/Stripe.net/Services/Issuing/Transactions/TransactionService.cs b/src/Stripe.net/Services/Issuing/Transactions/TransactionService.cs index 8c2a082175..f48a2760bb 100644 --- a/src/Stripe.net/Services/Issuing/Transactions/TransactionService.cs +++ b/src/Stripe.net/Services/Issuing/Transactions/TransactionService.cs @@ -46,6 +46,13 @@ public virtual IEnumerable ListAutoPaging(TransactionListOptions op return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(TransactionListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Transaction Update(string transactionId, TransactionUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(transactionId, options, requestOptions); diff --git a/src/Stripe.net/Services/Orders/OrderService.cs b/src/Stripe.net/Services/Orders/OrderService.cs index 0a7c0e7728..e617c9ce14 100644 --- a/src/Stripe.net/Services/Orders/OrderService.cs +++ b/src/Stripe.net/Services/Orders/OrderService.cs @@ -59,6 +59,13 @@ public virtual IEnumerable ListAutoPaging(OrderListOptions options = null return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(OrderListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Order Pay(string orderId, OrderPayOptions options = null, RequestOptions requestOptions = null) { return this.Request(HttpMethod.Post, $"{this.InstanceUrl(orderId)}/pay", options, requestOptions); diff --git a/src/Stripe.net/Services/PaymentIntents/PaymentIntentService.cs b/src/Stripe.net/Services/PaymentIntents/PaymentIntentService.cs index 3a02eae764..c81608b518 100644 --- a/src/Stripe.net/Services/PaymentIntents/PaymentIntentService.cs +++ b/src/Stripe.net/Services/PaymentIntents/PaymentIntentService.cs @@ -89,6 +89,13 @@ public virtual IEnumerable ListAutoPaging(PaymentIntentListOption return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(PaymentIntentListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual PaymentIntent Update(string paymentIntentId, PaymentIntentUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(paymentIntentId, options, requestOptions); diff --git a/src/Stripe.net/Services/PaymentMethods/PaymentMethodService.cs b/src/Stripe.net/Services/PaymentMethods/PaymentMethodService.cs index 4906497823..2f7b1ba088 100644 --- a/src/Stripe.net/Services/PaymentMethods/PaymentMethodService.cs +++ b/src/Stripe.net/Services/PaymentMethods/PaymentMethodService.cs @@ -79,6 +79,13 @@ public virtual IEnumerable ListAutoPaging(PaymentMethodListOption return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(PaymentMethodListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual PaymentMethod Update(string paymentMethodId, PaymentMethodUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(paymentMethodId, options, requestOptions); diff --git a/src/Stripe.net/Services/Payouts/PayoutService.cs b/src/Stripe.net/Services/Payouts/PayoutService.cs index b4e8009ce7..4f3d3fab36 100644 --- a/src/Stripe.net/Services/Payouts/PayoutService.cs +++ b/src/Stripe.net/Services/Payouts/PayoutService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(PayoutListOptions options = nu return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(PayoutListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Payout Update(string payoutId, PayoutUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(payoutId, options, requestOptions); diff --git a/src/Stripe.net/Services/Persons/PersonService.cs b/src/Stripe.net/Services/Persons/PersonService.cs index eafc0d52e4..5a3ecc5c6d 100644 --- a/src/Stripe.net/Services/Persons/PersonService.cs +++ b/src/Stripe.net/Services/Persons/PersonService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(string accountId, PersonListOp return this.ListNestedEntitiesAutoPaging(accountId, options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string accountId, PersonListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(accountId, options, requestOptions, cancellationToken); + } +#endif + public virtual Person Update(string accountId, string personId, PersonUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(accountId, personId, options, requestOptions); diff --git a/src/Stripe.net/Services/Plans/PlanService.cs b/src/Stripe.net/Services/Plans/PlanService.cs index cd5e420e7a..b924c77b70 100644 --- a/src/Stripe.net/Services/Plans/PlanService.cs +++ b/src/Stripe.net/Services/Plans/PlanService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(PlanListOptions options = null, return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(PlanListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Plan Update(string planId, PlanUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(planId, options, requestOptions); diff --git a/src/Stripe.net/Services/Products/ProductService.cs b/src/Stripe.net/Services/Products/ProductService.cs index 5a8c722e0d..84a608f570 100644 --- a/src/Stripe.net/Services/Products/ProductService.cs +++ b/src/Stripe.net/Services/Products/ProductService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(ProductListOptions options = return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ProductListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Product Update(string productId, ProductUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(productId, options, requestOptions); diff --git a/src/Stripe.net/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningService.cs b/src/Stripe.net/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningService.cs index c2c2cee445..d310e69849 100644 --- a/src/Stripe.net/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningService.cs +++ b/src/Stripe.net/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningService.cs @@ -44,5 +44,12 @@ public virtual IEnumerable ListAutoPaging(EarlyFraudWarningLi { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(EarlyFraudWarningListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Radar/ValueListItems/ValueListItemService.cs b/src/Stripe.net/Services/Radar/ValueListItems/ValueListItemService.cs index d98fb786a2..99af248ff8 100644 --- a/src/Stripe.net/Services/Radar/ValueListItems/ValueListItemService.cs +++ b/src/Stripe.net/Services/Radar/ValueListItems/ValueListItemService.cs @@ -66,5 +66,12 @@ public virtual IEnumerable ListAutoPaging(ValueListItemListOption { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ValueListItemListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Radar/ValueLists/ValueListService.cs b/src/Stripe.net/Services/Radar/ValueLists/ValueListService.cs index 59eeef3a4d..b9bcdbe32a 100644 --- a/src/Stripe.net/Services/Radar/ValueLists/ValueListService.cs +++ b/src/Stripe.net/Services/Radar/ValueLists/ValueListService.cs @@ -67,6 +67,13 @@ public virtual IEnumerable ListAutoPaging(ValueListListOptions option return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ValueListListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual ValueList Update(string valueListId, ValueListUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(valueListId, options, requestOptions); diff --git a/src/Stripe.net/Services/Refunds/RefundService.cs b/src/Stripe.net/Services/Refunds/RefundService.cs index 343229f582..5609ea3d2e 100644 --- a/src/Stripe.net/Services/Refunds/RefundService.cs +++ b/src/Stripe.net/Services/Refunds/RefundService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(RefundListOptions options = nu return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(RefundListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Refund Update(string refundId, RefundUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(refundId, options, requestOptions); diff --git a/src/Stripe.net/Services/Reporting/ReportRuns/ReportRunService.cs b/src/Stripe.net/Services/Reporting/ReportRuns/ReportRunService.cs index bc771998fe..f5f120169b 100644 --- a/src/Stripe.net/Services/Reporting/ReportRuns/ReportRunService.cs +++ b/src/Stripe.net/Services/Reporting/ReportRuns/ReportRunService.cs @@ -55,5 +55,12 @@ public virtual IEnumerable ListAutoPaging(ReportRunListOptions option { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ReportRunListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Reporting/ReportTypes/ReportTypeService.cs b/src/Stripe.net/Services/Reporting/ReportTypes/ReportTypeService.cs index ae3e5c184b..a62db6ba3c 100644 --- a/src/Stripe.net/Services/Reporting/ReportTypes/ReportTypeService.cs +++ b/src/Stripe.net/Services/Reporting/ReportTypes/ReportTypeService.cs @@ -44,5 +44,12 @@ public virtual IEnumerable ListAutoPaging(ReportTypeListOptions opti { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ReportTypeListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Reviews/ReviewService.cs b/src/Stripe.net/Services/Reviews/ReviewService.cs index 22e7972b91..4ff7a807a4 100644 --- a/src/Stripe.net/Services/Reviews/ReviewService.cs +++ b/src/Stripe.net/Services/Reviews/ReviewService.cs @@ -55,5 +55,12 @@ public virtual IEnumerable ListAutoPaging(ReviewListOptions options = nu { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ReviewListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/SetupIntents/SetupIntentService.cs b/src/Stripe.net/Services/SetupIntents/SetupIntentService.cs index d539036c84..68d4da7ae6 100644 --- a/src/Stripe.net/Services/SetupIntents/SetupIntentService.cs +++ b/src/Stripe.net/Services/SetupIntents/SetupIntentService.cs @@ -79,6 +79,13 @@ public virtual IEnumerable ListAutoPaging(SetupIntentListOptions op return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(SetupIntentListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual SetupIntent Update(string setupIntentId, SetupIntentUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(setupIntentId, options, requestOptions); diff --git a/src/Stripe.net/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunService.cs b/src/Stripe.net/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunService.cs index 58550c6779..6e52a50ba9 100644 --- a/src/Stripe.net/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunService.cs +++ b/src/Stripe.net/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunService.cs @@ -44,5 +44,12 @@ public virtual IEnumerable ListAutoPaging(ScheduledQueryRunLi { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ScheduledQueryRunListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Skus/SkuService.cs b/src/Stripe.net/Services/Skus/SkuService.cs index b0f4a13528..f4b0c3f7e9 100644 --- a/src/Stripe.net/Services/Skus/SkuService.cs +++ b/src/Stripe.net/Services/Skus/SkuService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(SkuListOptions options = null, Re return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(SkuListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Sku Update(string skuId, SkuUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(skuId, options, requestOptions); diff --git a/src/Stripe.net/Services/SourceTransactions/SourceTransactionService.cs b/src/Stripe.net/Services/SourceTransactions/SourceTransactionService.cs index 22225a1bb4..7c8b6f074f 100644 --- a/src/Stripe.net/Services/SourceTransactions/SourceTransactionService.cs +++ b/src/Stripe.net/Services/SourceTransactions/SourceTransactionService.cs @@ -33,5 +33,12 @@ public virtual IEnumerable ListAutoPaging(string sourceId, So { return this.ListNestedEntitiesAutoPaging(sourceId, options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string sourceId, SourceTransactionsListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(sourceId, options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/Sources/SourceService.cs b/src/Stripe.net/Services/Sources/SourceService.cs index e7fb4491eb..126b23d5cb 100644 --- a/src/Stripe.net/Services/Sources/SourceService.cs +++ b/src/Stripe.net/Services/Sources/SourceService.cs @@ -79,6 +79,13 @@ public virtual IEnumerable ListAutoPaging(string customerId, SourceListO return this.ListRequestAutoPaging($"/v1/customers/{customerId}/sources", options ?? new SourceListOptions(), requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string customerId, SourceListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListRequestAutoPagingAsync($"/v1/customers/{customerId}/sources", options ?? new SourceListOptions(), requestOptions, cancellationToken); + } +#endif + public virtual Source Update(string sourceId, SourceUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(sourceId, options, requestOptions); diff --git a/src/Stripe.net/Services/SubscriptionItems/SubscriptionItemService.cs b/src/Stripe.net/Services/SubscriptionItems/SubscriptionItemService.cs index 80745910fd..0484c3e7d9 100644 --- a/src/Stripe.net/Services/SubscriptionItems/SubscriptionItemService.cs +++ b/src/Stripe.net/Services/SubscriptionItems/SubscriptionItemService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(SubscriptionItemList return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(SubscriptionItemListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual SubscriptionItem Update(string subscriptionItemId, SubscriptionItemUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(subscriptionItemId, options, requestOptions); diff --git a/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleService.cs b/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleService.cs index 1153c70c86..6b9bd57a3e 100644 --- a/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleService.cs +++ b/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(SubscriptionSche return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(SubscriptionScheduleListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual SubscriptionSchedule Release(string scheduleId, SubscriptionScheduleReleaseOptions options = null, RequestOptions requestOptions = null) { return this.Request(HttpMethod.Post, $"{this.InstanceUrl(scheduleId)}/release", options, requestOptions); diff --git a/src/Stripe.net/Services/Subscriptions/SubscriptionService.cs b/src/Stripe.net/Services/Subscriptions/SubscriptionService.cs index 2946862648..0553e9232b 100644 --- a/src/Stripe.net/Services/Subscriptions/SubscriptionService.cs +++ b/src/Stripe.net/Services/Subscriptions/SubscriptionService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(SubscriptionListOptions return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(SubscriptionListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Subscription Update(string subscriptionId, SubscriptionUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(subscriptionId, options, requestOptions); diff --git a/src/Stripe.net/Services/TaxIds/TaxIdService.cs b/src/Stripe.net/Services/TaxIds/TaxIdService.cs index 25a3c514cc..ae17ea667e 100644 --- a/src/Stripe.net/Services/TaxIds/TaxIdService.cs +++ b/src/Stripe.net/Services/TaxIds/TaxIdService.cs @@ -67,5 +67,12 @@ public virtual IEnumerable ListAutoPaging(string customerId, TaxIdListOpt { return this.ListNestedEntitiesAutoPaging(customerId, options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string customerId, TaxIdListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(customerId, options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/TaxRates/TaxRateService.cs b/src/Stripe.net/Services/TaxRates/TaxRateService.cs index 00b086e65c..04d153522a 100644 --- a/src/Stripe.net/Services/TaxRates/TaxRateService.cs +++ b/src/Stripe.net/Services/TaxRates/TaxRateService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(TaxRateListOptions options = return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(TaxRateListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual TaxRate Update(string taxRateId, TaxRateUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(taxRateId, options, requestOptions); diff --git a/src/Stripe.net/Services/Terminal/Locations/LocationService.cs b/src/Stripe.net/Services/Terminal/Locations/LocationService.cs index 33348931ad..a7069d44d1 100644 --- a/src/Stripe.net/Services/Terminal/Locations/LocationService.cs +++ b/src/Stripe.net/Services/Terminal/Locations/LocationService.cs @@ -70,6 +70,13 @@ public virtual IEnumerable ListAutoPaging(LocationListOptions options return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(LocationListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Location Update(string locationId, LocationUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(locationId, options, requestOptions); diff --git a/src/Stripe.net/Services/Terminal/Readers/ReaderService.cs b/src/Stripe.net/Services/Terminal/Readers/ReaderService.cs index 08ddd65be3..cc5b4a6b88 100644 --- a/src/Stripe.net/Services/Terminal/Readers/ReaderService.cs +++ b/src/Stripe.net/Services/Terminal/Readers/ReaderService.cs @@ -70,6 +70,13 @@ public virtual IEnumerable ListAutoPaging(ReaderListOptions options = nu return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ReaderListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Reader Update(string readerId, ReaderUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(readerId, options, requestOptions); diff --git a/src/Stripe.net/Services/Topups/TopupService.cs b/src/Stripe.net/Services/Topups/TopupService.cs index 17d86cef01..6be93a6c24 100644 --- a/src/Stripe.net/Services/Topups/TopupService.cs +++ b/src/Stripe.net/Services/Topups/TopupService.cs @@ -69,6 +69,13 @@ public virtual IEnumerable ListAutoPaging(TopupListOptions options = null return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(TopupListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Topup Update(string topupId, TopupUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(topupId, options, requestOptions); diff --git a/src/Stripe.net/Services/TransferReversals/TransferReversalService.cs b/src/Stripe.net/Services/TransferReversals/TransferReversalService.cs index 00b411ec8f..3606922834 100644 --- a/src/Stripe.net/Services/TransferReversals/TransferReversalService.cs +++ b/src/Stripe.net/Services/TransferReversals/TransferReversalService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(string transferId, T return this.ListNestedEntitiesAutoPaging(transferId, options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string transferId, TransferReversalListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(transferId, options, requestOptions, cancellationToken); + } +#endif + public virtual TransferReversal Update(string transferId, string reversalId, TransferReversalUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateNestedEntity(transferId, reversalId, options, requestOptions); diff --git a/src/Stripe.net/Services/Transfers/TransferService.cs b/src/Stripe.net/Services/Transfers/TransferService.cs index a2bef8d1f7..b516fbf6e4 100644 --- a/src/Stripe.net/Services/Transfers/TransferService.cs +++ b/src/Stripe.net/Services/Transfers/TransferService.cs @@ -58,6 +58,13 @@ public virtual IEnumerable ListAutoPaging(TransferListOptions options return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(TransferListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual Transfer Update(string transferId, TransferUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(transferId, options, requestOptions); diff --git a/src/Stripe.net/Services/UsageRecordSummaries/UsageRecordSummaryService.cs b/src/Stripe.net/Services/UsageRecordSummaries/UsageRecordSummaryService.cs index 3d409705b5..02e2df0fd7 100644 --- a/src/Stripe.net/Services/UsageRecordSummaries/UsageRecordSummaryService.cs +++ b/src/Stripe.net/Services/UsageRecordSummaries/UsageRecordSummaryService.cs @@ -33,5 +33,12 @@ public virtual IEnumerable ListAutoPaging(string subscriptio { return this.ListNestedEntitiesAutoPaging(subscriptionItemId, options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(string subscriptionItemId, UsageRecordSummaryListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListNestedEntitiesAutoPagingAsync(subscriptionItemId, options, requestOptions, cancellationToken); + } +#endif } } diff --git a/src/Stripe.net/Services/WebhookEndpoints/WebhookEndpointService.cs b/src/Stripe.net/Services/WebhookEndpoints/WebhookEndpointService.cs index 410e82046b..97139b3812 100644 --- a/src/Stripe.net/Services/WebhookEndpoints/WebhookEndpointService.cs +++ b/src/Stripe.net/Services/WebhookEndpoints/WebhookEndpointService.cs @@ -68,6 +68,13 @@ public virtual IEnumerable ListAutoPaging(WebhookEndpointListOp return this.ListEntitiesAutoPaging(options, requestOptions); } +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(WebhookEndpointListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif + public virtual WebhookEndpoint Update(string endpointId, WebhookEndpointUpdateOptions options, RequestOptions requestOptions = null) { return this.UpdateEntity(endpointId, options, requestOptions); diff --git a/src/Stripe.net/Services/_base/Service.cs b/src/Stripe.net/Services/_base/Service.cs index 9737bf5114..4fec08e382 100644 --- a/src/Stripe.net/Services/_base/Service.cs +++ b/src/Stripe.net/Services/_base/Service.cs @@ -6,9 +6,11 @@ namespace Stripe using System.Net; using System.Net.Http; using System.Reflection; +#if !NET45 + using System.Runtime.CompilerServices; +#endif using System.Threading; using System.Threading.Tasks; - using Stripe.Infrastructure; /// Abstract base class for all services. /// @@ -163,6 +165,20 @@ protected IEnumerable ListEntitiesAutoPaging( requestOptions); } +#if !NET45 + protected IAsyncEnumerable ListEntitiesAutoPagingAsync( + ListOptions options, + RequestOptions requestOptions, + CancellationToken cancellationToken) + { + return this.ListRequestAutoPagingAsync( + this.ClassUrl(), + options, + requestOptions, + cancellationToken); + } +#endif + protected TEntityReturned UpdateEntity( string id, BaseOptions options, @@ -245,6 +261,91 @@ protected async Task RequestAsync( cancellationToken).ConfigureAwait(false); } +#if !NET45 + protected IEnumerable ListRequestAutoPaging( + string url, + ListOptions options, + RequestOptions requestOptions) + where T : IStripeEntity + { + return this.ListRequestAutoPagingAsync(url, options, requestOptions) + .ToEnumerable(); + } + + protected async IAsyncEnumerable ListRequestAutoPagingAsync( + string url, + ListOptions options, + RequestOptions requestOptions, + [EnumeratorCancellation] CancellationToken cancellationToken = default) + where T : IStripeEntity + { + var page = await this.RequestAsync>( + HttpMethod.Get, + url, + options, + requestOptions, + cancellationToken); + + options = options ?? new ListOptions(); + bool iterateBackward = false; + + // Backward iterating activates if we have an `EndingBefore` + // constraint and not a `StartingAfter` constraint + if (!string.IsNullOrEmpty(options.EndingBefore) && string.IsNullOrEmpty(options.StartingAfter)) + { + iterateBackward = true; + } + + while (true) + { + cancellationToken.ThrowIfCancellationRequested(); + + if (iterateBackward) + { + page.Reverse(); + } + + string itemId = null; + foreach (var item in page) + { + cancellationToken.ThrowIfCancellationRequested(); + + // Elements in `StripeList` instances are decoded by `StripeObjectConverter`, + // which returns `null` for objects it doesn't know how to decode. + // When auto-paginating, we simply ignore these null elements but still return + // other elements. + if (item == null) + { + continue; + } + + itemId = ((IHasId)item).Id; + yield return item; + } + + if (!page.HasMore || string.IsNullOrEmpty(itemId)) + { + break; + } + + if (iterateBackward) + { + options.EndingBefore = itemId; + } + else + { + options.StartingAfter = itemId; + } + + page = await this.RequestAsync>( + HttpMethod.Get, + url, + options, + requestOptions, + cancellationToken); + } + } +#else protected IEnumerable ListRequestAutoPaging( string url, ListOptions options, @@ -311,6 +412,7 @@ protected IEnumerable ListRequestAutoPaging( requestOptions); } } +#endif protected RequestOptions SetupRequestOptions(RequestOptions requestOptions) { diff --git a/src/Stripe.net/Services/_base/ServiceNested.cs b/src/Stripe.net/Services/_base/ServiceNested.cs index f42aff74fe..7b7754fb2a 100644 --- a/src/Stripe.net/Services/_base/ServiceNested.cs +++ b/src/Stripe.net/Services/_base/ServiceNested.cs @@ -139,6 +139,21 @@ protected IEnumerable ListNestedEntitiesAutoPaging( requestOptions); } +#if !NET45 + protected IAsyncEnumerable ListNestedEntitiesAutoPagingAsync( + string parentId, + ListOptions options, + RequestOptions requestOptions, + CancellationToken cancellationToken) + { + return this.ListRequestAutoPagingAsync( + this.ClassUrl(parentId), + options, + requestOptions, + cancellationToken); + } +#endif + protected TEntityReturned UpdateNestedEntity( string parentId, string id, diff --git a/src/Stripe.net/Services/_interfaces/IListable.cs b/src/Stripe.net/Services/_interfaces/IListable.cs index 5bab71418f..70d8913d12 100644 --- a/src/Stripe.net/Services/_interfaces/IListable.cs +++ b/src/Stripe.net/Services/_interfaces/IListable.cs @@ -13,5 +13,9 @@ public interface IListable Task> ListAsync(TOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default); IEnumerable ListAutoPaging(TOptions listOptions = null, RequestOptions requestOptions = null); + +#if !NET45 + IAsyncEnumerable ListAutoPagingAsync(TOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default); +#endif } } diff --git a/src/Stripe.net/Services/_interfaces/INestedListable.cs b/src/Stripe.net/Services/_interfaces/INestedListable.cs index e63c10707b..1a9208793f 100644 --- a/src/Stripe.net/Services/_interfaces/INestedListable.cs +++ b/src/Stripe.net/Services/_interfaces/INestedListable.cs @@ -13,5 +13,9 @@ public interface INestedListable Task> ListAsync(string parentId, TOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default); IEnumerable ListAutoPaging(string parentId, TOptions listOptions = null, RequestOptions requestOptions = null); + +#if !NET45 + IAsyncEnumerable ListAutoPagingAsync(string parentId, TOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default); +#endif } } diff --git a/src/Stripe.net/Stripe.net.csproj b/src/Stripe.net/Stripe.net.csproj index a63ed0a402..e004346cf3 100644 --- a/src/Stripe.net/Stripe.net.csproj +++ b/src/Stripe.net/Stripe.net.csproj @@ -6,6 +6,11 @@ Stripe.net 35.7.0 35.7.0 + 35.6.0 + 35.6.0 + 8 + 35.3.0 + 35.3.0 Stripe, Jayme Davis netstandard2.0;net461;net45 Stripe.net @@ -39,11 +44,15 @@ + + + + diff --git a/src/StripeTests/Services/Accounts/AccountServiceTest.cs b/src/StripeTests/Services/Accounts/AccountServiceTest.cs index d4e102d1bd..245fcb1b87 100644 --- a/src/StripeTests/Services/Accounts/AccountServiceTest.cs +++ b/src/StripeTests/Services/Accounts/AccountServiceTest.cs @@ -216,10 +216,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var accounts = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(accounts); - Assert.Equal("account", accounts[0].Object); + var account = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(account); + Assert.Equal("account", account.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var account = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(account); + Assert.Equal("account", account.Object); } +#endif [Fact] public void Reject() diff --git a/src/StripeTests/Services/ApplePayDomains/ApplePayDomainServiceTest.cs b/src/StripeTests/Services/ApplePayDomains/ApplePayDomainServiceTest.cs index 62fe2142da..f0da10b68a 100644 --- a/src/StripeTests/Services/ApplePayDomains/ApplePayDomainServiceTest.cs +++ b/src/StripeTests/Services/ApplePayDomains/ApplePayDomainServiceTest.cs @@ -110,9 +110,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var domains = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(domains); - Assert.Equal("apple_pay_domain", domains[0].Object); + var domain = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(domain); + Assert.Equal("apple_pay_domain", domain.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var domain = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(domain); + Assert.Equal("apple_pay_domain", domain.Object); } +#endif } } diff --git a/src/StripeTests/Services/ApplicationFeeRefunds/ApplicationFeeRefundServiceTest.cs b/src/StripeTests/Services/ApplicationFeeRefunds/ApplicationFeeRefundServiceTest.cs index 6393ff1da2..07b8d5ea81 100644 --- a/src/StripeTests/Services/ApplicationFeeRefunds/ApplicationFeeRefundServiceTest.cs +++ b/src/StripeTests/Services/ApplicationFeeRefunds/ApplicationFeeRefundServiceTest.cs @@ -109,10 +109,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var applicationFeeRefunds = this.service.ListAutoPaging(ApplicationFeeId, this.listOptions).ToList(); - Assert.NotNull(applicationFeeRefunds); - Assert.Equal("fee_refund", applicationFeeRefunds[0].Object); + var applicationFeeRefund = this.service.ListAutoPaging(ApplicationFeeId, this.listOptions).First(); + Assert.NotNull(applicationFeeRefund); + Assert.Equal("fee_refund", applicationFeeRefund.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var applicationFeeRefund = await this.service.ListAutoPagingAsync(ApplicationFeeId, this.listOptions).FirstAsync(); + Assert.NotNull(applicationFeeRefund); + Assert.Equal("fee_refund", applicationFeeRefund.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/ApplicationFees/ApplicationFeeServiceTest.cs b/src/StripeTests/Services/ApplicationFees/ApplicationFeeServiceTest.cs index 1a67b0a2df..41c0c7a7f3 100644 --- a/src/StripeTests/Services/ApplicationFees/ApplicationFeeServiceTest.cs +++ b/src/StripeTests/Services/ApplicationFees/ApplicationFeeServiceTest.cs @@ -70,9 +70,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var applicationFees = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(applicationFees); - Assert.Equal("application_fee", applicationFees[0].Object); + var applicationFee = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(applicationFee); + Assert.Equal("application_fee", applicationFee.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var applicationFee = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(applicationFee); + Assert.Equal("application_fee", applicationFee.Object); } +#endif } } diff --git a/src/StripeTests/Services/AutoPagingTest.cs b/src/StripeTests/Services/AutoPagingTest.cs index dc587fd020..2586d7e2f9 100644 --- a/src/StripeTests/Services/AutoPagingTest.cs +++ b/src/StripeTests/Services/AutoPagingTest.cs @@ -287,6 +287,356 @@ public void ListAutoPaging_EndingBefore() ItExpr.IsAny()); } +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + // Set up stubbed requests + var response1 = new HttpResponseMessage(HttpStatusCode.OK); + response1.Content = new StringContent(GetResourceAsString("pageable_models.0.json")); + var response2 = new HttpResponseMessage(HttpStatusCode.OK); + response2.Content = new StringContent(GetResourceAsString("pageable_models.1.json")); + var response3 = new HttpResponseMessage(HttpStatusCode.OK); + response3.Content = new StringContent(GetResourceAsString("pageable_models.2.json")); + + this.MockHttpClientFixture.MockHandler.Protected() + .SetupSequence>( + "SendAsync", + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels"), + ItExpr.IsAny()) + .Returns(Task.FromResult(response1)) + .Returns(Task.FromResult(response2)) + .Returns(Task.FromResult(response3)) + .Throws(new StripeTestException("Unexpected invocation!")); + + // Call auto-paging method + var service = new PageableService(this.StripeClient); + var options = new ListOptions + { + Limit = 2, + }; + var models = await service.ListAutoPagingAsync(options).ToListAsync(); + + // Check results + Assert.Equal(5, models.Count); + Assert.Equal("pm_123", models[0].Id); + Assert.Equal("pm_124", models[1].Id); + Assert.Equal("pm_125", models[2].Id); + Assert.Equal("pm_126", models[3].Id); + Assert.Equal("pm_127", models[4].Id); + + // Check invocations + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&starting_after=pm_124"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&starting_after=pm_126"), + ItExpr.IsAny()); + } + + [Fact] + public async Task ListAutoPagingAsync_NoParams() + { + // Set up stubbed requests + var response1 = new HttpResponseMessage(HttpStatusCode.OK); + response1.Content = new StringContent(GetResourceAsString("pageable_models.0.json")); + var response2 = new HttpResponseMessage(HttpStatusCode.OK); + response2.Content = new StringContent(GetResourceAsString("pageable_models.1.json")); + var response3 = new HttpResponseMessage(HttpStatusCode.OK); + response3.Content = new StringContent(GetResourceAsString("pageable_models.2.json")); + + this.MockHttpClientFixture.MockHandler.Protected() + .SetupSequence>( + "SendAsync", + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels"), + ItExpr.IsAny()) + .Returns(Task.FromResult(response1)) + .Returns(Task.FromResult(response2)) + .Returns(Task.FromResult(response3)) + .Throws(new StripeTestException("Unexpected invocation!")); + + // Call auto-paging method + var service = new PageableService(this.StripeClient); + var models = await service.ListAutoPagingAsync().ToListAsync(); + + // Check results + Assert.Equal(5, models.Count); + Assert.Equal("pm_123", models[0].Id); + Assert.Equal("pm_124", models[1].Id); + Assert.Equal("pm_125", models[2].Id); + Assert.Equal("pm_126", models[3].Id); + Assert.Equal("pm_127", models[4].Id); + + // Check invocations + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == string.Empty), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?starting_after=pm_124"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?starting_after=pm_126"), + ItExpr.IsAny()); + } + + [Fact] + public async Task ListAutoPagingAsync_StartingAfter() + { + // Set up stubbed requests + var response1 = new HttpResponseMessage(HttpStatusCode.OK); + response1.Content = new StringContent(GetResourceAsString("pageable_models.1.json")); + var response2 = new HttpResponseMessage(HttpStatusCode.OK); + response2.Content = new StringContent(GetResourceAsString("pageable_models.2.json")); + + this.MockHttpClientFixture.MockHandler.Protected() + .SetupSequence>( + "SendAsync", + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels"), + ItExpr.IsAny()) + .Returns(Task.FromResult(response1)) + .Returns(Task.FromResult(response2)) + .Throws(new StripeTestException("Unexpected invocation!")); + + // Call auto-paging method + var service = new PageableService(this.StripeClient); + var options = new ListOptions + { + Limit = 2, + StartingAfter = "pm_124", + }; + var models = await service.ListAutoPagingAsync(options).ToListAsync(); + + // Check results + Assert.Equal(3, models.Count); + Assert.Equal("pm_125", models[0].Id); + Assert.Equal("pm_126", models[1].Id); + Assert.Equal("pm_127", models[2].Id); + + // Check invocations + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&starting_after=pm_124"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&starting_after=pm_126"), + ItExpr.IsAny()); + } + + [Fact] + public async Task ListAutoPagingAsync_EndingBefore() + { + // Set up stubbed requests + var response1 = new HttpResponseMessage(HttpStatusCode.OK); + response1.Content = new StringContent(GetResourceAsString("pageable_models.1.json")); + var response2 = new HttpResponseMessage(HttpStatusCode.OK); + response2.Content = new StringContent(GetResourceAsString("pageable_models.0.json")); + var response3 = new HttpResponseMessage(HttpStatusCode.OK); + response3.Content = new StringContent(GetResourceAsString("pageable_models.0b.json")); + + this.MockHttpClientFixture.MockHandler.Protected() + .SetupSequence>( + "SendAsync", + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels"), + ItExpr.IsAny()) + .Returns(Task.FromResult(response1)) + .Returns(Task.FromResult(response2)) + .Returns(Task.FromResult(response3)) + .Throws(new StripeTestException("Unexpected invocation!")); + + // Call auto-paging method + var service = new PageableService(this.StripeClient); + var options = new ListOptions + { + Limit = 2, + EndingBefore = "pm_127", + }; + var models = await service.ListAutoPagingAsync(options).ToListAsync(); + + // Check results + Assert.Equal(5, models.Count); + Assert.Equal("pm_126", models[0].Id); + Assert.Equal("pm_125", models[1].Id); + Assert.Equal("pm_124", models[2].Id); + Assert.Equal("pm_123", models[3].Id); + Assert.Equal("pm_122", models[4].Id); + + // Check invocations + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&ending_before=pm_127"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&ending_before=pm_125"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&ending_before=pm_123"), + ItExpr.IsAny()); + } + + [Fact] + public async Task ListAutoPagingAsync_WithCancellation() + { + // Set up stubbed requests + var response1 = new HttpResponseMessage(HttpStatusCode.OK); + response1.Content = new StringContent(GetResourceAsString("pageable_models.0.json")); + var response2 = new HttpResponseMessage(HttpStatusCode.OK); + response2.Content = new StringContent(GetResourceAsString("pageable_models.1.json")); + + this.MockHttpClientFixture.MockHandler.Protected() + .SetupSequence>( + "SendAsync", + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels"), + ItExpr.IsAny()) + .Returns(Task.FromResult(response1)) + .Returns(Task.FromResult(response2)) + .Throws(new StripeTestException("Unexpected invocation!")); + + // Call auto-paging method + var service = new PageableService(this.StripeClient); + var options = new ListOptions + { + Limit = 2, + }; + var models = new List(); + + var source = new CancellationTokenSource(); + + try + { + await foreach (var model in service.ListAutoPagingAsync(options).WithCancellation(source.Token)) + { + models.Add(model); + + // Cancel in the middle of the second page + if (model.Id == "pm_125") + { + source.Cancel(); + } + } + + Assert.True(false, "Exception OperationCanceledException to be thrown"); + } + catch (OperationCanceledException) + { + } + finally + { + source.Dispose(); + } + + // Check results + Assert.Equal(3, models.Count); + Assert.Equal("pm_123", models[0].Id); + Assert.Equal("pm_124", models[1].Id); + Assert.Equal("pm_125", models[2].Id); + + // Check invocations + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2"), + ItExpr.IsAny()); + + this.MockHttpClientFixture.MockHandler.Protected() + .Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(m => + m.Method == HttpMethod.Get && + m.RequestUri.AbsolutePath == "/v1/pageablemodels" && + m.RequestUri.Query == "?limit=2&starting_after=pm_124"), + ItExpr.IsAny()); + } +#endif + public class PageableModel : StripeEntity, IHasId { [JsonProperty("id")] @@ -302,10 +652,17 @@ public PageableService(IStripeClient client) public override string BasePath => "/v1/pageablemodels"; - public IEnumerable ListAutoPaging(ListOptions options = null) + public IEnumerable ListAutoPaging(ListOptions options = null, RequestOptions requestOptions = null) + { + return this.ListEntitiesAutoPaging(options, requestOptions); + } + +#if !NET45 + public IAsyncEnumerable ListAutoPagingAsync(ListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { - return this.ListEntitiesAutoPaging(options, null); + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); } +#endif } } } diff --git a/src/StripeTests/Services/BalanceTransactions/BalanceTransactionServiceTest.cs b/src/StripeTests/Services/BalanceTransactions/BalanceTransactionServiceTest.cs index 4cd8cea217..b2651ae083 100644 --- a/src/StripeTests/Services/BalanceTransactions/BalanceTransactionServiceTest.cs +++ b/src/StripeTests/Services/BalanceTransactions/BalanceTransactionServiceTest.cs @@ -70,9 +70,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var balanceTransactions = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(balanceTransactions); - Assert.Equal("balance_transaction", balanceTransactions[0].Object); + var balanceTransaction = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(balanceTransaction); + Assert.Equal("balance_transaction", balanceTransaction.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var balanceTransaction = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(balanceTransaction); + Assert.Equal("balance_transaction", balanceTransaction.Object); } +#endif } } diff --git a/src/StripeTests/Services/BankAccounts/BankAccountServiceTest.cs b/src/StripeTests/Services/BankAccounts/BankAccountServiceTest.cs index 5c83bb5575..a549ffdeee 100644 --- a/src/StripeTests/Services/BankAccounts/BankAccountServiceTest.cs +++ b/src/StripeTests/Services/BankAccounts/BankAccountServiceTest.cs @@ -125,9 +125,18 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var bankAccounts = this.service.ListAutoPaging(CustomerId, this.listOptions).ToList(); - Assert.NotNull(bankAccounts); + var bankAccount = this.service.ListAutoPaging(CustomerId, this.listOptions).First(); + Assert.NotNull(bankAccount); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var bankAccount = await this.service.ListAutoPagingAsync(CustomerId, this.listOptions).FirstAsync(); + Assert.NotNull(bankAccount); } +#endif // stripe-mock does not return a bank account object on update today so we do not test // the returned value's object diff --git a/src/StripeTests/Services/Capabilities/CapabilityServiceTest.cs b/src/StripeTests/Services/Capabilities/CapabilityServiceTest.cs index a0038f61af..11eae55260 100644 --- a/src/StripeTests/Services/Capabilities/CapabilityServiceTest.cs +++ b/src/StripeTests/Services/Capabilities/CapabilityServiceTest.cs @@ -76,10 +76,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var capabilities = this.service.ListAutoPaging(AccountId, this.listOptions).ToList(); - Assert.NotNull(capabilities); - Assert.Equal("capability", capabilities[0].Object); + var capabilitie = this.service.ListAutoPaging(AccountId, this.listOptions).First(); + Assert.NotNull(capabilitie); + Assert.Equal("capability", capabilitie.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var capabilitie = await this.service.ListAutoPagingAsync(AccountId, this.listOptions).FirstAsync(); + Assert.NotNull(capabilitie); + Assert.Equal("capability", capabilitie.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Cards/CardServiceTest.cs b/src/StripeTests/Services/Cards/CardServiceTest.cs index 7f1599b597..807d7a8c79 100644 --- a/src/StripeTests/Services/Cards/CardServiceTest.cs +++ b/src/StripeTests/Services/Cards/CardServiceTest.cs @@ -119,9 +119,18 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var cards = this.service.ListAutoPaging(CustomerId, this.listOptions).ToList(); - Assert.NotNull(cards); + var card = this.service.ListAutoPaging(CustomerId, this.listOptions).First(); + Assert.NotNull(card); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var card = await this.service.ListAutoPagingAsync(CustomerId, this.listOptions).FirstAsync(); + Assert.NotNull(card); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Charges/ChargeServiceTest.cs b/src/StripeTests/Services/Charges/ChargeServiceTest.cs index 3f32d811f4..e3c5d4b25b 100644 --- a/src/StripeTests/Services/Charges/ChargeServiceTest.cs +++ b/src/StripeTests/Services/Charges/ChargeServiceTest.cs @@ -130,10 +130,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var charges = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(charges); - Assert.Equal("charge", charges[0].Object); + var charge = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(charge); + Assert.Equal("charge", charge.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var charge = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(charge); + Assert.Equal("charge", charge.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Checkout/SessionServiceTest.cs b/src/StripeTests/Services/Checkout/SessionServiceTest.cs index 55a88ef4e4..bf7ac88fdb 100644 --- a/src/StripeTests/Services/Checkout/SessionServiceTest.cs +++ b/src/StripeTests/Services/Checkout/SessionServiceTest.cs @@ -134,9 +134,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var intents = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(intents); - Assert.Equal("checkout.session", intents[0].Object); + var intent = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(intent); + Assert.Equal("checkout.session", intent.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var intent = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(intent); + Assert.Equal("checkout.session", intent.Object); } +#endif } } diff --git a/src/StripeTests/Services/CountrySpecs/CountrySpecServiceTest.cs b/src/StripeTests/Services/CountrySpecs/CountrySpecServiceTest.cs index 4b51db8d27..0165ebe02e 100644 --- a/src/StripeTests/Services/CountrySpecs/CountrySpecServiceTest.cs +++ b/src/StripeTests/Services/CountrySpecs/CountrySpecServiceTest.cs @@ -70,9 +70,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var countrySpecs = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(countrySpecs); - Assert.Equal("country_spec", countrySpecs[0].Object); + var countrySpec = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(countrySpec); + Assert.Equal("country_spec", countrySpec.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var countrySpec = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(countrySpec); + Assert.Equal("country_spec", countrySpec.Object); } +#endif } } diff --git a/src/StripeTests/Services/Coupons/CouponServiceTest.cs b/src/StripeTests/Services/Coupons/CouponServiceTest.cs index b914294043..ddfa8ad3fc 100644 --- a/src/StripeTests/Services/Coupons/CouponServiceTest.cs +++ b/src/StripeTests/Services/Coupons/CouponServiceTest.cs @@ -121,10 +121,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var coupons = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(coupons); - Assert.Equal("coupon", coupons[0].Object); + var coupon = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(coupon); + Assert.Equal("coupon", coupon.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var coupon = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(coupon); + Assert.Equal("coupon", coupon.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/CreditNotes/CreditNoteServiceTest.cs b/src/StripeTests/Services/CreditNotes/CreditNoteServiceTest.cs index 2f51452d90..24bb6f9828 100644 --- a/src/StripeTests/Services/CreditNotes/CreditNoteServiceTest.cs +++ b/src/StripeTests/Services/CreditNotes/CreditNoteServiceTest.cs @@ -132,10 +132,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var creditNotes = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(creditNotes); - Assert.Equal("credit_note", creditNotes[0].Object); + var creditNote = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(creditNote); + Assert.Equal("credit_note", creditNote.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var creditNote = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(creditNote); + Assert.Equal("credit_note", creditNote.Object); } +#endif [Fact] public void ListLineItems() @@ -162,11 +172,21 @@ public async Task ListLineItemsAsync() [Fact] public void ListLineItemsAutoPaging() { - var lineItems = this.service.ListLineItemsAutoPaging(CreditNoteId, this.listLineItemsOptions).ToList(); - Assert.NotNull(lineItems); - Assert.Equal("credit_note_line_item", lineItems[0].Object); + var lineItem = this.service.ListLineItemsAutoPaging(CreditNoteId, this.listLineItemsOptions).First(); + Assert.NotNull(lineItem); + Assert.Equal("credit_note_line_item", lineItem.Object); } +#if !NET45 + [Fact] + public async Task ListLineItemsAutoPagingAsync() + { + var lineItem = await this.service.ListLineItemsAutoPagingAsync(CreditNoteId, this.listLineItemsOptions).FirstAsync(); + Assert.NotNull(lineItem); + Assert.Equal("credit_note_line_item", lineItem.Object); + } +#endif + [Fact] public void Preview() { @@ -210,10 +230,20 @@ public async Task ListPreviewLineItemsAsync() [Fact] public void ListPreviewLineItemsAutoPaging() { - var lineItems = this.service.ListPreviewLineItemsAutoPaging(this.listPreviewLineItemsOptions).ToList(); - Assert.NotNull(lineItems); - Assert.Equal("credit_note_line_item", lineItems[0].Object); + var lineItem = this.service.ListPreviewLineItemsAutoPaging(this.listPreviewLineItemsOptions).First(); + Assert.NotNull(lineItem); + Assert.Equal("credit_note_line_item", lineItem.Object); + } + +#if !NET45 + [Fact] + public async Task ListPreviewLineItemsAutoPagingAsync() + { + var lineItem = await this.service.ListPreviewLineItemsAutoPagingAsync(this.listPreviewLineItemsOptions).FirstAsync(); + Assert.NotNull(lineItem); + Assert.Equal("credit_note_line_item", lineItem.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/CustomerBalanceTransactions/CustomerBalanceTransactionServiceTest.cs b/src/StripeTests/Services/CustomerBalanceTransactions/CustomerBalanceTransactionServiceTest.cs index d7e0998fa8..38a31c23f4 100644 --- a/src/StripeTests/Services/CustomerBalanceTransactions/CustomerBalanceTransactionServiceTest.cs +++ b/src/StripeTests/Services/CustomerBalanceTransactions/CustomerBalanceTransactionServiceTest.cs @@ -102,10 +102,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var transactions = this.service.ListAutoPaging(CustomerId, this.listOptions).ToList(); - Assert.NotNull(transactions); - Assert.Equal("customer_balance_transaction", transactions[0].Object); + var transaction = this.service.ListAutoPaging(CustomerId, this.listOptions).First(); + Assert.NotNull(transaction); + Assert.Equal("customer_balance_transaction", transaction.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var transaction = await this.service.ListAutoPagingAsync(CustomerId, this.listOptions).FirstAsync(); + Assert.NotNull(transaction); + Assert.Equal("customer_balance_transaction", transaction.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Customers/CustomerServiceTest.cs b/src/StripeTests/Services/Customers/CustomerServiceTest.cs index 7b4511b9a6..ebe953c70f 100644 --- a/src/StripeTests/Services/Customers/CustomerServiceTest.cs +++ b/src/StripeTests/Services/Customers/CustomerServiceTest.cs @@ -121,10 +121,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var customers = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(customers); - Assert.Equal("customer", customers[0].Object); + var customer = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(customer); + Assert.Equal("customer", customer.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var customer = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(customer); + Assert.Equal("customer", customer.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Disputes/DisputeServiceTest.cs b/src/StripeTests/Services/Disputes/DisputeServiceTest.cs index df03be3706..a3000e97e0 100644 --- a/src/StripeTests/Services/Disputes/DisputeServiceTest.cs +++ b/src/StripeTests/Services/Disputes/DisputeServiceTest.cs @@ -98,10 +98,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var disputes = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(disputes); - Assert.Equal("dispute", disputes[0].Object); + var dispute = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(dispute); + Assert.Equal("dispute", dispute.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var dispute = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(dispute); + Assert.Equal("dispute", dispute.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Events/EventServiceTest.cs b/src/StripeTests/Services/Events/EventServiceTest.cs index 0e4f0bf8c3..0a40d4a3fa 100644 --- a/src/StripeTests/Services/Events/EventServiceTest.cs +++ b/src/StripeTests/Services/Events/EventServiceTest.cs @@ -70,9 +70,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var events = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(events); - Assert.Equal("event", events[0].Object); + var evt = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(evt); + Assert.Equal("event", evt.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var evt = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(evt); + Assert.Equal("event", evt.Object); } +#endif } } diff --git a/src/StripeTests/Services/ExchangeRates/ExchangeRateServiceTest.cs b/src/StripeTests/Services/ExchangeRates/ExchangeRateServiceTest.cs index 950a549271..0a6d8ff143 100644 --- a/src/StripeTests/Services/ExchangeRates/ExchangeRateServiceTest.cs +++ b/src/StripeTests/Services/ExchangeRates/ExchangeRateServiceTest.cs @@ -68,9 +68,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var exchangeRates = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(exchangeRates); - Assert.Equal("exchange_rate", exchangeRates[0].Object); + var exchangeRate = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(exchangeRate); + Assert.Equal("exchange_rate", exchangeRate.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var exchangeRate = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(exchangeRate); + Assert.Equal("exchange_rate", exchangeRate.Object); } +#endif } } diff --git a/src/StripeTests/Services/ExternalAccounts/ExternalAccountServiceTest.cs b/src/StripeTests/Services/ExternalAccounts/ExternalAccountServiceTest.cs index 0c7ba39cc2..4f0bc98e52 100644 --- a/src/StripeTests/Services/ExternalAccounts/ExternalAccountServiceTest.cs +++ b/src/StripeTests/Services/ExternalAccounts/ExternalAccountServiceTest.cs @@ -126,9 +126,18 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var externalAccounts = this.service.ListAutoPaging(AccountId, this.listOptions).ToList(); - Assert.NotNull(externalAccounts); + var externalAccount = this.service.ListAutoPaging(AccountId, this.listOptions).First(); + Assert.NotNull(externalAccount); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var externalAccount = await this.service.ListAutoPagingAsync(AccountId, this.listOptions).FirstAsync(); + Assert.NotNull(externalAccount); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/FileLinks/FileLinkServiceTest.cs b/src/StripeTests/Services/FileLinks/FileLinkServiceTest.cs index 5ee26b0b63..4fcb486f62 100644 --- a/src/StripeTests/Services/FileLinks/FileLinkServiceTest.cs +++ b/src/StripeTests/Services/FileLinks/FileLinkServiceTest.cs @@ -105,11 +105,21 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var domains = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(domains); - Assert.Equal("file_link", domains[0].Object); + var domain = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(domain); + Assert.Equal("file_link", domain.Object); } +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var domain = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(domain); + Assert.Equal("file_link", domain.Object); + } +#endif + [Fact] public void Update() { diff --git a/src/StripeTests/Services/Files/FileServiceTest.cs b/src/StripeTests/Services/Files/FileServiceTest.cs index 1b629b6719..113f2e155f 100644 --- a/src/StripeTests/Services/Files/FileServiceTest.cs +++ b/src/StripeTests/Services/Files/FileServiceTest.cs @@ -106,9 +106,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var files = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(files); - Assert.Equal("file", files[0].Object); + var file = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(file); + Assert.Equal("file", file.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var file = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(file); + Assert.Equal("file", file.Object); } +#endif } } diff --git a/src/StripeTests/Services/InvoiceItems/InvoiceItemServiceTest.cs b/src/StripeTests/Services/InvoiceItems/InvoiceItemServiceTest.cs index e9dc942e89..57f990b02c 100644 --- a/src/StripeTests/Services/InvoiceItems/InvoiceItemServiceTest.cs +++ b/src/StripeTests/Services/InvoiceItems/InvoiceItemServiceTest.cs @@ -122,10 +122,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var invoiceItems = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(invoiceItems); - Assert.Equal("invoiceitem", invoiceItems[0].Object); + var invoiceItem = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(invoiceItem); + Assert.Equal("invoiceitem", invoiceItem.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var invoiceItem = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(invoiceItem); + Assert.Equal("invoiceitem", invoiceItem.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Invoices/InvoiceServiceTest.cs b/src/StripeTests/Services/Invoices/InvoiceServiceTest.cs index 7224915cab..403cc0214d 100644 --- a/src/StripeTests/Services/Invoices/InvoiceServiceTest.cs +++ b/src/StripeTests/Services/Invoices/InvoiceServiceTest.cs @@ -189,10 +189,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var invoices = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(invoices); - Assert.Equal("invoice", invoices[0].Object); + var invoice = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(invoice); + Assert.Equal("invoice", invoice.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var invoice = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(invoice); + Assert.Equal("invoice", invoice.Object); } +#endif [Fact] public void ListLineItems() @@ -219,11 +229,21 @@ public async Task ListLineItemsAsync() [Fact] public void ListLineItemsAutoPaging() { - var lineItems = this.service.ListLineItemsAutoPaging(InvoiceId, this.listLineItemsOptions).ToList(); - Assert.NotNull(lineItems); - Assert.Equal("line_item", lineItems[0].Object); + var lineItem = this.service.ListLineItemsAutoPaging(InvoiceId, this.listLineItemsOptions).First(); + Assert.NotNull(lineItem); + Assert.Equal("line_item", lineItem.Object); } +#if !NET45 + [Fact] + public async Task ListLineItemsAutoPagingAsync() + { + var lineItem = await this.service.ListLineItemsAutoPagingAsync(InvoiceId, this.listLineItemsOptions).FirstAsync(); + Assert.NotNull(lineItem); + Assert.Equal("line_item", lineItem.Object); + } +#endif + [Fact] public void ListUpcomingLineItems() { @@ -249,10 +269,20 @@ public async Task ListUpcomingLineItemsAsync() [Fact] public void ListUpcomingLineItemsAutoPaging() { - var lineItems = this.service.ListUpcomingLineItemsAutoPaging(this.upcomingListLineItemsOptions).ToList(); - Assert.NotNull(lineItems); - Assert.Equal("line_item", lineItems[0].Object); + var lineItem = this.service.ListUpcomingLineItemsAutoPaging(this.upcomingListLineItemsOptions).First(); + Assert.NotNull(lineItem); + Assert.Equal("line_item", lineItem.Object); + } + +#if !NET45 + [Fact] + public async Task ListUpcomingLineItemsAutoPagingAsync() + { + var lineItem = await this.service.ListUpcomingLineItemsAutoPagingAsync(this.upcomingListLineItemsOptions).FirstAsync(); + Assert.NotNull(lineItem); + Assert.Equal("line_item", lineItem.Object); } +#endif [Fact] public void MarkUncollectible() diff --git a/src/StripeTests/Services/Issuing/Authorizations/AuthorizationServiceTest.cs b/src/StripeTests/Services/Issuing/Authorizations/AuthorizationServiceTest.cs index 1e2d785bc7..880a60e936 100644 --- a/src/StripeTests/Services/Issuing/Authorizations/AuthorizationServiceTest.cs +++ b/src/StripeTests/Services/Issuing/Authorizations/AuthorizationServiceTest.cs @@ -104,9 +104,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var authorizations = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(authorizations); + var authorization = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(authorization); + Assert.Equal("issuing.authorization", authorization.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var authorization = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(authorization); + Assert.Equal("issuing.authorization", authorization.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Issuing/Cardholders/CardholderServiceTest.cs b/src/StripeTests/Services/Issuing/Cardholders/CardholderServiceTest.cs index 472c58e0c6..08e6ac09ae 100644 --- a/src/StripeTests/Services/Issuing/Cardholders/CardholderServiceTest.cs +++ b/src/StripeTests/Services/Issuing/Cardholders/CardholderServiceTest.cs @@ -145,9 +145,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var cardholders = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(cardholders); + var cardholder = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(cardholder); + Assert.Equal("issuing.cardholder", cardholder.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var cardholder = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(cardholder); + Assert.Equal("issuing.cardholder", cardholder.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Issuing/Cards/IssuingCardServiceTest.cs b/src/StripeTests/Services/Issuing/Cards/IssuingCardServiceTest.cs index dce9c7c730..a73574a60c 100644 --- a/src/StripeTests/Services/Issuing/Cards/IssuingCardServiceTest.cs +++ b/src/StripeTests/Services/Issuing/Cards/IssuingCardServiceTest.cs @@ -126,9 +126,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var cards = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(cards); + var card = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(card); + Assert.Equal("issuing.card", card.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var card = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(card); + Assert.Equal("issuing.card", card.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Issuing/Disputes/IssuingDisputeServiceTest.cs b/src/StripeTests/Services/Issuing/Disputes/IssuingDisputeServiceTest.cs index bf0caa20d2..c13a84e8ab 100644 --- a/src/StripeTests/Services/Issuing/Disputes/IssuingDisputeServiceTest.cs +++ b/src/StripeTests/Services/Issuing/Disputes/IssuingDisputeServiceTest.cs @@ -103,9 +103,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var disputes = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(disputes); + var dispute = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(dispute); + Assert.Equal("issuing.dispute", dispute.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var dispute = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(dispute); + Assert.Equal("issuing.dispute", dispute.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Issuing/Transactions/TransactionServiceTest.cs b/src/StripeTests/Services/Issuing/Transactions/TransactionServiceTest.cs index a1ba17c174..516e7324d1 100644 --- a/src/StripeTests/Services/Issuing/Transactions/TransactionServiceTest.cs +++ b/src/StripeTests/Services/Issuing/Transactions/TransactionServiceTest.cs @@ -72,9 +72,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var transactions = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(transactions); + var transaction = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(transaction); + Assert.Equal("issuing.transaction", transaction.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var transaction = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(transaction); + Assert.Equal("issuing.transaction", transaction.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Orders/OrderServiceTest.cs b/src/StripeTests/Services/Orders/OrderServiceTest.cs index 1be538c221..c8c51f7913 100644 --- a/src/StripeTests/Services/Orders/OrderServiceTest.cs +++ b/src/StripeTests/Services/Orders/OrderServiceTest.cs @@ -131,10 +131,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var orders = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(orders); - Assert.Equal("order", orders[0].Object); + var order = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(order); + Assert.Equal("order", order.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var order = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(order); + Assert.Equal("order", order.Object); } +#endif [Fact] public void Pay() diff --git a/src/StripeTests/Services/PaymentIntents/PaymentIntentServiceTest.cs b/src/StripeTests/Services/PaymentIntents/PaymentIntentServiceTest.cs index 37528462c0..bc93833718 100644 --- a/src/StripeTests/Services/PaymentIntents/PaymentIntentServiceTest.cs +++ b/src/StripeTests/Services/PaymentIntents/PaymentIntentServiceTest.cs @@ -198,10 +198,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var intents = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(intents); - Assert.Equal("payment_intent", intents[0].Object); + var intent = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(intent); + Assert.Equal("payment_intent", intent.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var intent = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(intent); + Assert.Equal("payment_intent", intent.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/PaymentMethods/PaymentMethodServiceTest.cs b/src/StripeTests/Services/PaymentMethods/PaymentMethodServiceTest.cs index 4b56b5aaa1..4bc00ea621 100644 --- a/src/StripeTests/Services/PaymentMethods/PaymentMethodServiceTest.cs +++ b/src/StripeTests/Services/PaymentMethods/PaymentMethodServiceTest.cs @@ -156,9 +156,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var payment_methods = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(payment_methods); - Assert.Equal("payment_method", payment_methods[0].Object); + var payment_method = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(payment_method); + Assert.Equal("payment_method", payment_method.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var payment_method = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(payment_method); + Assert.Equal("payment_method", payment_method.Object); } +#endif } } diff --git a/src/StripeTests/Services/Payouts/PayoutServiceTest.cs b/src/StripeTests/Services/Payouts/PayoutServiceTest.cs index a45069bbbc..4e43ca942d 100644 --- a/src/StripeTests/Services/Payouts/PayoutServiceTest.cs +++ b/src/StripeTests/Services/Payouts/PayoutServiceTest.cs @@ -123,10 +123,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var payouts = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(payouts); - Assert.Equal("payout", payouts[0].Object); + var payout = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(payout); + Assert.Equal("payout", payout.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var payout = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(payout); + Assert.Equal("payout", payout.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Persons/PersonServiceTest.cs b/src/StripeTests/Services/Persons/PersonServiceTest.cs index 3ae4cfa6e8..2e6c853427 100644 --- a/src/StripeTests/Services/Persons/PersonServiceTest.cs +++ b/src/StripeTests/Services/Persons/PersonServiceTest.cs @@ -148,10 +148,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var persons = this.service.ListAutoPaging(AccountId, this.listOptions).ToList(); - Assert.NotNull(persons); - Assert.Equal("person", persons[0].Object); + var person = this.service.ListAutoPaging(AccountId, this.listOptions).First(); + Assert.NotNull(person); + Assert.Equal("person", person.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var person = await this.service.ListAutoPagingAsync(AccountId, this.listOptions).FirstAsync(); + Assert.NotNull(person); + Assert.Equal("person", person.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Plans/PlanServiceTest.cs b/src/StripeTests/Services/Plans/PlanServiceTest.cs index 8091932c2c..fa58845af4 100644 --- a/src/StripeTests/Services/Plans/PlanServiceTest.cs +++ b/src/StripeTests/Services/Plans/PlanServiceTest.cs @@ -170,10 +170,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var plans = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(plans); - Assert.Equal("plan", plans[0].Object); + var plan = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(plan); + Assert.Equal("plan", plan.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var plan = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(plan); + Assert.Equal("plan", plan.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Products/ProductServiceTest.cs b/src/StripeTests/Services/Products/ProductServiceTest.cs index 1fb8cca265..a2df6e9ec4 100644 --- a/src/StripeTests/Services/Products/ProductServiceTest.cs +++ b/src/StripeTests/Services/Products/ProductServiceTest.cs @@ -133,10 +133,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var products = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(products); - Assert.Equal("product", products[0].Object); + var product = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(product); + Assert.Equal("product", product.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var product = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(product); + Assert.Equal("product", product.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningServiceTest.cs b/src/StripeTests/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningServiceTest.cs index 8aebdda11d..becdcac366 100644 --- a/src/StripeTests/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningServiceTest.cs +++ b/src/StripeTests/Services/Radar/EarlyFraudWarnings/EarlyFraudWarningServiceTest.cs @@ -72,9 +72,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var warnings = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(warnings); - Assert.Equal("radar.early_fraud_warning", warnings[0].Object); + var warning = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(warning); + Assert.Equal("radar.early_fraud_warning", warning.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var warning = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(warning); + Assert.Equal("radar.early_fraud_warning", warning.Object); } +#endif } } diff --git a/src/StripeTests/Services/Radar/ValueListItems/ValueListItemServiceTest.cs b/src/StripeTests/Services/Radar/ValueListItems/ValueListItemServiceTest.cs index 4ee9df8168..048d2617fb 100644 --- a/src/StripeTests/Services/Radar/ValueListItems/ValueListItemServiceTest.cs +++ b/src/StripeTests/Services/Radar/ValueListItems/ValueListItemServiceTest.cs @@ -112,9 +112,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var valueListItems = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(valueListItems); - Assert.Equal("radar.value_list_item", valueListItems[0].Object); + var valueListItem = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(valueListItem); + Assert.Equal("radar.value_list_item", valueListItem.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var valueListItem = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(valueListItem); + Assert.Equal("radar.value_list_item", valueListItem.Object); } +#endif } } diff --git a/src/StripeTests/Services/Radar/ValueLists/ValueListServiceTest.cs b/src/StripeTests/Services/Radar/ValueLists/ValueListServiceTest.cs index 94cb862831..cb17de144e 100644 --- a/src/StripeTests/Services/Radar/ValueLists/ValueListServiceTest.cs +++ b/src/StripeTests/Services/Radar/ValueLists/ValueListServiceTest.cs @@ -123,10 +123,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var valueLists = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(valueLists); - Assert.Equal("radar.value_list", valueLists[0].Object); + var valueList = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(valueList); + Assert.Equal("radar.value_list", valueList.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var valueList = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(valueList); + Assert.Equal("radar.value_list", valueList.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Refunds/RefundServiceTest.cs b/src/StripeTests/Services/Refunds/RefundServiceTest.cs index 9f08782356..4a61202bb4 100644 --- a/src/StripeTests/Services/Refunds/RefundServiceTest.cs +++ b/src/StripeTests/Services/Refunds/RefundServiceTest.cs @@ -105,10 +105,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var refunds = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(refunds); - Assert.Equal("refund", refunds[0].Object); + var refund = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(refund); + Assert.Equal("refund", refund.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var refund = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(refund); + Assert.Equal("refund", refund.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Reporting/ReportRuns/ReportRunServiceTest.cs b/src/StripeTests/Services/Reporting/ReportRuns/ReportRunServiceTest.cs index 627b235f4e..7ce0d70ec5 100644 --- a/src/StripeTests/Services/Reporting/ReportRuns/ReportRunServiceTest.cs +++ b/src/StripeTests/Services/Reporting/ReportRuns/ReportRunServiceTest.cs @@ -89,8 +89,17 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var reportRuns = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(reportRuns); + var reportRun = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(reportRun); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var reportRun = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(reportRun); } +#endif } } diff --git a/src/StripeTests/Services/Reporting/ReportTypes/ReportTypeServiceTest.cs b/src/StripeTests/Services/Reporting/ReportTypes/ReportTypeServiceTest.cs index cb5dfd8707..c7537fb663 100644 --- a/src/StripeTests/Services/Reporting/ReportTypes/ReportTypeServiceTest.cs +++ b/src/StripeTests/Services/Reporting/ReportTypes/ReportTypeServiceTest.cs @@ -61,8 +61,17 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var reportTypes = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(reportTypes); + var reportType = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(reportType); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var reportType = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(reportType); } +#endif } } diff --git a/src/StripeTests/Services/Reviews/ReviewServiceTest.cs b/src/StripeTests/Services/Reviews/ReviewServiceTest.cs index d6a3bb31ed..3d6ab2ef95 100644 --- a/src/StripeTests/Services/Reviews/ReviewServiceTest.cs +++ b/src/StripeTests/Services/Reviews/ReviewServiceTest.cs @@ -92,9 +92,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var reviews = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(reviews); - Assert.Equal("review", reviews[0].Object); + var review = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(review); + Assert.Equal("review", review.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var review = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(review); + Assert.Equal("review", review.Object); } +#endif } } diff --git a/src/StripeTests/Services/SetupIntents/SetupIntentServiceTest.cs b/src/StripeTests/Services/SetupIntents/SetupIntentServiceTest.cs index ac8c4916bd..4ef65f1d4a 100644 --- a/src/StripeTests/Services/SetupIntents/SetupIntentServiceTest.cs +++ b/src/StripeTests/Services/SetupIntents/SetupIntentServiceTest.cs @@ -166,10 +166,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var intents = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(intents); - Assert.Equal("setup_intent", intents[0].Object); + var intent = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(intent); + Assert.Equal("setup_intent", intent.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var intent = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(intent); + Assert.Equal("setup_intent", intent.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunServiceTest.cs b/src/StripeTests/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunServiceTest.cs index 6e19e1cdbf..41abf89d62 100644 --- a/src/StripeTests/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunServiceTest.cs +++ b/src/StripeTests/Services/Sigma/ScheduledQueryRuns/ScheduledQueryRunServiceTest.cs @@ -70,9 +70,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var runs = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(runs); - Assert.Equal("scheduled_query_run", runs[0].Object); + var run = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(run); + Assert.Equal("scheduled_query_run", run.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var run = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(run); + Assert.Equal("scheduled_query_run", run.Object); } +#endif } } diff --git a/src/StripeTests/Services/Skus/SkuServiceTest.cs b/src/StripeTests/Services/Skus/SkuServiceTest.cs index dd6bf487a0..8e684cfdb9 100644 --- a/src/StripeTests/Services/Skus/SkuServiceTest.cs +++ b/src/StripeTests/Services/Skus/SkuServiceTest.cs @@ -139,10 +139,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var skus = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(skus); - Assert.Equal("sku", skus[0].Object); + var sku = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(sku); + Assert.Equal("sku", sku.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var sku = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(sku); + Assert.Equal("sku", sku.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/SourceTransactions/SourceTransactionServiceTest.cs b/src/StripeTests/Services/SourceTransactions/SourceTransactionServiceTest.cs index 6647e508eb..e1c99ecefa 100644 --- a/src/StripeTests/Services/SourceTransactions/SourceTransactionServiceTest.cs +++ b/src/StripeTests/Services/SourceTransactions/SourceTransactionServiceTest.cs @@ -52,9 +52,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var sourceTransactions = this.service.ListAutoPaging(SourceId, this.listOptions).ToList(); - Assert.NotNull(sourceTransactions); - Assert.Equal("source_transaction", sourceTransactions[0].Object); + var sourceTransaction = this.service.ListAutoPaging(SourceId, this.listOptions).First(); + Assert.NotNull(sourceTransaction); + Assert.Equal("source_transaction", sourceTransaction.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var sourceTransaction = await this.service.ListAutoPagingAsync(SourceId, this.listOptions).FirstAsync(); + Assert.NotNull(sourceTransaction); + Assert.Equal("source_transaction", sourceTransaction.Object); } +#endif } } diff --git a/src/StripeTests/Services/Sources/SourceServiceTest.cs b/src/StripeTests/Services/Sources/SourceServiceTest.cs index a9d02ee817..d7460d59f0 100644 --- a/src/StripeTests/Services/Sources/SourceServiceTest.cs +++ b/src/StripeTests/Services/Sources/SourceServiceTest.cs @@ -210,9 +210,18 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var sources = this.service.ListAutoPaging(CustomerId, this.listOptions).ToList(); - Assert.NotNull(sources); + var source = this.service.ListAutoPaging(CustomerId, this.listOptions).First(); + Assert.NotNull(source); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var source = await this.service.ListAutoPagingAsync(CustomerId, this.listOptions).FirstAsync(); + Assert.NotNull(source); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/SubscriptionItems/SubscriptionItemServiceTest.cs b/src/StripeTests/Services/SubscriptionItems/SubscriptionItemServiceTest.cs index 4b07feeae6..e17d83c2af 100644 --- a/src/StripeTests/Services/SubscriptionItems/SubscriptionItemServiceTest.cs +++ b/src/StripeTests/Services/SubscriptionItems/SubscriptionItemServiceTest.cs @@ -129,10 +129,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var subscriptionItems = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(subscriptionItems); - Assert.Equal("subscription_item", subscriptionItems[0].Object); + var subscriptionItem = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(subscriptionItem); + Assert.Equal("subscription_item", subscriptionItem.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var subscriptionItem = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(subscriptionItem); + Assert.Equal("subscription_item", subscriptionItem.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/SubscriptionSchedules/SubscriptionScheduleServiceTest.cs b/src/StripeTests/Services/SubscriptionSchedules/SubscriptionScheduleServiceTest.cs index 83e7f7e2c9..2659faa2ec 100644 --- a/src/StripeTests/Services/SubscriptionSchedules/SubscriptionScheduleServiceTest.cs +++ b/src/StripeTests/Services/SubscriptionSchedules/SubscriptionScheduleServiceTest.cs @@ -136,10 +136,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var subscriptions = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(subscriptions); - Assert.Equal("subscription_schedule", subscriptions[0].Object); + var subscription = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(subscription); + Assert.Equal("subscription_schedule", subscription.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var subscription = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(subscription); + Assert.Equal("subscription_schedule", subscription.Object); } +#endif [Fact] public void Release() diff --git a/src/StripeTests/Services/Subscriptions/SubscriptionServiceTest.cs b/src/StripeTests/Services/Subscriptions/SubscriptionServiceTest.cs index 5e0169ccb9..c1bac523b7 100644 --- a/src/StripeTests/Services/Subscriptions/SubscriptionServiceTest.cs +++ b/src/StripeTests/Services/Subscriptions/SubscriptionServiceTest.cs @@ -142,10 +142,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var subscriptions = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(subscriptions); - Assert.Equal("subscription", subscriptions[0].Object); + var subscription = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(subscription); + Assert.Equal("subscription", subscription.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var subscription = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(subscription); + Assert.Equal("subscription", subscription.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/TaxIds/TaxIdServiceTest.cs b/src/StripeTests/Services/TaxIds/TaxIdServiceTest.cs index a3b0f799e0..d43fbf6bda 100644 --- a/src/StripeTests/Services/TaxIds/TaxIdServiceTest.cs +++ b/src/StripeTests/Services/TaxIds/TaxIdServiceTest.cs @@ -114,9 +114,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var persons = this.service.ListAutoPaging(CustomerId, this.listOptions).ToList(); - Assert.NotNull(persons); - Assert.Equal("tax_id", persons[0].Object); + var person = this.service.ListAutoPaging(CustomerId, this.listOptions).First(); + Assert.NotNull(person); + Assert.Equal("tax_id", person.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var person = await this.service.ListAutoPagingAsync(CustomerId, this.listOptions).FirstAsync(); + Assert.NotNull(person); + Assert.Equal("tax_id", person.Object); } +#endif } } diff --git a/src/StripeTests/Services/TaxRates/TaxRateServiceTest.cs b/src/StripeTests/Services/TaxRates/TaxRateServiceTest.cs index c6ac710927..12fb611376 100644 --- a/src/StripeTests/Services/TaxRates/TaxRateServiceTest.cs +++ b/src/StripeTests/Services/TaxRates/TaxRateServiceTest.cs @@ -106,10 +106,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var taxRates = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(taxRates); - Assert.Equal("tax_rate", taxRates[0].Object); + var taxRate = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(taxRate); + Assert.Equal("tax_rate", taxRate.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var taxRate = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(taxRate); + Assert.Equal("tax_rate", taxRate.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Terminal/Locations/LocationServiceTest.cs b/src/StripeTests/Services/Terminal/Locations/LocationServiceTest.cs index b3c08b1769..3480dda158 100644 --- a/src/StripeTests/Services/Terminal/Locations/LocationServiceTest.cs +++ b/src/StripeTests/Services/Terminal/Locations/LocationServiceTest.cs @@ -114,10 +114,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var locations = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(locations); - Assert.Equal("terminal.location", locations[0].Object); + var location = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(location); + Assert.Equal("terminal.location", location.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var location = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(location); + Assert.Equal("terminal.location", location.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Terminal/Readers/ReaderServiceTest.cs b/src/StripeTests/Services/Terminal/Readers/ReaderServiceTest.cs index 7faada8397..79b0781a4a 100644 --- a/src/StripeTests/Services/Terminal/Readers/ReaderServiceTest.cs +++ b/src/StripeTests/Services/Terminal/Readers/ReaderServiceTest.cs @@ -107,10 +107,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var readers = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(readers); - Assert.Equal("terminal.reader", readers[0].Object); + var reader = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(reader); + Assert.Equal("terminal.reader", reader.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var reader = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(reader); + Assert.Equal("terminal.reader", reader.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Topups/TopupServiceTest.cs b/src/StripeTests/Services/Topups/TopupServiceTest.cs index 7f925dc8de..9f1a0efd5e 100644 --- a/src/StripeTests/Services/Topups/TopupServiceTest.cs +++ b/src/StripeTests/Services/Topups/TopupServiceTest.cs @@ -124,10 +124,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var topups = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(topups); - Assert.Equal("topup", topups[0].Object); + var topup = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(topup); + Assert.Equal("topup", topup.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var topup = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(topup); + Assert.Equal("topup", topup.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/TransferReversals/TransferReversalServiceTest.cs b/src/StripeTests/Services/TransferReversals/TransferReversalServiceTest.cs index fdeaaee46f..f523eb468e 100644 --- a/src/StripeTests/Services/TransferReversals/TransferReversalServiceTest.cs +++ b/src/StripeTests/Services/TransferReversals/TransferReversalServiceTest.cs @@ -105,10 +105,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var transferReversals = this.service.ListAutoPaging(TransferId, this.listOptions).ToList(); - Assert.NotNull(transferReversals); - Assert.Equal("transfer_reversal", transferReversals[0].Object); + var transferReversal = this.service.ListAutoPaging(TransferId, this.listOptions).First(); + Assert.NotNull(transferReversal); + Assert.Equal("transfer_reversal", transferReversal.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var transferReversal = await this.service.ListAutoPagingAsync(TransferId, this.listOptions).FirstAsync(); + Assert.NotNull(transferReversal); + Assert.Equal("transfer_reversal", transferReversal.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/Transfers/TransferServiceTest.cs b/src/StripeTests/Services/Transfers/TransferServiceTest.cs index d648e64750..fac4effd5a 100644 --- a/src/StripeTests/Services/Transfers/TransferServiceTest.cs +++ b/src/StripeTests/Services/Transfers/TransferServiceTest.cs @@ -106,10 +106,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var transfers = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(transfers); - Assert.Equal("transfer", transfers[0].Object); + var transfer = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(transfer); + Assert.Equal("transfer", transfer.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var transfer = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(transfer); + Assert.Equal("transfer", transfer.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/UsageRecordSummaries/UsageRecordSummaryServiceTest.cs b/src/StripeTests/Services/UsageRecordSummaries/UsageRecordSummaryServiceTest.cs index 572dc876b5..b682ea3b33 100644 --- a/src/StripeTests/Services/UsageRecordSummaries/UsageRecordSummaryServiceTest.cs +++ b/src/StripeTests/Services/UsageRecordSummaries/UsageRecordSummaryServiceTest.cs @@ -51,9 +51,19 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var summaries = this.service.ListAutoPaging(SubscriptionItemId, this.listOptions).ToList(); - Assert.NotNull(summaries); - Assert.Equal("usage_record_summary", summaries[0].Object); + var summarie = this.service.ListAutoPaging(SubscriptionItemId, this.listOptions).First(); + Assert.NotNull(summarie); + Assert.Equal("usage_record_summary", summarie.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var summarie = await this.service.ListAutoPagingAsync(SubscriptionItemId, this.listOptions).FirstAsync(); + Assert.NotNull(summarie); + Assert.Equal("usage_record_summary", summarie.Object); } +#endif } } diff --git a/src/StripeTests/Services/WebhookEndpoints/WebhookEndpointServiceTest.cs b/src/StripeTests/Services/WebhookEndpoints/WebhookEndpointServiceTest.cs index e2460baf25..258b24319b 100644 --- a/src/StripeTests/Services/WebhookEndpoints/WebhookEndpointServiceTest.cs +++ b/src/StripeTests/Services/WebhookEndpoints/WebhookEndpointServiceTest.cs @@ -124,10 +124,20 @@ public async Task ListAsync() [Fact] public void ListAutoPaging() { - var endpoints = this.service.ListAutoPaging(this.listOptions).ToList(); - Assert.NotNull(endpoints); - Assert.Equal("webhook_endpoint", endpoints[0].Object); + var endpoint = this.service.ListAutoPaging(this.listOptions).First(); + Assert.NotNull(endpoint); + Assert.Equal("webhook_endpoint", endpoint.Object); + } + +#if !NET45 + [Fact] + public async Task ListAutoPagingAsync() + { + var endpoint = await this.service.ListAutoPagingAsync(this.listOptions).FirstAsync(); + Assert.NotNull(endpoint); + Assert.Equal("webhook_endpoint", endpoint.Object); } +#endif [Fact] public void Update() diff --git a/src/StripeTests/Services/_base/ServiceTest.cs b/src/StripeTests/Services/_base/ServiceTest.cs index a487de0c3f..e090dcf763 100644 --- a/src/StripeTests/Services/_base/ServiceTest.cs +++ b/src/StripeTests/Services/_base/ServiceTest.cs @@ -106,6 +106,13 @@ public virtual IEnumerable ListAutoPaging(ListOptions options = null { return this.ListEntitiesAutoPaging(options, requestOptions); } + +#if !NET45 + public virtual IAsyncEnumerable ListAutoPagingAsync(ListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken); + } +#endif } } } diff --git a/src/StripeTests/StripeTests.csproj b/src/StripeTests/StripeTests.csproj index 549fcd77be..2f5a803a01 100644 --- a/src/StripeTests/StripeTests.csproj +++ b/src/StripeTests/StripeTests.csproj @@ -4,6 +4,7 @@ netcoreapp3.1;netcoreapp2.0;net461;net45 StripeTests + 8 StripeTests win10-x64 true @@ -26,7 +27,16 @@ + + + + + + + + +