Coverage for polar/account/schemas.py: 100%
139 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1from enum import StrEnum
2from typing import Annotated, Literal
3from uuid import UUID
5from pydantic import BeforeValidator, Field
7from polar.enums import AccountType
8from polar.kit.address import Address, AddressInput
9from polar.kit.schemas import Schema
10from polar.models.account import Account as AccountModel
11from polar.organization.schemas import Organization
12from polar.user.schemas import UserBase
15class StripeAccountCountry(StrEnum):
16 AL = "AL"
17 AG = "AG"
18 AR = "AR"
19 AM = "AM"
20 AU = "AU"
21 AT = "AT"
22 BH = "BH"
23 BE = "BE"
24 BO = "BO"
25 BA = "BA"
26 BG = "BG"
27 KH = "KH"
28 CA = "CA"
29 CL = "CL"
30 CO = "CO"
31 CR = "CR"
32 HR = "HR"
33 CY = "CY"
34 CZ = "CZ"
35 CI = "CI"
36 DK = "DK"
37 DO = "DO"
38 EC = "EC"
39 EG = "EG"
40 SV = "SV"
41 EE = "EE"
42 ET = "ET"
43 FI = "FI"
44 FR = "FR"
45 GM = "GM"
46 DE = "DE"
47 GH = "GH"
48 GR = "GR"
49 GT = "GT"
50 GY = "GY"
51 HK = "HK"
52 HU = "HU"
53 IS = "IS"
54 IN = "IN"
55 ID = "ID"
56 IE = "IE"
57 IL = "IL"
58 IT = "IT"
59 JM = "JM"
60 JP = "JP"
61 JO = "JO"
62 KE = "KE"
63 KW = "KW"
64 LV = "LV"
65 LI = "LI"
66 LT = "LT"
67 LU = "LU"
68 MO = "MO"
69 MG = "MG"
70 MY = "MY"
71 MT = "MT"
72 MU = "MU"
73 MX = "MX"
74 MD = "MD"
75 MN = "MN"
76 MA = "MA"
77 NA = "NA"
78 NL = "NL"
79 NZ = "NZ"
80 NG = "NG"
81 MK = "MK"
82 NO = "NO"
83 OM = "OM"
84 PA = "PA"
85 PY = "PY"
86 PE = "PE"
87 PH = "PH"
88 PL = "PL"
89 PT = "PT"
90 QA = "QA"
91 RO = "RO"
92 RW = "RW"
93 SA = "SA"
94 SN = "SN"
95 RS = "RS"
96 SG = "SG"
97 SK = "SK"
98 SI = "SI"
99 ZA = "ZA"
100 KR = "KR"
101 ES = "ES"
102 LK = "LK"
103 LC = "LC"
104 SE = "SE"
105 CH = "CH"
106 TZ = "TZ"
107 TH = "TH"
108 TT = "TT"
109 TN = "TN"
110 TR = "TR"
111 AE = "AE"
112 GB = "GB"
113 US = "US"
114 UY = "UY"
115 UZ = "UZ"
116 VN = "VN"
117 DZ = "DZ"
118 AO = "AO"
119 AZ = "AZ"
120 BS = "BS"
121 BD = "BD"
122 BJ = "BJ"
123 BT = "BT"
124 BW = "BW"
125 BN = "BN"
126 GA = "GA"
127 KZ = "KZ"
128 LA = "LA"
129 MC = "MC"
130 MZ = "MZ"
131 NE = "NE"
132 PK = "PK"
133 SM = "SM"
134 TW = "TW"
137class AccountCreateForOrganization(Schema):
138 organization_id: UUID = Field(
139 description="Organization ID to create or get account for"
140 )
142 account_type: Literal[AccountType.stripe]
143 country: Annotated[StripeAccountCountry, BeforeValidator(str.upper)]
146class Account(Schema):
147 id: UUID
148 account_type: AccountType
149 status: AccountModel.Status
150 stripe_id: str | None
151 open_collective_slug: str | None
152 is_details_submitted: bool
153 is_charges_enabled: bool
154 is_payouts_enabled: bool
155 country: str
157 billing_name: str | None
158 billing_address: Address | None
159 billing_additional_info: str | None
160 billing_notes: str | None
162 users: list[UserBase]
163 organizations: list[Organization]
166class AccountUpdate(Schema):
167 billing_name: str | None = Field(
168 default=None,
169 description="Billing name that should appear on the reverse invoice.",
170 )
171 billing_address: AddressInput | None = Field(
172 default=None,
173 description="Billing address that should appear on the reverse invoice.",
174 )
175 billing_additional_info: str | None = Field(
176 default=None,
177 description="Additional information that should appear on the reverse invoice.",
178 )
179 billing_notes: str | None = Field(
180 default=None,
181 description="Notes that should appear on the reverse invoice.",
182 )
185class AccountLink(Schema):
186 url: str