Skip to content

Commit 9427a04

Browse files
authored
Merge pull request #10 from huntflow/INT-307_update_dependicies
[INT-307]- Switch to pydantic 2.
2 parents 492454b + fbbaee9 commit 9427a04

File tree

11 files changed

+459
-316
lines changed

11 files changed

+459
-316
lines changed

huntflow_webhook_models/base.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66

77

88
class Account(BaseModel):
9-
id: int = Field(..., description="Account ID", example=1)
10-
name: str = Field(..., description="Account name", example="Huntflow")
11-
nick: str = Field(..., description="Account nick", example="HF")
9+
id: int = Field(..., description="Account ID", examples=[1])
10+
name: str = Field(..., description="Account name", examples=["Huntflow"])
11+
nick: str = Field(..., description="Account nick", examples=["HF"])
1212

1313

1414
class Author(BaseModel):
15-
id: int = Field(..., description="Account ID", example=1)
16-
email: str = Field(..., description="Account owner email", example="[email protected]")
17-
name: str = Field(..., description="Account owner name", example="John")
18-
meta: Optional[Dict] = Field(None, description="Additional data", example={"data": "data"})
15+
id: int = Field(..., description="Account ID", examples=[1])
16+
email: str = Field(..., description="Account owner email", examples=["[email protected]"])
17+
name: str = Field(..., description="Account owner name", examples=["John"])
18+
meta: Optional[Dict] = Field(None, description="Additional data", examples=[{"data": "data"}])
1919

2020

2121
class WebhookMetaInfoBase(BaseModel):
2222
account: Account
23-
author: Optional[Author]
23+
author: Optional[Author] = None
2424
event_type: WebhookEventType = Field(
2525
...,
2626
description="Webhook event type",
27-
example=WebhookEventType.APPLICANT,
27+
examples=[WebhookEventType.APPLICANT],
2828
)
29-
version: str = Field(..., description="Webhook version", example="2.0")
30-
retry: int = Field(..., description="Webhook retry count", example=1)
31-
event_id: str = Field(..., description="Event ID", example="1")
29+
version: str = Field(..., description="Webhook version", examples=["2.0"])
30+
retry: int = Field(..., description="Webhook retry count", examples=[1])
31+
event_id: str = Field(..., description="Event ID", examples=["1"])
3232

3333

3434
class BaseHuntflowWebhookRequest(BaseModel):
35-
changes: Optional[Dict] = Field(..., description="Data changes", example={"id": 2})
35+
changes: Optional[Dict] = Field(None, description="Data changes", examples=[{"id": 2}])
3636
meta: WebhookMetaInfoBase

huntflow_webhook_models/common_models/applicant.py

+61-49
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,77 @@
1111

1212

1313
class ApplicantSocial(BaseModel):
14-
id: int = Field(..., description="Social ID", example=1)
15-
social_type: str = Field(..., description="Social type", example="TELEGRAM")
16-
value: str = Field(..., description="Social nick/email", example="test_tg")
17-
verified: bool = Field(..., description="Verification flag", example=True)
14+
id: int = Field(..., description="Social ID", examples=[1])
15+
social_type: str = Field(..., description="Social type", examples=["TELEGRAM"])
16+
value: str = Field(..., description="Social nick/email", examples=["test_tg"])
17+
verified: bool = Field(..., description="Verification flag", examples=[True])
1818
verification_date: Optional[datetime] = Field(
1919
None,
2020
description="Verification datetime",
21-
example=datetime(1970, 1, 1, 1, 1, 1),
21+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
2222
)
2323

2424

2525
class ApplicantPDAgreement(BaseModel):
2626
state: Optional[AgreementState] = Field(
2727
None,
2828
description="Agreement state",
29-
example=AgreementState.NOT_SENT,
29+
examples=[AgreementState.NOT_SENT],
3030
)
3131
decision_date: Optional[datetime] = Field(
3232
None,
3333
description="Decision date",
34-
example=datetime(1970, 1, 1, 1, 1, 1),
34+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
3535
)
3636

3737

