-
Notifications
You must be signed in to change notification settings - Fork 447
build SDK w/ new spec #1518
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
Closed
Closed
build SDK w/ new spec #1518
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b4105e1
build SDK
xavdid-stripe 1d8f198
fix deleted object handling
xavdid-stripe 7501079
latest output
xavdid-stripe df8241c
Fix semantics mismatches
xavdid-stripe dc272f0
generate a relatedobject for event_destination.ping
xavdid-stripe 752d408
Merge branch 'master' into openapi-v2
xavdid-stripe e2c39df
remove erroneous classurl
xavdid-stripe 4f91644
fix tests
xavdid-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,6 +198,12 @@ def get_thin_event_classes(): | |
return THIN_EVENT_CLASSES | ||
|
||
|
||
def get_deleted_object(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. busting a circular import |
||
from stripe.v2._deleted_object import DeletedObject | ||
|
||
return DeletedObject | ||
|
||
|
||
def get_object_classes(api_mode): | ||
# This is here to avoid a circular dependency | ||
if api_mode == "V2": | ||
|
@@ -272,6 +278,7 @@ def _convert_to_stripe_object( | |
klass_: Optional[Type["StripeObject"]] = None, | ||
requestor: "_APIRequestor", | ||
api_mode: ApiMode, | ||
v2_deleted_object: bool = False, | ||
) -> "StripeObject": ... | ||
|
||
|
||
|
@@ -283,6 +290,7 @@ def _convert_to_stripe_object( | |
klass_: Optional[Type["StripeObject"]] = None, | ||
requestor: "_APIRequestor", | ||
api_mode: ApiMode, | ||
v2_deleted_object: bool = False, | ||
) -> List["StripeObject"]: ... | ||
|
||
|
||
|
@@ -293,6 +301,8 @@ def _convert_to_stripe_object( | |
klass_: Optional[Type["StripeObject"]] = None, | ||
requestor: "_APIRequestor", | ||
api_mode: ApiMode, | ||
# whether we can't trust the object tag to represent the actual class we look up | ||
v2_deleted_object: bool = False, | ||
) -> Union["StripeObject", List["StripeObject"]]: | ||
# If we get a StripeResponse, we'll want to return a | ||
# StripeObject with the last_response field filled out with | ||
|
@@ -314,14 +324,17 @@ def _convert_to_stripe_object( | |
requestor=requestor, | ||
api_mode=api_mode, | ||
klass_=klass_, | ||
v2_deleted_object=v2_deleted_object, | ||
) | ||
for i in resp | ||
] | ||
elif isinstance(resp, dict) and not isinstance(resp, StripeObject): | ||
resp = resp.copy() | ||
klass_name = resp.get("object") | ||
if isinstance(klass_name, str): | ||
if api_mode == "V2" and klass_name == "v2.core.event": | ||
if v2_deleted_object: | ||
klass = get_deleted_object() | ||
elif api_mode == "V2" and klass_name == "v2.core.event": | ||
event_name = resp.get("type", "") | ||
klass = get_thin_event_classes().get( | ||
event_name, stripe.StripeObject | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
from stripe._stripe_object import StripeObject | ||
|
||
|
||
class DeletedObject(StripeObject): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. manually written class, references to which will get spit out by codegen |
||
object: str | ||
""" | ||
String representing the object's type. Objects of the same type share the same value of the object field. | ||
""" | ||
id: str | ||
""" | ||
The ID of the object that's being deleted. | ||
""" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the runtime code that ensures we turn delete responses into
V2DeletedObject
instead ofEventDestination
We're not merging this second, but it's what we'll do when we are ready to merge.