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 @@
58595eed5a9dffbf0f297ecaf3ac45acf36c5de3
25e6bd225852aa44d783e9fb3b9895af39479331
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2205
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 @@ -395,3 +398,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)
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, Dict, List, Optional
Expand Down Expand Up @@ -176,7 +177,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 @@ -186,3 +187,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
7 changes: 5 additions & 2 deletions 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 @@ -100,11 +101,12 @@ class PriceDetails(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.
"""
_inner_class_types = {"price_details": PriceDetails}
_field_encodings = {"unit_amount_decimal": "decimal_string"}

class ProrationDetails(StripeObject):
class DiscountAmount(StripeObject):
Expand Down Expand Up @@ -205,7 +207,7 @@ class DiscountAmount(StripeObject):
"""
Quantity of units for the invoice item in integer format, with any decimal precision truncated. For the item's full-precision decimal quantity, use `quantity_decimal`. This field will be deprecated in favor of `quantity_decimal` in a future version. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
"""
quantity_decimal: str
quantity_decimal: Decimal
"""
Non-negative decimal with at most 12 decimal places. The quantity of units for the invoice item.
"""
Expand Down Expand Up @@ -450,3 +452,4 @@ async def retrieve_async(
"pricing": Pricing,
"proration_details": ProrationDetails,
}
_field_encodings = {"quantity_decimal": "decimal_string"}
7 changes: 5 additions & 2 deletions 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 @@ -190,11 +191,12 @@ class PriceDetails(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.
"""
_inner_class_types = {"price_details": PriceDetails}
_field_encodings = {"unit_amount_decimal": "decimal_string"}

class TaxCalculationReference(StripeObject):
calculation_id: Optional[str]
Expand Down Expand Up @@ -325,7 +327,7 @@ class TaxRateDetails(StripeObject):
"""
Quantity of units for the invoice line item in integer format, with any decimal precision truncated. For the line item's full-precision decimal quantity, use `quantity_decimal`. This field will be deprecated in favor of `quantity_decimal` in a future version. If the line item is a proration or subscription, the quantity of the subscription that the proration was computed for.
"""
quantity_decimal: Optional[str]
quantity_decimal: Optional[Decimal]
"""
Non-negative decimal with at most 12 decimal places. The quantity of units for the line item.
"""
Expand Down Expand Up @@ -399,3 +401,4 @@ async def modify_async(
"tax_calculation_reference": TaxCalculationReference,
"taxes": Tax,
}
_field_encodings = {"quantity_decimal": "decimal_string"}
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)
8 changes: 0 additions & 8 deletions stripe/_payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4007,13 +4007,6 @@ class Sofort(StripeObject):
"""

class StripeBalance(StripeObject):
class MandateOptions(StripeObject):
stripe_balance_debit_agreement: Optional[str]
"""
The ID of the Stripe Balance Debit Agreement used for this mandate.
"""

mandate_options: Optional[MandateOptions]
setup_future_usage: Optional[Literal["none", "off_session"]]
"""
Indicates that you intend to make future payments with this PaymentIntent's payment method.
Expand All @@ -4024,7 +4017,6 @@ class MandateOptions(StripeObject):

When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://docs.stripe.com/strong-customer-authentication).
"""
_inner_class_types = {"mandate_options": MandateOptions}

class Swish(StripeObject):
reference: Optional[str]
Expand Down
Loading
Loading