Skip to content
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 CODEGEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9e950cbf7b5a814a98f27d1a94b72cd6f1df2078
25e6bd225852aa44d783e9fb3b9895af39479331
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2203
v2206
27 changes: 27 additions & 0 deletions stripe/_account_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
import json
from stripe._api_version import _ApiVersion
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from uuid import uuid4
from importlib import import_module
from typing_extensions import TYPE_CHECKING

Expand Down Expand Up @@ -398,3 +401,27 @@ async def reject_async(
options=options,
),
)

def serialize_batch_update(
self,
account: str,
params: Optional["AccountUpdateParams"] = None,
options: Optional["RequestOptions"] = None,
) -> str:
"""
Serializes an Account update request into a batch job JSONL line.
"""
item_id = str(uuid4())
stripe_version = (
options.get("stripe_version") if options else None
) or _ApiVersion.CURRENT
context = options.get("stripe_context") if options else None
item = {
"id": item_id,
"path_params": {"account": account},
"params": params,
"stripe_version": stripe_version,
}
if context is not None:
item["context"] = context
return json.dumps(item)
1 change: 1 addition & 0 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ def specific_oauth_error(self, rbody, rcode, resp, rheaders, error_code):
("CODEX_CI", "codex_cli"),
("CURSOR_AGENT", "cursor"),
("GEMINI_CLI", "gemini_cli"),
("OPENCLAW_SHELL", "openclaw"),
("OPENCODE", "open_code"),
# aiAgents: The end of the section generated from our OpenAPI spec
]
Expand Down
4 changes: 3 additions & 1 deletion stripe/_credit_note_line_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from decimal import Decimal
from stripe._expandable_field import ExpandableField
from stripe._stripe_object import StripeObject
from typing import ClassVar, List, Optional
Expand Down Expand Up @@ -172,7 +173,7 @@ class TaxRateDetails(StripeObject):
"""
The cost of each unit of product being credited.
"""
unit_amount_decimal: Optional[str]
unit_amount_decimal: Optional[Decimal]
"""
Same as `unit_amount`, but contains a decimal value with at most 12 decimal places.
"""
Expand All @@ -182,3 +183,4 @@ class TaxRateDetails(StripeObject):
"tax_calculation_reference": TaxCalculationReference,
"taxes": Tax,
}
_field_encodings = {"unit_amount_decimal": "decimal_string"}
25 changes: 25 additions & 0 deletions stripe/_credit_note_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
import json
from stripe._api_version import _ApiVersion
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from uuid import uuid4
from importlib import import_module
from typing_extensions import TYPE_CHECKING

Expand Down Expand Up @@ -319,3 +322,25 @@ async def void_credit_note_async(
options=options,
),
)

def serialize_batch_create(
self,
params: Optional["CreditNoteCreateParams"] = None,
options: Optional["RequestOptions"] = None,
) -> str:
"""
Serializes a CreditNote create request into a batch job JSONL line.
"""
item_id = str(uuid4())
stripe_version = (
options.get("stripe_version") if options else None
) or _ApiVersion.CURRENT
context = options.get("stripe_context") if options else None
item = {
"id": item_id,
"params": params,
"stripe_version": stripe_version,
}
if context is not None:
item["context"] = context
return json.dumps(item)
27 changes: 27 additions & 0 deletions stripe/_customer_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
import json
from stripe._api_version import _ApiVersion
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from uuid import uuid4
from importlib import import_module
from typing_extensions import TYPE_CHECKING

Expand Down Expand Up @@ -397,3 +400,27 @@ async def search_async(
options=options,
),
)

