Skip to content
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

Add support for auto-paginatable SearchResult type #1252

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Aug 30, 2021

Notify

r? @ramon-stripe
cc @stripe/api-libraries

Summary

Adds support for autopaginatable SearchResult API response types. Implementation strategy: mostly I copied Collection classes/interfaces, but changed the pagination logic to use nextPage instead of lastId.

Analogous to PRs in stripe-node and stripe-go

See example commit for how this would work in the context of a /v1/search/charges endpoint.

Release Plan

Even though this functionality is not public, without a future PR adding a search method to a resource (like my charges example, none of these classes/interfaces are accessible, so in effect this addition does not affect the public interface of stripe-java and can be safely removed or changed. I intend to merge it right away. This is similar to the release pattern we followed for streaming requests.

Testing

Test strategy: took https://github.com/stripe/stripe-java/compare/richardm-search-charges?expand=1, made a .jar, added it to the pom.xml in my sample app, and successfully executed:

    RequestOptions opts = RequestOptions.builder().setStripeVersionOverride("2020-08-27;search_api_beta=v1").build();
    ChargeSearchParams params = ChargeSearchParams
      .builder()
      .setLimit(2l)
      .setQuery("metadata[\"foo\"]:\"bar\"")
      .build();
    for (Charge ch : Charge.search(params, opts).autoPagingIterable()) {
      System.out.println(ch.getId());
    }

and confirmed the pagination appeared to be happening correctly (it actually wasn't, at first and I fixed a bug).

@richardm-stripe richardm-stripe changed the title Infra Add support for auto-paginatable SearchResult type Aug 30, 2021
@richardm-stripe richardm-stripe merged commit 5fba586 into master Aug 31, 2021
@richardm-stripe richardm-stripe deleted the richardm-search-api-infra branch August 31, 2021 16:28
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