diff --git a/.hark/changes/2026-11-24_stripe-openapi_1f35b2bf.change.md b/.hark/changes/2026-11-24_stripe-openapi_1f35b2bf.change.md new file mode 100644 index 000000000..80398f34e --- /dev/null +++ b/.hark/changes/2026-11-24_stripe-openapi_1f35b2bf.change.md @@ -0,0 +1,8 @@ +--- +title: Update generated code +pr_url: https://github.com/stripe/stripe-python/pull/2003 +semver_level: minor +is_stripe_api_change: true +--- + +* Release specs are identical. diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index 06a01d0ea..f0f3aa3c5 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -f3581f76eec818aa658fd9635eaf0107d13e3441 \ No newline at end of file +b608cd5088d47fe3b03946089cbfdd4d61a12212 \ No newline at end of file diff --git a/stripe/_encode.py b/stripe/_encode.py index 7c402cf52..3230063cf 100644 --- a/stripe/_encode.py +++ b/stripe/_encode.py @@ -171,6 +171,10 @@ def _api_encode( ) for k, v in _api_encode(subdict): yield (k, v) + elif isinstance(sv, datetime.datetime): + yield (encoded_key, _encode_datetime(sv)) + elif isinstance(sv, bool): + yield (encoded_key, str(sv).lower()) else: yield (encoded_key, sv) elif isinstance(value, dict) or hasattr(value, "_data"): diff --git a/tests/test_encode.py b/tests/test_encode.py index f8f036c8f..5e39339e3 100644 --- a/tests/test_encode.py +++ b/tests/test_encode.py @@ -1,3 +1,4 @@ +import datetime import warnings from stripe._stripe_object import StripeObject @@ -86,6 +87,19 @@ def test_encode_boolean_value(self): result = list(_api_encode({"active": True, "deleted": False})) assert result == [("active", "true"), ("deleted", "false")] + def test_encode_list_with_boolean_values(self): + """Booleans inside a list are encoded as lowercase strings, like top-level booleans.""" + result = list(_api_encode({"flags": [True, False]})) + assert result == [("flags[0]", "true"), ("flags[1]", "false")] + + def test_encode_list_with_datetime_values(self): + """Datetimes inside a list are encoded as unix timestamps, like top-level datetimes.""" + dt = datetime.datetime( + 2024, 1, 2, 3, 4, 5, tzinfo=datetime.timezone.utc + ) + result = list(_api_encode({"created": [dt]})) + assert result == [("created[0]", 1704164645)] + def test_encode_list_value(self): """Test that list values are encoded with indexed keys.""" result = list(_api_encode({"items": ["item1", "item2", "item3"]}))