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

custom_method decorator for defining static methods for custom API requests #547

Merged
merged 2 commits into from
Apr 3, 2019

Conversation

ob-stripe
Copy link
Contributor

r? @brandur-stripe @remi-stripe
cc @stripe/api-libraries

This is similar to stripe/stripe-ruby#754. This PR defines a new custom_method decorator that can be applied to resource classes to automatically define class methods for custom (non-CRUDL) API requests.

The decorator checks if a method with the target name already exists, and if so it uses the new decorator util.class_method_variant from #543 to avoid overwriting the existing method (that we assume to be an instance method).

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

Left one question, but this looking great!

ptal @ob-stripe

stripe/api_resources/charge.py Outdated Show resolved Hide resolved
@remi-stripe
Copy link
Contributor

@ob-stripe I added all custom methods and tests and rebased on the latest branch for deletion

@remi-stripe remi-stripe force-pushed the ob-custom-method branch 3 times, most recently from d8c301c to 91f7806 Compare April 3, 2019 01:07
@ob-stripe ob-stripe changed the base branch from ob-delete-class-method to master April 3, 2019 17:19
@ob-stripe ob-stripe changed the title [WIP] custom_method decorator for defining static methods for custom API requests custom_method decorator for defining static methods for custom API requests Apr 3, 2019
Copy link
Contributor Author

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

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

LGTM

@ob-stripe ob-stripe merged commit 97205a1 into master Apr 3, 2019
@ob-stripe ob-stripe deleted the ob-custom-method branch April 3, 2019 17:26
@ob-stripe
Copy link
Contributor Author

Released as 2.24.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants