diff --git a/src/hrflow_connectors/connectors/talentsoft/warehouse.py b/src/hrflow_connectors/connectors/talentsoft/warehouse.py index 0ca7602f7..f84fe4106 100644 --- a/src/hrflow_connectors/connectors/talentsoft/warehouse.py +++ b/src/hrflow_connectors/connectors/talentsoft/warehouse.py @@ -170,14 +170,16 @@ class WriteProfileParameters(ParametersModel): ) -def decode_unicode(input_str): +def decode_unicode(input_str: str) -> str: try: return bytes(input_str, "utf-8").decode("unicode_escape") except UnicodeDecodeError: return input_str -def decode_json(obj): +def decode_json( + obj: t.Union[str, list, dict, t.Any] +) -> t.Union[str, list, dict, t.Any]: if isinstance(obj, str): return decode_unicode(obj) elif isinstance(obj, list): @@ -188,6 +190,20 @@ def decode_json(obj): return obj +def get_mime_type_with_mimetypes(filename: t.Optional[str]) -> str: + if filename is None: + return "application/octet-stream" + mime_type, encoding = mimetypes.guess_type(filename) + return mime_type or "application/octet-stream" + + +def get_cv_content(attachment: dict) -> t.Optional[bytes]: + response = requests.get(attachment["public_url"]) + if response.status_code == 200: + return response.content + raise Exception(response.text) + + def get_talentsoft_auth_token( client_url: str, client_id: str, @@ -228,13 +244,6 @@ def get_talentsoft_auth_token( ) -def get_mime_type_with_mimetypes(filename): - if filename is None: - return "application/octet-stream" - mime_type, encoding = mimetypes.guess_type(filename) - return mime_type or "application/octet-stream" - - def post_applicant_front(client_url, token, applicant, files, job_reference=None): if job_reference: headers = { @@ -258,13 +267,6 @@ def post_applicant_front(client_url, token, applicant, files, job_reference=None raise Exception(response.text) -def get_cv_content(attachment): - response = requests.get(attachment["public_url"]) - if response.status_code == 200: - return response.content - raise Exception(response.text) - - def read_jobs( adapter: LoggerAdapter, parameters: ReadProfilesParameters,