Skip to content

Support cleaner pagination for V1 in stripe.Client #2027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2025

Conversation

mbroshi-stripe
Copy link
Contributor

@mbroshi-stripe mbroshi-stripe commented Apr 15, 2025

Why?

For V2 support, we offer pagination using Go's iter.Seq2 interface, so iterating over V2 accounts looks like this:

for acct, err := range sc.V2Accounts.All(params) {
        // do something
}

This compares to V1 where it looks like this:

i := sc.Accounts.List(params)
for i.Next() {
	acct := i.Account()
        // do something
}

if err := i.Err(); err != nil {
	// handle
}

With the new stripe.Client type in a future PR, we will be providing the former style pagination for both V1 and V2.

This PR paves the way by introducing the mechanism for V1 to cleanly paginate in List methods.

What?

  • Adds an unexported (i.e., internal-only) type v1List with an All method for pagination. This is not currently used anywhere, but will be leveraged by stripe.Client in a subsequent PR.

See Also

@mbroshi-stripe mbroshi-stripe requested a review from a team as a code owner April 15, 2025 17:29
@mbroshi-stripe mbroshi-stripe requested review from helenye-stripe and removed request for a team April 15, 2025 17:29
@mbroshi-stripe mbroshi-stripe force-pushed the mbroshi/go-v2-support branch from 036af41 to 4661282 Compare April 15, 2025 17:32
Base automatically changed from mbroshi/go-v2-support to mbroshi/improve-comments April 15, 2025 19:16
Base automatically changed from mbroshi/improve-comments to master April 15, 2025 19:19
@mbroshi-stripe mbroshi-stripe force-pushed the mbroshi/v1-range-pagination branch 2 times, most recently from 4e82bf0 to c906e63 Compare April 16, 2025 01:11
@mbroshi-stripe mbroshi-stripe marked this pull request as draft April 16, 2025 13:50
@mbroshi-stripe mbroshi-stripe changed the title Support cleaner pagination in stripe.Client Support cleaner pagination for V1 in stripe.Client Apr 16, 2025
@mbroshi-stripe mbroshi-stripe marked this pull request as ready for review April 16, 2025 15:43
@mbroshi-stripe mbroshi-stripe force-pushed the mbroshi/v1-range-pagination branch from e34073c to b564eb9 Compare April 16, 2025 15:44
@mbroshi-stripe mbroshi-stripe merged commit 5a1defb into master Apr 16, 2025
10 checks passed
@mbroshi-stripe mbroshi-stripe deleted the mbroshi/v1-range-pagination branch April 16, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants