Skip to content

Commit

Permalink
Merge pull request #69 from huntflow/INT-304_update_dependencies
Browse files Browse the repository at this point in the history
[INT-303] - Switch to pydantic 2.
  • Loading branch information
polina-koval authored Sep 7, 2023
2 parents b755614 + c1d5535 commit 05e2a1b
Show file tree
Hide file tree
Showing 63 changed files with 514 additions and 445 deletions.
5 changes: 5 additions & 0 deletions huntflow_api_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async def request( # type: ignore[no-untyped-def]
data=None,
files=None,
json=None,
content=None,
params=None,
headers=None,
timeout=None,
Expand All @@ -68,6 +69,7 @@ async def request( # type: ignore[no-untyped-def]
data=data,
files=files,
json=json,
content=content,
params=params,
headers=headers,
timeout=timeout,
Expand All @@ -78,6 +80,7 @@ async def request( # type: ignore[no-untyped-def]
data=data,
files=files,
json=json,
content=content,
params=params,
headers=headers,
timeout=timeout,
Expand All @@ -91,6 +94,7 @@ async def _request( # type: ignore[no-untyped-def]
data=None,
files=None,
json=None,
content=None,
params=None,
headers=None,
timeout=None,
Expand All @@ -104,6 +108,7 @@ async def _request( # type: ignore[no-untyped-def]
data=data,
files=files,
json=json,
content=content,
params=params,
headers=headers,
timeout=timeout,
Expand Down
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/account_offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def list(self, account_id: int) -> AccountOffersListResponse:
:return: List of organization's offers
"""
response = await self._api.request("GET", f"/accounts/{account_id}/offers")
return AccountOffersListResponse.parse_obj(response.json())
return AccountOffersListResponse.model_validate(response.json())

async def get(self, account_id: int, offer_id: int) -> AccountOfferResponse:
"""
Expand All @@ -28,4 +28,4 @@ async def get(self, account_id: int, offer_id: int) -> AccountOfferResponse:
:return: Organization's offer with a schema of values
"""
response = await self._api.request("GET", f"/accounts/{account_id}/offers/{offer_id}")
return AccountOfferResponse.parse_obj(response.json())
return AccountOfferResponse.model_validate(response.json())
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/account_vacancy_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def list(
"only_active": only_active,
}
response = await self._api.request("GET", path, params=params)
return AccountVacancyRequestsListResponse.parse_obj(response.json())
return AccountVacancyRequestsListResponse.model_validate(response.json())

async def get(
self,
Expand All @@ -41,4 +41,4 @@ async def get(
"""
path = f"/accounts/{account_id}/account_vacancy_requests/{account_vacancy_request_id}"
response = await self._api.request("GET", path)
return AccountVacancyRequestResponse.parse_obj(response.json())
return AccountVacancyRequestResponse.model_validate(response.json())
6 changes: 3 additions & 3 deletions huntflow_api_client/entities/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def get_current_user(self) -> MeResponse:
:return: Information about the current user
"""
response = await self._api.request("GET", "/me")
return MeResponse.parse_obj(response.json())
return MeResponse.model_validate(response.json())

async def list(self) -> OrganizationsListResponse:
"""
Expand All @@ -24,7 +24,7 @@ async def list(self) -> OrganizationsListResponse:
associated with the passed authentication
"""
response = await self._api.request("GET", "/accounts")
return OrganizationsListResponse.parse_obj(response.json())
return OrganizationsListResponse.model_validate(response.json())

async def get(self, account_id: int) -> OrganizationInfoResponse:
"""
Expand All @@ -34,4 +34,4 @@ async def get(self, account_id: int) -> OrganizationInfoResponse:
:return: Information about the specified organization
"""
response = await self._api.request("GET", f"/accounts/{account_id}")
return OrganizationInfoResponse.parse_obj(response.json())
return OrganizationInfoResponse.model_validate(response.json())
2 changes: 1 addition & 1 deletion huntflow_api_client/entities/action_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ async def list(
f"/accounts/{account_id}/action_logs",
params=params,
)
return ActionLogsResponse.parse_obj(response.json())
return ActionLogsResponse.model_validate(response.json())
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/applicant_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def list(
params["vacancy"] = vacancy

response = await self._api.request("GET", path, params=params)
return ApplicantLogResponse.parse_obj(response.json())
return ApplicantLogResponse.model_validate(response.json())

async def create(
self,
Expand All @@ -70,4 +70,4 @@ async def create(
f"/accounts/{account_id}/applicants/{applicant_id}/logs",
json=data.jsonable_dict(exclude_none=True),
)
return CreateApplicantLogResponse.parse_obj(response.json())
return CreateApplicantLogResponse.model_validate(response.json())
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/applicant_offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def update(
f"/accounts/{account_id}/applicants/{applicant_id}/offers/{offer_id}",
json=data.jsonable_dict(),
)
return ApplicantVacancyOfferResponse.parse_obj(response.json())
return ApplicantVacancyOfferResponse.model_validate(response.json())

async def get(
self,
Expand All @@ -71,4 +71,4 @@ async def get(
f"/vacancy_frames/{vacancy_frame_id}/offer",
params={"normalize": normalize},
)
return ApplicantVacancyOfferResponse.parse_obj(response.json())
return ApplicantVacancyOfferResponse.model_validate(response.json())
6 changes: 3 additions & 3 deletions huntflow_api_client/entities/applicant_on_vacancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def attach_applicant_to_vacancy(
f"/accounts/{account_id}/applicants/{applicant_id}/vacancy",
json=data.jsonable_dict(exclude_none=True),
)
return AddApplicantToVacancyResponse.parse_obj(response.json())
return AddApplicantToVacancyResponse.model_validate(response.json())

async def change_vacancy_status_for_applicant(
self,
Expand All @@ -57,7 +57,7 @@ async def change_vacancy_status_for_applicant(
f"/accounts/{account_id}/applicants/{applicant_id}/vacancy",
json=data.jsonable_dict(exclude_none=True),
)
return AddApplicantToVacancyResponse.parse_obj(response.json())
return AddApplicantToVacancyResponse.model_validate(response.json())

async def move_applicant_to_child_vacancy(
self,
Expand All @@ -79,4 +79,4 @@ async def move_applicant_to_child_vacancy(
f"/accounts/{account_id}/applicants/vacancy/{vacancy_id}/split",
json=data.jsonable_dict(exclude_none=True),
)
return ApplicantVacancySplitResponse.parse_obj(response.json())
return ApplicantVacancySplitResponse.model_validate(response.json())
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ async def list(self, account_id: int) -> VacancyStatusesResponse:
:return: List of available applicant on vacancy statuses (stages)
"""
response = await self._api.request("GET", f"/accounts/{account_id}/vacancies/statuses")
return VacancyStatusesResponse.parse_obj(response.json())
return VacancyStatusesResponse.model_validate(response.json())
10 changes: 5 additions & 5 deletions huntflow_api_client/entities/applicants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def list(
f"/accounts/{account_id}/applicants",
params=params,
)
return ApplicantListResponse.parse_obj(response.json())
return ApplicantListResponse.model_validate(response.json())

async def create(
self,
Expand All @@ -73,7 +73,7 @@ async def create(
f"/accounts/{account_id}/applicants",
json=data.jsonable_dict(exclude_none=True),
)
return ApplicantCreateResponse.parse_obj(response.json())
return ApplicantCreateResponse.model_validate(response.json())

async def get(self, account_id: int, applicant_id: int) -> ApplicantItem:
"""
Expand All @@ -88,7 +88,7 @@ async def get(self, account_id: int, applicant_id: int) -> ApplicantItem:
"GET",
f"/accounts/{account_id}/applicants/{applicant_id}",
)
return ApplicantItem.parse_obj(response.json())
return ApplicantItem.model_validate(response.json())

async def patch(
self,
Expand All @@ -110,7 +110,7 @@ async def patch(
f"/accounts/{account_id}/applicants/{applicant_id}",
json=data.jsonable_dict(exclude_none=True),
)
return ApplicantItem.parse_obj(response.json())
return ApplicantItem.model_validate(response.json())

async def delete(self, account_id: int, applicant_id: int) -> None:
"""
Expand Down Expand Up @@ -185,4 +185,4 @@ async def search_by_cursor(
params["vacancy"] = vacancy if vacancy else "null"

response = await self._api.request("GET", path, params=params)
return ApplicantSearchByCursorResponse.parse_obj(response.json())
return ApplicantSearchByCursorResponse.model_validate(response.json())
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/coworkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def list(
f"/accounts/{account_id}/coworkers",
params=params,
)
return CoworkersListResponse(**response.json())
return CoworkersListResponse.model_validate(response.json())

async def get(
self,
Expand All @@ -68,4 +68,4 @@ async def get(
f"/accounts/{account_id}/coworkers",
params=params,
)
return CoworkerResponse(**response.json())
return CoworkerResponse.model_validate(response.json())
2 changes: 1 addition & 1 deletion huntflow_api_client/entities/delayed_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ async def get(self, account_id: int, task_id: str) -> DelayedTaskResponse:

path = f"/accounts/{account_id}/delayed_tasks/{task_id}"
response = await self._api.request("GET", path)
return DelayedTaskResponse.parse_obj(response.json())
return DelayedTaskResponse.model_validate(response.json())
8 changes: 4 additions & 4 deletions huntflow_api_client/entities/dictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def list(self, account_id: int) -> DictionariesListResponse:
"""
path = f"/accounts/{account_id}/dictionaries"
response = await self._api.request("GET", path)
data = DictionariesListResponse.parse_obj(response.json())
data = DictionariesListResponse.model_validate(response.json())
return data

async def create(
Expand All @@ -44,7 +44,7 @@ async def create(
"""
path = f"/accounts/{account_id}/dictionaries"
response = await self._api.request("POST", path, json=data.jsonable_dict(exclude_none=True))
return DictionaryTaskResponse.parse_obj(response.json())
return DictionaryTaskResponse.model_validate(response.json())

async def get(self, account_id: int, dict_code: str) -> DictionaryResponse:
"""
Expand All @@ -57,7 +57,7 @@ async def get(self, account_id: int, dict_code: str) -> DictionaryResponse:
"""
path = f"/accounts/{account_id}/dictionaries/{dict_code}"
response = await self._api.request("GET", path)
return DictionaryResponse.parse_obj(response.json())
return DictionaryResponse.model_validate(response.json())

async def update(
self,
Expand All @@ -76,4 +76,4 @@ async def update(
"""
path = f"/accounts/{account_id}/dictionaries/{dict_code}"
response = await self._api.request("PUT", path, json=data.jsonable_dict(exclude_none=True))
return DictionaryTaskResponse.parse_obj(response.json())
return DictionaryTaskResponse.model_validate(response.json())
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/divisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def list(
path,
params=params,
)
return DivisionsListResponse.parse_obj(response.json())
return DivisionsListResponse.model_validate(response.json())

async def create(
self,
Expand All @@ -67,4 +67,4 @@ async def create(
f"/accounts/{account_id}/divisions/batch",
json=divisions.jsonable_dict(exclude_none=True),
)
return BatchDivisionsResponse.parse_obj(response.json())
return BatchDivisionsResponse.model_validate(response.json())
2 changes: 1 addition & 1 deletion huntflow_api_client/entities/email_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ async def list(self, account_id: int, editable: bool = False) -> MailTemplatesRe
f"/accounts/{account_id}/mail/templates",
params={"editable": editable},
)
return MailTemplatesResponse.parse_obj(response.json())
return MailTemplatesResponse.model_validate(response.json())
2 changes: 1 addition & 1 deletion huntflow_api_client/entities/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ async def upload(
data=data,
headers=headers.jsonable_dict(exclude_none=True, by_alias=True),
)
return UploadResponse(**response.json())
return UploadResponse.model_validate(response.json())
4 changes: 2 additions & 2 deletions huntflow_api_client/entities/multi_vacancies.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def create(
f"/accounts/{account_id}/multi-vacancies",
json=data.jsonable_dict(exclude_none=True),
)
return MultiVacancyResponse.parse_obj(response.json())
return MultiVacancyResponse.model_validate(response.json())

async def update(
self,
Expand All @@ -54,4 +54,4 @@ async def update(
f"/accounts/{account_id}/multi-vacancies/{vacancy_id}",
json=data.jsonable_dict(exclude_none=True),
)
return MultiVacancyResponse.parse_obj(response.json())
return MultiVacancyResponse.model_validate(response.json())
6 changes: 3 additions & 3 deletions huntflow_api_client/entities/organization_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def get_hold_reasons(self, account_id: int) -> HoldReasonsListResponse:
"GET",
f"/accounts/{account_id}/vacancy_hold_reasons",
)
return HoldReasonsListResponse(**response.json())
return HoldReasonsListResponse.model_validate(response.json())

async def get_close_reasons(self, account_id: int) -> CloseReasonsListResponse:
"""
Expand All @@ -33,7 +33,7 @@ async def get_close_reasons(self, account_id: int) -> CloseReasonsListResponse:
"GET",
f"/accounts/{account_id}/vacancy_close_reasons",
)
return CloseReasonsListResponse(**response.json())
return CloseReasonsListResponse.model_validate(response.json())

async def get_applicant_survey_form(
self,
Expand All @@ -52,4 +52,4 @@ async def get_applicant_survey_form(
"GET",
f"/accounts/{account_id}/surveys/type_a/{survey_id}",
)
return BaseSurveySchemaTypeWithSchemas(**response.json())
return BaseSurveySchemaTypeWithSchemas.model_validate(response.json())
20 changes: 10 additions & 10 deletions huntflow_api_client/entities/production_calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def list(self) -> CalendarListResponse:
"""
path = "/production_calendars"
response = await self._api.request("GET", path)
return CalendarListResponse.parse_obj(response.json())
return CalendarListResponse.model_validate(response.json())

async def get(self, calendar_id: int) -> CalendarResponse:
"""
Expand All @@ -37,7 +37,7 @@ async def get(self, calendar_id: int) -> CalendarResponse:
"""
path = f"/production_calendars/{calendar_id}"
response = await self._api.request("GET", path)
return CalendarResponse.parse_obj(response.json())
return CalendarResponse.model_validate(response.json())

async def get_organizations_calendar(self, account_id: int) -> AccountCalendarResponse:
"""
Expand All @@ -48,7 +48,7 @@ async def get_organizations_calendar(self, account_id: int) -> AccountCalendarRe
"""
path = f"/accounts/{account_id}/calendar"
response = await self._api.request("GET", path)
return AccountCalendarResponse.parse_obj(response.json())
return AccountCalendarResponse.model_validate(response.json())

async def get_non_working_days_in_period(
self,
Expand All @@ -74,7 +74,7 @@ async def get_non_working_days_in_period(
params["start"] = start.strftime("%Y-%m-%d")
path = f"/production_calendars/{calendar_id}/days/{deadline}"
response = await self._api.request("GET", path, params=params)
return NonWorkingDaysResponse.parse_obj(response.json())
return NonWorkingDaysResponse.model_validate(response.json())

async def get_non_working_days_for_multiple_period(
self,
Expand All @@ -91,8 +91,8 @@ async def get_non_working_days_for_multiple_period(
specified periods
"""
path = f"/production_calendars/{calendar_id}/days"
response = await self._api.request("POST", path, data=data.json())
return NonWorkingDaysBulkResponse.parse_obj(response.json())
response = await self._api.request("POST", path, content=data.model_dump_json())
return NonWorkingDaysBulkResponse.model_validate(response.json())

async def get_deadline_date_with_non_working_days(
self,
Expand Down Expand Up @@ -130,8 +130,8 @@ async def get_multiple_deadline_dates_with_non_working_days(
:return: List of deadlines
"""
path = f"/production_calendars/{calendar_id}/deadline"
response = await self._api.request("POST", path, data=data.json())
return DatesBulkResponse.parse_obj(response.json())
response = await self._api.request("POST", path, content=data.model_dump_json())
return DatesBulkResponse.model_validate(response.json())

async def get_start_date_with_non_working_days(
self,
Expand Down Expand Up @@ -170,5 +170,5 @@ async def get_multiple_start_dates_with_non_working_days(
:return: List of start dates
"""
path = f"/production_calendars/{calendar_id}/start"
response = await self._api.request("POST", path, data=data.json())
return DatesBulkResponse.parse_obj(response.json())
response = await self._api.request("POST", path, content=data.model_dump_json())
return DatesBulkResponse.model_validate(response.json())
2 changes: 1 addition & 1 deletion huntflow_api_client/entities/questionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def get_schema(self, account_id: int) -> QuestionarySchemaResponse:
:return: A schema of applicant's questionary for organization
"""
response = await self._api.request("GET", f"/accounts/{account_id}/applicants/questionary")
return QuestionarySchemaResponse.parse_obj(response.json())
return QuestionarySchemaResponse.model_validate(response.json())

async def create(
self,
Expand Down
Loading

0 comments on commit 05e2a1b

Please sign in to comment.