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 SearchResult. #777

Merged
merged 5 commits into from
Mar 17, 2022
Merged

Add support for SearchResult. #777

merged 5 commits into from
Mar 17, 2022

Conversation

dcr-stripe
Copy link
Contributor

Notify

r? @pakrym-stripe

Summary

Adds support for search_result objects returned by the Stripe API, including adding a SearchResultObject class and a SearchableAPIResource class which can be added to resources to support invoking search APIs.

This behaves similarly to ListObject in that they both wrap around a list of objects and provide pagination. However the SearchResultObject object paginates by relying on a next_page token included in the response rather than using object IDs + starting_before/ending_after. Thus, only forward pagination is supported

This was branched from #730.

Test plan

Added unit tests. We'll want to add some more rigorous tests once stripe-mock has been updated to include at least one API that returns this resource.

@pakrym-stripe
Copy link
Contributor

Can you please add a test similar to https://github.com/stripe/stripe-python/blob/master/tests/api_resources/abstract/test_listable_api_resource.py that exercises the SearchableAPIResource?

@dcr-stripe
Copy link
Contributor Author

Can you please add a test similar to https://github.com/stripe/stripe-python/blob/master/tests/api_resources/abstract/test_listable_api_resource.py that exercises the SearchableAPIResource?

Good catch - thank you! Added.

PTAL @pakrym-stripe

{"object": "charge", "name": "curly"},
],
"url": "/v1/charges",
"has_more": False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a second page here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@dcr-stripe
Copy link
Contributor Author

PTAL again @pakrym-stripe for the multi-page test?

@dcr-stripe
Copy link
Contributor Author

r? @richardm-stripe

@dcr-stripe dcr-stripe merged commit 3c674aa into master Mar 17, 2022
@dcr-stripe dcr-stripe deleted the dcr-search-api branch March 17, 2022 22:20
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.

None yet

3 participants