8000 [WIP; no-merge] build SDK w/ new spec by xavdid-stripe · Pull Request #1518 · stripe/stripe-python · GitHub
[go: up one dir, main page]

Skip to content

[WIP; no-merge] 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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def request(
params=params,
requestor=requestor,
api_mode=api_mode,
v2_deleted_object=method == "delete" and api_mode == "V2",
)

return obj
Expand Down Expand Up @@ -234,6 +235,7 @@ async def request_async(
params=params,
requestor=requestor,
api_mode=api_mode,
v2_deleted_object=method == "delete" and api_mode == "V2",
)

return obj
Expand Down
9 changes: 8 additions & 1 deletion stripe/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def _convert_to_stripe_object(
klass_: Optional[Type["StripeObject"]] = None,
requestor: "_APIRequestor",
api_mode: ApiMode,
v2_deleted_object: bool = False,
) -> "StripeObject": ...


Expand All @@ -283,6 +284,7 @@ def _convert_to_stripe_object(
klass_: Optional[Type["StripeObject"]] = None,
requestor: "_APIRequestor",
api_mode: ApiMode,
v2_deleted_object: bool = False,
) -> List["StripeObject"]: ...


Expand All @@ -293,6 +295,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
Expand All @@ -314,14 +318,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 = stripe.v2.DeletedObject
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ class Request(StripeObject):
"""
_inner_class_types = {"error_types": ErrorType}

developer_message_summary: str
"""
Extra field included in the event's `data` when fetched from /v2/events.
"""
reason: Reason
"""
This contains information about why meter error happens.
"""
validation_end: str
developer_message_summary: str
"""
The end of the window that is encapsulated by this summary.
Extra field included in the event's `data` when fetched from /v2/events.
"""
validation_start: str
"""
The start of the window that is encapsulated by this summary.
"""
validation_end: str
"""
The end of the window that is encapsulated by this summary.
"""
_inner_class_types = {"reason": Reason}

data: V1BillingMeterErrorReportTriggeredEventData
Expand Down
12 changes: 6 additions & 6 deletions stripe/events/_v1_billing_meter_no_meter_found_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ class Request(StripeObject):
"""
_inner_class_types = {"error_types": ErrorType}

developer_message_summary: str
"""
Extra field included in the event's `data` when fetched from /v2/events.
"""
reason: Reason
"""
This contains information about why meter error happens.
"""
validation_end: str
developer_message_summary: str
"""
The end of the window that is encapsulated by this summary.
Extra field included in the event's `data` when fetched from /v2/events.
"""
validation_start: str
"""
The start of the window that is encapsulated by this summary.
"""
validation_end: str
"""
The end of the window that is encapsulated by this summary.
"""
_inner_class_types = {"reason": Reason}

data: V1BillingMeterNoMeterFoundEventData
Expand Down
4 changes: 2 additions & 2 deletions stripe/v2/_billing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
class BillingService(StripeService):
def __init__(self, requestor):
super().__init__(requestor)
self.meter_event_session = MeterEventSessionService(self._requestor)
self.meter_events = MeterEventService(self._requestor)
self.meter_event_adjustments = MeterEventAdjustmentService(
self._requestor,
)
self.meter_event_session = MeterEventSessionService(self._requestor)
self.meter_event_stream = MeterEventStreamService(self._requestor)
self.meter_events = MeterEventService(self._requestor)
2 changes: 1 addition & 1 deletion stripe/v2/_core_service.py
9E19
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
class CoreService(StripeService):
def __init__(self, requestor):
super().__init__(requestor)
self.event_destinations = EventDestinationService(self._requestor)
self.events = EventService(self._requestor)
self.event_destinations = EventDestinationService(self._requestor)
13 changes: 13 additions & 0 deletions stripe/v2/_deleted_object.py
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):
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.
"""
Loading
Loading
0