3838
class VacancyApplicantStatus(BaseModel):
39-
id: int = Field(..., description="Status ID", example=1)
40-
name: str = Field(..., description="Status name", example="hired")
39+
id: int = Field(..., description="Status ID", examples=[1])
40+
name: str = Field(..., description="Status name", examples=["hired"])
4141

4242

4343
class ApplicantPhoto(AccountFile):
4444
pass
4545

4646

4747
class Applicant(BaseModel):
48-
id: int = Field(..., description="Applicant ID", example=1)
49-
email: Optional[str] = Field(None, description="Applicant's email", example="[email protected]")
50-
first_name: str = Field(..., description="Applicant's firstname", example="test_name")
51-
last_name: str = Field(..., description="Applicant's lastname", example="test")
52-
middle_name: Optional[str] = Field(None, description="Applicant's patronymic", example="test")
53-
position: Optional[str] = Field(None, description="Applicant's current job", example="test")
48+
id: int = Field(..., description="Applicant ID", examples=[1])
49+
email: Optional[str] = Field(
50+
None,
51+
description="Applicant's email",
52+
examples=["[email protected]"],
53+
)
54+
first_name: str = Field(..., description="Applicant's firstname", examples=["test_name"])
55+
last_name: str = Field(..., description="Applicant's lastname", examples=["test"])
56+
middle_name: Optional[str] = Field(
57+
None,
58+
description="Applicant's patronymic",
59+
examples=["test"],
60+
)
61+
position: Optional[str] = Field(None, description="Applicant's current job", examples=["test"])
5462
birthday: Optional[date] = Field(
5563
None,
5664
description="Applicant's birthday",
57-
example=date(1970, 1, 1),
65+
examples=[date(1970, 1, 1)],
5866
)
5967
company: Optional[str] = Field(
6068
None,
6169
description="Last company the applicant worked for",
62-
example="test",
70+
examples=["test"],
6371
)
64-
money: Optional[str] = Field(None, description="Desired salary of the applicant", example="10$")
65-
phone: Optional[str] = Field(None, description="Applicant's phone", example="+99999999")
66-
skype: Optional[str] = Field(None, description="Applicant's skype", example="test_skype")
72+
money: Optional[str] = Field(
73+
None,
74+
description="Desired salary of the applicant",
75+
examples=["10$"],
76+
)
77+
phone: Optional[str] = Field(None, description="Applicant's phone", examples=["+99999999"])
78+
skype: Optional[str] = Field(None, description="Applicant's skype", examples=["test_skype"])
6779
photo: Optional[ApplicantPhoto] = Field(None, description="Applicant's photo")
6880
social: List[ApplicantSocial] = Field([], description="Applicant social media list")
6981
questionary: Optional[datetime] = Field(
7082
None,
7183
description="Date of filling / changing additional information",
72-
example=datetime(1970, 1, 1, 1, 1, 1, 1),
84+
examples=[datetime(1970, 1, 1, 1, 1, 1, 1)],
7385
)
7486
pd_agreement: Optional[ApplicantPDAgreement] = Field(
7587
None,
@@ -78,85 +90,85 @@ class Applicant(BaseModel):
7890
values: Optional[Dict[str, Any]] = Field(
7991
None,
8092
description="Additional applicant fields",
81-
example={"favorite_language": "python"},
93+
examples=[{"favorite_language": "python"}],
8294
)
8395

8496

8597
class Respondent(BaseModel):
86-
account_id: int = Field(..., description="Account ID", example=1)
87-
custom_id: Optional[int] = Field(None, description="Custom ID", example=1)
88-
name: Optional[str] = Field(None, description="Respondent name", example="John")
89-
email: str = Field(..., description="Respondent email", example="[email protected]")
98+
account_id: int = Field(..., description="Account ID", examples=[1])
99+
custom_id: Optional[int] = Field(None, description="Custom ID", examples=[1])
100+
name: Optional[str] = Field(None, description="Respondent name", examples=["John"])
101+
email: str = Field(..., description="Respondent email", examples=["[email protected]"])
90102

91103

92104
class Survey(BaseModel):
93-
id: int = Field(..., description="Survey ID", example=1)
94-
name: str = Field(..., description="Survey name", example="test")
95-
type: SurveyType = Field(..., description="Survey type", example=SurveyType.TYPE_A)
105+
id: int = Field(..., description="Survey ID", examples=[1])
106+
name: str = Field(..., description="Survey name", examples=["test"])
107+
type: SurveyType = Field(..., description="Survey type", examples=[SurveyType.TYPE_A])
96108
created: datetime = Field(
97109
...,
98110
description="Date the survey was created",
99-
example=datetime(1970, 1, 1, 1, 1, 1),
111+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
100112
)
101113
updated: Optional[datetime] = Field(
102114
None,
103115
description="Date the survey was changed",
104-
example=datetime(1970, 1, 1, 1, 1, 1),
116+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
105117
)
106-
active: bool = Field(..., description="Active flag", example=True)
118+
active: bool = Field(..., description="Active flag", examples=[True])
107119

108120

109121
class SurveyAnswerOfTypeA(BaseModel):
110-
id: int = Field(..., description="Survey answer ID", example=1)
122+
id: int = Field(..., description="Survey answer ID", examples=[1])
111123
respondent: Respondent
112124
survey: Survey
113125
created: datetime = Field(
114126
...,
115127
description="Date of the questionnaire",
116-
example=datetime(1970, 1, 1, 1, 1, 1),
128+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
117129
)
118130
updated: Optional[datetime] = Field(
119-
...,
131+
None,
120132
description="Date the questionnaire was modified",
121-
example=datetime(1970, 1, 1, 1, 1, 1),
133+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
122134
)
123135
values: Optional[Dict[str, Any]] = Field(
124136
None,
125137
description="Survey results",
126-
example={"question": "answer"},
138+
examples=[{"question": "answer"}],
127139
)
128140

129141

130142
class RejectionReason(BaseModel):
131-
id: int = Field(..., description="Rejection reason ID", example=1)
132-
name: str = Field(..., description="Rejection reason name", example="Too far")
143+
id: int = Field(..., description="Rejection reason ID", examples=[1])
144+
name: str = Field(..., description="Rejection reason name", examples=["Too far"])
133145

134146

135147
class ApplicantLog(BaseModel):
136-
id: int = Field(..., description="Applicant log ID", example=1)
148+
id: int = Field(..., description="Applicant log ID", examples=[1])
137149
type: ApplicantLogType = Field(
138150
...,
139151
description="Applicant log type",
140-
example=ApplicantLogType.STATUS,
152+
examples=[ApplicantLogType.STATUS],
141153
)
142154
status: Optional[VacancyApplicantStatus] = None
143155
employment_date: Optional[date] = Field(
144156
None,
145157
description="Applicant employment date",
146-
example=date(1970, 1, 1),
158+
examples=[date(1970, 1, 1)],
147159
)
148160
removed: Optional[datetime] = Field(
149161
None,
150162
description="Record delete date time",
151-
example=datetime(1970, 1, 1, 1, 1, 1),
163+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
152164
)
153-
comment: Optional[str] = Field(None, description="Comment", example="comment")
165+
comment: Optional[str] = Field(None, description="Comment", examples=["comment"])
154166
created: datetime = Field(
155167
...,
156168
description="Log creation date time",
157-
example=datetime(1970, 1, 1, 1, 1, 1),
169+
examples=[datetime(1970, 1, 1, 1, 1, 1)],
158170
)
159-
source: Optional[str]
171+
source: Optional[str] = None
160172
files: List[AccountFile] = Field([], description="List of uploaded files")
161173
survey_answer_of_type_a: Optional[SurveyAnswerOfTypeA] = None
162174
rejection_reason: Optional[RejectionReason] = None
@@ -166,6 +178,6 @@ class ApplicantLog(BaseModel):
166178

167179

168180
class ApplicantTag(BaseModel):
169-
id: int = Field(..., description="Tag ID", example=1)
170-
name: str = Field(..., description="Tag name", example="COOL")
171-
color: str = Field(..., description="Tag color", example="000000")
181+
id: int = Field(..., description="Tag ID", examples=[1])
182+
name: str = Field(..., description="Tag name", examples=["COOL"])
183+
color: str = Field(..., description="Tag color", examples=["000000"])

0 commit comments

Comments
 (0)