Coverage for polar/customer_portal/schemas/customer.py: 100%
39 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
1from typing import Annotated, Literal 1a
3from pydantic import UUID4, AfterValidator, Discriminator, TypeAdapter 1a
5from polar.kit.address import Address, AddressInput 1a
6from polar.kit.http import get_safe_return_url 1a
7from polar.kit.schemas import ( 1a
8 ClassName,
9 EmptyStrToNoneValidator,
10 IDSchema,
11 MergeJSONSchema,
12 Schema,
13 SetSchemaReference,
14 TimestampedSchema,
15)
16from polar.kit.tax import TaxID 1a
17from polar.payment_method.schemas import PaymentMethodCard, PaymentMethodGeneric 1a
20class CustomerPortalOAuthAccount(Schema): 1a
21 account_id: str 1a
22 account_username: str | None 1a
25class CustomerPortalCustomer(IDSchema, TimestampedSchema): 1a
26 email: str 1a
27 email_verified: bool 1a
28 name: str | None 1a
29 billing_name: str | None 1a
30 billing_address: Address | None 1a
31 tax_id: TaxID | None 1a
32 oauth_accounts: dict[str, CustomerPortalOAuthAccount] 1a
33 default_payment_method_id: UUID4 | None = None 1a
36class CustomerPortalCustomerUpdate(Schema): 1a
37 billing_name: Annotated[str | None, EmptyStrToNoneValidator] = None 1a
38 billing_address: AddressInput | None = None 1a
39 tax_id: Annotated[str | None, EmptyStrToNoneValidator] = None 1a
42CustomerPaymentMethod = Annotated[ 1a
43 PaymentMethodCard | PaymentMethodGeneric,
44 SetSchemaReference("CustomerPaymentMethod"),
45 MergeJSONSchema({"title": "CustomerPaymentMethod"}),
46 ClassName("CustomerPaymentMethod"),
47]
49CustomerPaymentMethodTypeAdapter: TypeAdapter[CustomerPaymentMethod] = TypeAdapter( 1a
50 CustomerPaymentMethod
51)
54class CustomerPaymentMethodCreate(Schema): 1a
55 confirmation_token_id: str 1a
56 set_default: bool 1a
57 return_url: Annotated[str, AfterValidator(get_safe_return_url)] 1a
60class CustomerPaymentMethodCreateSucceededResponse(Schema): 1a
61 status: Literal["succeeded"] 1a
62 payment_method: CustomerPaymentMethod 1a
65class CustomerPaymentMethodCreateRequiresActionResponse(Schema): 1a
66 status: Literal["requires_action"] 1a
67 client_secret: str 1a
70CustomerPaymentMethodCreateResponse = Annotated[ 1a
71 CustomerPaymentMethodCreateSucceededResponse
72 | CustomerPaymentMethodCreateRequiresActionResponse,
73 Discriminator("status"),
74 SetSchemaReference("CustomerPaymentMethodCreateResponse"),
75 MergeJSONSchema({"title": "CustomerPaymentMethodCreateResponse"}),
76]
79class CustomerPaymentMethodConfirm(Schema): 1a
80 setup_intent_id: str 1a
81 set_default: bool 1a