def serialize_batch_update(
self,
customer: str,
params: Optional["CustomerUpdateParams"] = None,
options: Optional["RequestOptions"] = None,
) -> str:
"""
Serializes a Customer update request into a batch job JSONL line.
"""
item_id = str(uuid4())
stripe_version = (
options.get("stripe_version") if options else None
) or _ApiVersion.CURRENT
context = options.get("stripe_context") if options else None
item = {
"id": item_id,
"path_params": {"customer": customer},
"params": params,
"stripe_version": stripe_version,
}
if context is not None:
item["context"] = context
return json.dumps(item)
31 changes: 31 additions & 0 deletions stripe/_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import time
from collections import OrderedDict
from decimal import Decimal
from typing import Any, Dict, Generator, Mapping, Optional, Tuple, Union


Expand All @@ -25,6 +26,8 @@ def _encode_nested_dict(key, data, fmt="%s[%s]"):
def _json_encode_date_callback(value):
if isinstance(value, datetime.datetime):
return _encode_datetime(value)
if isinstance(value, Decimal):
return str(value)
return value


Expand Down Expand Up @@ -82,6 +85,31 @@ def _coerce_int64_string(value: Any, *, encode: bool) -> Any:
return value


def _coerce_decimal_string(value: Any, *, encode: bool) -> Any:
"""
Coerce a decimal_string value in either direction.

encode=True: Decimal/int/float → str (request serialization)
encode=False: str → Decimal (response hydration)
"""
if value is None:
return None

if isinstance(value, list):
return [_coerce_decimal_string(v, encode=encode) for v in value]

if encode:
if isinstance(value, (Decimal, int, float)) and not isinstance(
value, bool
):
return str(value)
return value
else:
if isinstance(value, str):
return Decimal(value)
return value


def _coerce_value(value: Any, schema: _SchemaNode) -> Any:
"""Coerce a single value according to its schema node."""
if value is None:
Expand All @@ -90,6 +118,9 @@ def _coerce_value(value: Any, schema: _SchemaNode) -> Any:
if schema == "int64_string":
return _coerce_int64_string(value, encode=True)

if schema == "decimal_string":
return _coerce_decimal_string(value, encode=True)

if isinstance(schema, dict):
# Nested object schema
if isinstance(value, list):
Expand Down
4 changes: 3 additions & 1 deletion stripe/_invoice_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from decimal import Decimal
from stripe._createable_api_resource import CreateableAPIResource
from stripe._deletable_api_resource import DeletableAPIResource
from stripe._expandable_field import ExpandableField
Expand Down Expand Up @@ -206,7 +207,7 @@ class RateCardRateDetails(StripeObject):
"""
The type of the pricing details.
"""
unit_amount_decimal: Optional[str]
unit_amount_decimal: Optional[Decimal]
"""
The unit amount (in the `currency` specified) of the item which contains a decimal value with at most 12 decimal places.
"""
Expand All @@ -216,6 +217,7 @@ class RateCardRateDetails(StripeObject):
"rate_card_custom_pricing_unit_overage_rate_details": RateCardCustomPricingUnitOverageRateDetails,
"rate_card_rate_details": RateCardRateDetails,
}
_field_encodings = {"unit_amount_decimal": "decimal_string"}

class ProrationDetails(StripeObject):
class DiscountAmount(StripeObject):
Expand Down
4 changes: 3 additions & 1 deletion stripe/_invoice_line_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from decimal import Decimal
from stripe._expandable_field import ExpandableField
from stripe._stripe_object import StripeObject
from stripe._updateable_api_resource import UpdateableAPIResource
Expand Down Expand Up @@ -337,7 +338,7 @@ class RateCardRateDetails(StripeObject):
"""
The type of the pricing details.
"""
unit_amount_decimal: Optional[str]
unit_amount_decimal: Optional[Decimal]
"""
The unit amount (in the `currency` specified) of the item which contains a decimal value with at most 12 decimal places.
"""
Expand All @@ -347,6 +348,7 @@ class RateCardRateDetails(StripeObject):
"rate_card_custom_pricing_unit_overage_rate_details": RateCardCustomPricingUnitOverageRateDetails,
"rate_card_rate_details": RateCardRateDetails,
}
_field_encodings = {"unit_amount_decimal": "decimal_string"}

