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

Update generated code for beta #1380

Merged
merged 14 commits into from
Aug 28, 2024
Merged
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: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1214
v1226
4 changes: 3 additions & 1 deletion stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ class _APIRequestor(object):

def __init__(
self,
options: RequestorOptions = RequestorOptions(),
options: Optional[RequestorOptions] = None,
client: Optional[HTTPClient] = None,
):
if options is None:
options = RequestorOptions()
self._options = options
self._client = client

Expand Down
5 changes: 4 additions & 1 deletion stripe/_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CreateParams(RequestOptions):
"customer_signature",
"dispute_evidence",
"identity_document",
"issuing_regulatory_reporting",
"pci_document",
"tax_document_user_upload",
"terminal_reader_splashscreen",
Expand All @@ -62,7 +63,7 @@ class CreateParams(RequestOptions):
class CreateParamsFileLinkData(TypedDict):
create: bool
"""
Set this to `true` to create a file link for the newly created file. Creating a link is only possible when the file's `purpose` is one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `pci_document`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
Set this to `true` to create a file link for the newly created file. Creating a link is only possible when the file's `purpose` is one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `issuing_regulatory_reporting`, `pci_document`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
"""
expires_at: NotRequired[int]
"""
Expand Down Expand Up @@ -102,6 +103,7 @@ class ListParams(RequestOptions):
"finance_report_run",
"identity_document",
"identity_document_downloadable",
"issuing_regulatory_reporting",
"pci_document",
"selfie",
"sigma_scheduled_query",
Expand Down Expand Up @@ -176,6 +178,7 @@ class RetrieveParams(RequestOptions):
"finance_report_run",
"identity_document",
"identity_document_downloadable",
"issuing_regulatory_reporting",
"pci_document",
"selfie",
"sigma_scheduled_query",
Expand Down
2 changes: 1 addition & 1 deletion stripe/_file_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CreateParams(RequestOptions):
"""
file: str
"""
The ID of the file. The file's `purpose` must be one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `finance_report_run`, `identity_document_downloadable`, `pci_document`, `selfie`, `sigma_scheduled_query`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
The ID of the file. The file's `purpose` must be one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `finance_report_run`, `identity_document_downloadable`, `issuing_regulatory_reporting`, `pci_document`, `selfie`, `sigma_scheduled_query`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
"""
metadata: NotRequired["Literal['']|Dict[str, str]"]
"""
Expand Down
2 changes: 1 addition & 1 deletion stripe/_file_link_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CreateParams(TypedDict):
"""
file: str
"""
The ID of the file. The file's `purpose` must be one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `finance_report_run`, `identity_document_downloadable`, `pci_document`, `selfie`, `sigma_scheduled_query`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
The ID of the file. The file's `purpose` must be one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `finance_report_run`, `identity_document_downloadable`, `issuing_regulatory_reporting`, `pci_document`, `selfie`, `sigma_scheduled_query`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
"""
metadata: NotRequired["Literal['']|Dict[str, str]"]
"""
Expand Down
4 changes: 3 additions & 1 deletion stripe/_file_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CreateParams(TypedDict):
"customer_signature",
"dispute_evidence",
"identity_document",
"issuing_regulatory_reporting",
"pci_document",
"tax_document_user_upload",
"terminal_reader_splashscreen",
Expand All @@ -42,7 +43,7 @@ class CreateParams(TypedDict):
class CreateParamsFileLinkData(TypedDict):
create: bool
"""
Set this to `true` to create a file link for the newly created file. Creating a link is only possible when the file's `purpose` is one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `pci_document`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
Set this to `true` to create a file link for the newly created file. Creating a link is only possible when the file's `purpose` is one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `issuing_regulatory_reporting`, `pci_document`, `tax_document_user_upload`, or `terminal_reader_splashscreen`.
"""
expires_at: NotRequired[int]
"""
Expand Down Expand Up @@ -82,6 +83,7 @@ class ListParams(TypedDict):
"finance_report_run",
"identity_document",
"identity_document_downloadable",
"issuing_regulatory_reporting",
"pci_document",
"selfie",
"sigma_scheduled_query",
Expand Down
34 changes: 18 additions & 16 deletions stripe/_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
Never,
)

