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