class TaxCalculationReference(StripeObject):
calculation_id: Optional[str]
Expand Down
51 changes: 51 additions & 0 deletions stripe/_invoice_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
import json
from stripe._api_version import _ApiVersion
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from uuid import uuid4
from importlib import import_module
from typing_extensions import TYPE_CHECKING

Expand Down Expand Up @@ -847,3 +850,51 @@ async def create_preview_async(
options=options,
),
)

def serialize_batch_update(
self,
invoice: str,
params: Optional["InvoiceUpdateParams"] = None,
options: Optional["RequestOptions"] = None,
) -> str:
"""
Serializes an Invoice update request into a batch job JSONL line.
"""
item_id = str(uuid4())
stripe_version = (
options.get("stripe_version") if options else None
) or _ApiVersion.CURRENT
context = options.get("stripe_context") if options else None
item = {
"id": item_id,
"path_params": {"invoice": invoice},
"params": params,
"stripe_version": stripe_version,
}
if context is not None:
item["context"] = context
return json.dumps(item)

def serialize_batch_pay(
self,
invoice: str,
params: Optional["InvoicePayParams"] = None,
options: Optional["RequestOptions"] = None,
) -> str:
"""
Serializes an Invoice pay request into a batch job JSONL line.
"""
item_id = str(uuid4())
stripe_version = (
options.get("stripe_version") if options else None
) or _ApiVersion.CURRENT
context = options.get("stripe_context") if options else None
item = {
"id": item_id,
"path_params": {"invoice": invoice},
"params": params,
"stripe_version": stripe_version,
}
if context is not None:
item["context"] = context
return json.dumps(item)
13 changes: 5 additions & 8 deletions stripe/_object_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,6 @@
"LicensedItem",
),
"v2.billing.license_fee": ("stripe.v2.billing._license_fee", "LicenseFee"),
"v2.billing.license_fee_subscription": (
"stripe.v2.billing._license_fee_subscription",
"LicenseFeeSubscription",
),
"v2.billing.license_fee_version": (
"stripe.v2.billing._license_fee_version",
"LicenseFeeVersion",
Expand Down Expand Up @@ -517,10 +513,6 @@
"stripe.v2.billing._pricing_plan_subscription",
"PricingPlanSubscription",
),
"v2.billing.pricing_plan_subscription_components": (
"stripe.v2.billing._pricing_plan_subscription_components",
"PricingPlanSubscriptionComponents",
),
"v2.billing.pricing_plan_version": (
"stripe.v2.billing._pricing_plan_version",
"PricingPlanVersion",
Expand Down Expand Up @@ -548,6 +540,10 @@
"ServiceAction",
),
"v2.core.account": ("stripe.v2.core._account", "Account"),
"v2.core.account_evaluation": (
"stripe.v2.core._account_evaluation",
"AccountEvaluation",
),
"v2.core.account_link": ("stripe.v2.core._account_link", "AccountLink"),
"v2.core.account_person": (
"stripe.v2.core._account_person",
Expand All @@ -558,6 +554,7 @@
"AccountPersonToken",
),
"v2.core.account_token": ("stripe.v2.core._account_token", "AccountToken"),
"v2.core.batch_job": ("stripe.v2.core._batch_job", "BatchJob"),
"v2.core.claimable_sandbox": (
"stripe.v2.core._claimable_sandbox",
"ClaimableSandbox",
Expand Down
6 changes: 0 additions & 6 deletions stripe/_payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4188,12 +4188,6 @@ class MandateOptions(StripeObject):

financial_connections: Optional[FinancialConnections]
mandate_options: Optional[MandateOptions]
preferred_settlement_speed: Optional[
Literal["fastest", "standard"]
]
"""
Preferred transaction settlement speed
"""
setup_future_usage: Optional[
Literal["none", "off_session", "on_session"]
]
Expand Down
Loading
Loading