"""Billing request and response bodies. Webhook bodies are the stores' own shapes, so they ignore unknown fields.""" from typing import Literal from pydantic import ConfigDict, Field from app.common.schemas import RequestModel, ResponseModel from app.modules.billing.entitlement import Entitlement class ReceiptIn(RequestModel): platform: Literal["ios", "android"] product_id: str = Field(min_length=1, max_length=64) signed_transaction: str | None = Field(default=None, max_length=32_000) purchase_token: str | None = Field(default=None, max_length=4_096) class ReceiptOut(ResponseModel): entitlement: Entitlement class AppleWebhookIn(RequestModel): model_config = ConfigDict(extra="ignore", populate_by_name=True) signed_payload: str = Field(alias="signedPayload", max_length=200_000) class PubSubMessage(RequestModel): model_config = ConfigDict(extra="ignore") data: str = Field(default="", max_length=100_000) class PubSubPushIn(RequestModel): model_config = ConfigDict(extra="ignore") message: PubSubMessage class WebhookAck(ResponseModel): pass