# - Requests is the preferred HTTP library
# - Google App Engine has urlfetch
# - Use Pycurl if it's there (at least it verifies SSL certs)
# - Fall back to urllib2 with a warning if needed

# The precedence of HTTP libraries is
# - Urlfetch (this is provided by Google App Engine, so if it's present you probably want it)
# - Requests (popular library, the top priority for all environments outside Google App Engine, but not always present)
# - Pycurl (another library, not always present, not as preferred as Requests but at least it verifies SSL certs)
# - urllib2 with a warning (basically always present, fallback if needed)
try:
import urllib.request as urllibrequest
import urllib.error as urlliberror
Expand Down Expand Up @@ -713,7 +715,7 @@ def _request_internal(

return content, status_code, result.headers

def _handle_request_error(self, e) -> NoReturn:
def _handle_request_error(self, e: Exception) -> NoReturn:
# Catch SSL error first as it belongs to ConnectionError,
# but we don't want to retry
if isinstance(e, self.requests.exceptions.SSLError):
Expand Down Expand Up @@ -764,7 +766,7 @@ def _handle_request_error(self, e) -> NoReturn:
should_retry = False

msg = textwrap.fill(msg) + "\n\n(Network error: %s)" % (err,)
raise APIConnectionError(msg, should_retry=should_retry)
raise APIConnectionError(msg, should_retry=should_retry) from e

def close(self):
if getattr(self._thread_local, "session", None) is not None:
Expand Down Expand Up @@ -869,7 +871,7 @@ def _request_internal(

return content, result.status_code, result.headers

def _handle_request_error(self, e, url) -> NoReturn:
def _handle_request_error(self, e: Exception, url: str) -> NoReturn:
if isinstance(e, self.urlfetch.InvalidURLError):
msg = (
"The Stripe library attempted to fetch an "
Expand All @@ -892,7 +894,7 @@ def _handle_request_error(self, e, url) -> NoReturn:
)

msg = textwrap.fill(msg) + "\n\n(Network error: " + str(e) + ")"
raise APIConnectionError(msg)
raise APIConnectionError(msg) from e

def close(self):
pass
Expand Down Expand Up @@ -1046,7 +1048,7 @@ def _request_internal(

return rcontent, rcode, headers

def _handle_request_error(self, e) -> NoReturn:
def _handle_request_error(self, e: Exception) -> NoReturn:
if e.args[0] in [
self.pycurl.E_COULDNT_CONNECT,
self.pycurl.E_COULDNT_RESOLVE_HOST,
Expand Down Expand Up @@ -1079,7 +1081,7 @@ def _handle_request_error(self, e) -> NoReturn:
should_retry = False

msg = textwrap.fill(msg) + "\n\n(Network error: " + e.args[1] + ")"
raise APIConnectionError(msg, should_retry=should_retry)
raise APIConnectionError(msg, should_retry=should_retry) from e

def _get_proxy(self, url) -> Optional[ParseResult]:
if self._parsed_proxy:
Expand Down Expand Up @@ -1194,13 +1196,13 @@ def _request_internal(
lh = dict((k.lower(), v) for k, v in iter(dict(headers).items()))
return rcontent, rcode, lh

def _handle_request_error(self, e) -> NoReturn:
def _handle_request_error(self, e: Exception) -> NoReturn:
msg = (
"Unexpected error communicating with Stripe. "
"If this problem persists, let us know at support@stripe.com."
)
msg = textwrap.fill(msg) + "\n\n(Network error: " + str(e) + ")"
raise APIConnectionError(msg)
raise APIConnectionError(msg) from e

def close(self):
pass
Expand Down Expand Up @@ -1307,7 +1309,7 @@ async def request_async(
response_headers = response.headers
return content, status_code, response_headers

def _handle_request_error(self, e) -> NoReturn:
def _handle_request_error(self, e: Exception) -> NoReturn:
msg = (
"Unexpected error communicating with Stripe. If this "
"problem persists, let us know at support@stripe.com."
Expand All @@ -1316,7 +1318,7 @@ def _handle_request_error(self, e) -> NoReturn:
should_retry = True

msg = textwrap.fill(msg) + "\n\n(Network error: %s)" % (err,)
raise APIConnectionError(msg, should_retry=should_retry)
raise APIConnectionError(msg, should_retry=should_retry) from e

def request_stream(
self, method: str, url: str, headers: Mapping[str, str], post_data=None
Expand Down Expand Up @@ -1446,7 +1448,7 @@ async def request_async(

return (await content.read()), status_code, response_headers

def _handle_request_error(self, e) -> NoReturn:
def _handle_request_error(self, e: Exception) -> NoReturn:
msg = (
"Unexpected error communicating with Stripe. If this "
"problem persists, let us know at support@stripe.com."
Expand All @@ -1455,7 +1457,7 @@ def _handle_request_error(self, e) -> NoReturn:
should_retry = True

msg = textwrap.fill(msg) + "\n\n(Network error: %s)" % (err,)
raise APIConnectionError(msg, should_retry=should_retry)
raise APIConnectionError(msg, should_retry=should_retry) from e

def request_stream(self) -> Tuple[Iterable[bytes], int, Mapping[str, str]]:
raise NotImplementedError(
Expand Down
1 change: 1 addition & 0 deletions stripe/_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ class LastFinalizationError(StripeObject):
"taxes_calculation_failed",
"terminal_location_country_unsupported",
"terminal_reader_busy",
"terminal_reader_collected_data_invalid",
"terminal_reader_hardware_fault",
"terminal_reader_invalid_location_for_payment",
"terminal_reader_offline",
Expand Down
2 changes: 1 addition & 1 deletion stripe/_line_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Tax(StripeObject):
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
description: str
description: Optional[str]
"""
An arbitrary string attached to the object. Often useful for displaying to users. Defaults to product name.
"""
Expand Down
1 change: 1 addition & 0 deletions stripe/_object_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
stripe.terminal.ConnectionToken.OBJECT_NAME: stripe.terminal.ConnectionToken,
stripe.terminal.Location.OBJECT_NAME: stripe.terminal.Location,
stripe.terminal.Reader.OBJECT_NAME: stripe.terminal.Reader,
stripe.terminal.ReaderCollectedData.OBJECT_NAME: stripe.terminal.ReaderCollectedData,
stripe.test_helpers.TestClock.OBJECT_NAME: stripe.test_helpers.TestClock,
stripe.Token.OBJECT_NAME: stripe.Token,
stripe.Topup.OBJECT_NAME: stripe.Topup,
Expand Down
1 change: 1 addition & 0 deletions stripe/_payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class LastPaymentError(StripeObject):
"taxes_calculation_failed",
"terminal_location_country_unsupported",
"terminal_reader_busy",
"terminal_reader_collected_data_invalid",
"terminal_reader_hardware_fault",
"terminal_reader_invalid_location_for_payment",
"terminal_reader_offline",
Expand Down
24 changes: 0 additions & 24 deletions stripe/_payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,10 +2072,6 @@ class ModifyParams(RequestOptions):
"""
If this is a `payto` PaymentMethod, this hash contains details about the PayTo payment method.
"""
rechnung: NotRequired["PaymentMethod.ModifyParamsRechnung"]
"""
If this is a `rechnung` PaymentMethod, this hash contains details about the Rechnung payment method.
"""
us_bank_account: NotRequired["PaymentMethod.ModifyParamsUsBankAccount"]
"""
If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method.
Expand Down Expand Up @@ -2166,26 +2162,6 @@ class ModifyParamsPayto(TypedDict):
The PayID alias for the bank account.
"""

class ModifyParamsRechnung(TypedDict):
dob: "PaymentMethod.ModifyParamsRechnungDob"
"""
Customer's date of birth
"""

class ModifyParamsRechnungDob(TypedDict):
day: int
"""
The day of birth, between 1 and 31.
"""
month: int
"""
The month of birth, between 1 and 12.
"""
year: int
"""
The four-digit year of birth.
"""

class ModifyParamsUsBankAccount(TypedDict):
account_holder_type: NotRequired[Literal["company", "individual"]]
"""
Expand Down
24 changes: 0 additions & 24 deletions stripe/_payment_method_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,6 @@ class UpdateParams(TypedDict):
"""
If this is a `payto` PaymentMethod, this hash contains details about the PayTo payment method.
"""
rechnung: NotRequired["PaymentMethodService.UpdateParamsRechnung"]
"""
If this is a `rechnung` PaymentMethod, this hash contains details about the Rechnung payment method.
"""
us_bank_account: NotRequired[
"PaymentMethodService.UpdateParamsUsBankAccount"
]
Expand Down Expand Up @@ -909,26 +905,6 @@ class UpdateParamsPayto(TypedDict):
The PayID alias for the bank account.
"""

class UpdateParamsRechnung(TypedDict):
dob: "PaymentMethodService.UpdateParamsRechnungDob"
"""
Customer's date of birth
"""

class UpdateParamsRechnungDob(TypedDict):
day: int
"""
The day of birth, between 1 and 31.
"""
month: int
"""
The month of birth, between 1 and 12.
"""
year: int
"""
The four-digit year of birth.
"""

class UpdateParamsUsBankAccount(TypedDict):
account_holder_type: NotRequired[Literal["company", "individual"]]
"""
Expand Down
1 change: 1 addition & 0 deletions stripe/_quote_preview_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class LastFinalizationError(StripeObject):
"taxes_calculation_failed",
"terminal_location_country_unsupported",
"terminal_reader_busy",
"terminal_reader_collected_data_invalid",
"terminal_reader_hardware_fault",
"terminal_reader_invalid_location_for_payment",
"terminal_reader_offline",
Expand Down
1 change: 1 addition & 0 deletions stripe/_setup_attempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ class SetupError(StripeObject):
"taxes_calculation_failed",
"terminal_location_country_unsupported",
"terminal_reader_busy",
"terminal_reader_collected_data_invalid",
"terminal_reader_hardware_fault",
"terminal_reader_invalid_location_for_payment",
"terminal_reader_offline",
Expand Down
1 change: 1 addition & 0 deletions stripe/_setup_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class LastSetupError(StripeObject):
"taxes_calculation_failed",
"terminal_location_country_unsupported",
"terminal_reader_busy",
"terminal_reader_collected_data_invalid",
"terminal_reader_hardware_fault",
"terminal_reader_invalid_location_for_payment",
"terminal_reader_offline",
Expand Down
2 changes: 1 addition & 1 deletion stripe/_stripe_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def __getattr__(self, k):
k = self._field_remappings[k]
return self[k]
except KeyError as err:
raise AttributeError(*err.args)
raise AttributeError(*err.args) from err

def __delattr__(self, k):
if k[0] == "_" or k in self.__dict__:
Expand Down
6 changes: 6 additions & 0 deletions stripe/_terminal_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from stripe.terminal._configuration_service import ConfigurationService
from stripe.terminal._connection_token_service import ConnectionTokenService
from stripe.terminal._location_service import LocationService
from stripe.terminal._reader_collected_data_service import (
ReaderCollectedDataService,
)
from stripe.terminal._reader_service import ReaderService


Expand All @@ -14,3 +17,6 @@ def __init__(self, requestor):
self.connection_tokens = ConnectionTokenService(self._requestor)
self.locations = LocationService(self._requestor)
self.readers = ReaderService(self._requestor)
self.reader_collected_data = ReaderCollectedDataService(
self._requestor
)
3 changes: 3 additions & 0 deletions stripe/api_resources/terminal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
from stripe.api_resources.terminal.connection_token import ConnectionToken
from stripe.api_resources.terminal.location import Location
from stripe.api_resources.terminal.reader import Reader
from stripe.api_resources.terminal.reader_collected_data import (
ReaderCollectedData,
)
Loading
Loading