Skip to content

Commit

Permalink
fix: modify write profiles parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdellahitech committed Dec 28, 2023
1 parent 805f2be commit 41ada3e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 42 deletions.
55 changes: 33 additions & 22 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3932,45 +3932,56 @@
"description": "Parameters for write action",
"type": "object",
"properties": {
"client_id": {
"title": "Client Id",
"client_id_front": {
"title": "Client Id Front",
"description": "client id used to access TalentSoft front office API",
"field_type": "Auth",
"type": "string"
},
"client_secret": {
"title": "Client Secret",
"description": "client secret used to access TalentSoft API",
"client_secret_front": {
"title": "Client Secret Front",
"description": "client secret used to access TalentSoft front office API",
"field_type": "Auth",
"type": "string"
},
"client_url": {
"title": "Client Url",
"description": "url used to access TalentSoft API",
"client_url_front": {
"title": "Client Url Front",
"description": "url used to access TalentSoft front office API",
"field_type": "Auth",
"type": "string"
},
"job_reference": {
"title": "Job Reference",
"description": "reference of the job offer to which the candidate is applying",
"client_id_back": {
"title": "Client Id Back",
"description": "client id used to access TalentSoft back office API",
"field_type": "Auth",
"type": "string"
},
"front_or_back": {
"title": "Front Or Back",
"description": "front or back office",
"client_secret_back": {
"title": "Client Secret Back",
"description": "client secret used to access TalentSoft back office API",
"field_type": "Auth",
"type": "string"
},
"client_url_back": {
"title": "Client Url Back",
"description": "url used to access TalentSoft back office API",
"field_type": "Auth",
"type": "string"
},
"job_reference": {
"title": "Job Reference",
"description": "reference of the job offer to which the candidate is applying",
"field_type": "Auth",
"enum": [
"front",
"back"
],
"type": "string"
}
},
"required": [
"client_id",
"client_secret",
"client_url"
"client_id_front",
"client_secret_front",
"client_url_front",
"client_id_back",
"client_secret_back",
"client_url_back"
],
"additionalProperties": false
},
Expand All @@ -3979,7 +3990,7 @@
"type": "object",
"properties": {}
},
"workflow_code": "import typing as t\n\nfrom hrflow_connectors import TalentSoft\nfrom hrflow_connectors.core.connector import ActionInitError, Reason\n\nORIGIN_SETTINGS_PREFIX = \"origin_\"\nTARGET_SETTINGS_PREFIX = \"target_\"\n\n# << format_placeholder >>\n\n# << logics_placeholder >>\n\n# << event_parser_placeholder >>\n\n\ndef workflow(\n \n _request: t.Dict,\n \n settings: t.Dict\n ) -> None:\n actions_parameters = dict()\n try:\n format\n except NameError:\n pass\n else:\n actions_parameters[\"format\"] = format\n\n try:\n logics\n except NameError:\n pass\n else:\n actions_parameters[\"logics\"] = logics\n\n if \"__workflow_id\" not in settings:\n return TalentSoft.push_profile(\n workflow_id=\"\",\n action_parameters=dict(),\n origin_parameters=dict(),\n target_parameters=dict(),\n init_error=ActionInitError(\n reason=Reason.workflow_id_not_found,\n data=dict(error=\"__workflow_id not found in settings\", settings_keys=list(settings.keys())),\n )\n )\n workflow_id = settings[\"__workflow_id\"]\n\n \n try:\n event_parser\n _event_parser = event_parser\n except NameError as e:\n action = TalentSoft.model.action_by_name(\"push_profile\")\n # Without this trick event_parser is always only fetched from the local scope\n # meaning that try block always raises NameError even if the function is\n # defined in the placeholder\n _event_parser = action.parameters.__fields__[\"event_parser\"].default\n\n if _event_parser is not None:\n try:\n _request = _event_parser(_request)\n except Exception as e:\n return TalentSoft.push_profile(\n workflow_id=workflow_id,\n action_parameters=dict(),\n origin_parameters=dict(),\n target_parameters=dict(),\n init_error=ActionInitError(\n reason=Reason.event_parsing_failure,\n data=dict(error=e, event=_request),\n )\n )\n \n\n origin_parameters = dict()\n for parameter in ['api_secret', 'api_user', 'source_key', 'profile_key']:\n if \"{}{}\".format(ORIGIN_SETTINGS_PREFIX, parameter) in settings:\n origin_parameters[parameter] = settings[\"{}{}\".format(ORIGIN_SETTINGS_PREFIX, parameter)]\n \n if parameter in _request:\n origin_parameters[parameter] = _request[parameter]\n \n\n target_parameters = dict()\n for parameter in ['client_id', 'client_secret', 'client_url', 'job_reference', 'front_or_back']:\n if \"{}{}\".format(TARGET_SETTINGS_PREFIX, parameter) in settings:\n target_parameters[parameter] = settings[\"{}{}\".format(TARGET_SETTINGS_PREFIX, parameter)]\n \n if parameter in _request:\n target_parameters[parameter] = _request[parameter]\n \n\n return TalentSoft.push_profile(\n workflow_id=workflow_id,\n action_parameters=actions_parameters,\n origin_parameters=origin_parameters,\n target_parameters=target_parameters,\n )",
"workflow_code": "import typing as t\n\nfrom hrflow_connectors import TalentSoft\nfrom hrflow_connectors.core.connector import ActionInitError, Reason\n\nORIGIN_SETTINGS_PREFIX = \"origin_\"\nTARGET_SETTINGS_PREFIX = \"target_\"\n\n# << format_placeholder >>\n\n# << logics_placeholder >>\n\n# << event_parser_placeholder >>\n\n\ndef workflow(\n \n _request: t.Dict,\n \n settings: t.Dict\n ) -> None:\n actions_parameters = dict()\n try:\n format\n except NameError:\n pass\n else:\n actions_parameters[\"format\"] = format\n\n try:\n logics\n except NameError:\n pass\n else:\n actions_parameters[\"logics\"] = logics\n\n if \"__workflow_id\" not in settings:\n return TalentSoft.push_profile(\n workflow_id=\"\",\n action_parameters=dict(),\n origin_parameters=dict(),\n target_parameters=dict(),\n init_error=ActionInitError(\n reason=Reason.workflow_id_not_found,\n data=dict(error=\"__workflow_id not found in settings\", settings_keys=list(settings.keys())),\n )\n )\n workflow_id = settings[\"__workflow_id\"]\n\n \n try:\n event_parser\n _event_parser = event_parser\n except NameError as e:\n action = TalentSoft.model.action_by_name(\"push_profile\")\n # Without this trick event_parser is always only fetched from the local scope\n # meaning that try block always raises NameError even if the function is\n # defined in the placeholder\n _event_parser = action.parameters.__fields__[\"event_parser\"].default\n\n if _event_parser is not None:\n try:\n _request = _event_parser(_request)\n except Exception as e:\n return TalentSoft.push_profile(\n workflow_id=workflow_id,\n action_parameters=dict(),\n origin_parameters=dict(),\n target_parameters=dict(),\n init_error=ActionInitError(\n reason=Reason.event_parsing_failure,\n data=dict(error=e, event=_request),\n )\n )\n \n\n origin_parameters = dict()\n for parameter in ['api_secret', 'api_user', 'source_key', 'profile_key']:\n if \"{}{}\".format(ORIGIN_SETTINGS_PREFIX, parameter) in settings:\n origin_parameters[parameter] = settings[\"{}{}\".format(ORIGIN_SETTINGS_PREFIX, parameter)]\n \n if parameter in _request:\n origin_parameters[parameter] = _request[parameter]\n \n\n target_parameters = dict()\n for parameter in ['client_id_front', 'client_secret_front', 'client_url_front', 'client_id_back', 'client_secret_back', 'client_url_back', 'job_reference']:\n if \"{}{}\".format(TARGET_SETTINGS_PREFIX, parameter) in settings:\n target_parameters[parameter] = settings[\"{}{}\".format(TARGET_SETTINGS_PREFIX, parameter)]\n \n if parameter in _request:\n target_parameters[parameter] = _request[parameter]\n \n\n return TalentSoft.push_profile(\n workflow_id=workflow_id,\n action_parameters=actions_parameters,\n origin_parameters=origin_parameters,\n target_parameters=target_parameters,\n )",
"workflow_code_format_placeholder": "# << format_placeholder >>",
"workflow_code_logics_placeholder": "# << logics_placeholder >>",
"workflow_code_event_parser_placeholder": "# << event_parser_placeholder >>",
Expand Down
20 changes: 12 additions & 8 deletions src/hrflow_connectors/connectors/talentsoft/docs/push_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ Pushs specific Profile from HrFlow and writes it to Applicant object in Talentso

| Field | Type | Default | Description |
| ----- | ---- | ------- | ----------- |
| `client_id` :red_circle: | `str` | None | client id used to access TalentSoft front office API |
| `client_secret` :red_circle: | `str` | None | client secret used to access TalentSoft API |
| `client_url` :red_circle: | `str` | None | url used to access TalentSoft API |
| `client_id_front` :red_circle: | `str` | None | client id used to access TalentSoft front office API |
| `client_secret_front` :red_circle: | `str` | None | client secret used to access TalentSoft front office API |
| `client_url_front` :red_circle: | `str` | None | url used to access TalentSoft front office API |
| `client_id_back` :red_circle: | `str` | None | client id used to access TalentSoft back office API |
| `client_secret_back` :red_circle: | `str` | None | client secret used to access TalentSoft back office API |
| `client_url_back` :red_circle: | `str` | None | url used to access TalentSoft back office API |
| `job_reference` | `str` | None | reference of the job offer to which the candidate is applying |
| `front_or_back` | `typing_extensions.Literal['front', 'back']` | None | front or back office |

:red_circle: : *required*

Expand Down Expand Up @@ -59,11 +61,13 @@ TalentSoft.push_profile(
profile_key="your_profile_key",
),
target_parameters=dict(
client_id="your_client_id",
client_secret="your_client_secret",
client_url="your_client_url",
client_id_front="your_client_id_front",
client_secret_front="your_client_secret_front",
client_url_front="your_client_url_front",
client_id_back="your_client_id_back",
client_secret_back="your_client_secret_back",
client_url_back="your_client_url_back",
job_reference="your_job_reference",
front_or_back=***,
)
)
```
35 changes: 23 additions & 12 deletions src/hrflow_connectors/connectors/talentsoft/warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from zipfile import ZipFile

import requests
import typing_extensions as te
from pydantic import Field, PositiveInt

from hrflow_connectors.core import (
Expand Down Expand Up @@ -126,33 +125,45 @@ class ReadJobsParameters(ParametersModel):
class WriteProfileParameters(ParametersModel):
"""Parameters for write action"""

client_id: str = Field(
client_id_front: str = Field(
...,
description="client id used to access TalentSoft front office API",
repr=False,
field_type=FieldType.Auth,
)
client_secret: str = Field(
client_secret_front: str = Field(
...,
description="client secret used to access TalentSoft API",
description="client secret used to access TalentSoft front office API",
repr=False,
field_type=FieldType.Auth,
)
client_url: str = Field(
client_url_front: str = Field(
...,
description="url used to access TalentSoft API",
description="url used to access TalentSoft front office API",
repr=False,
field_type=FieldType.Auth,
)
job_reference: str = Field(
None,
description="reference of the job offer to which the candidate is applying",
client_id_back: str = Field(
...,
description="client id used to access TalentSoft back office API",
repr=False,
field_type=FieldType.Auth,
)
front_or_back: te.Literal["front", "back"] = Field(
client_secret_back: str = Field(
...,
description="client secret used to access TalentSoft back office API",
repr=False,
field_type=FieldType.Auth,
)
client_url_back: str = Field(
...,
description="url used to access TalentSoft back office API",
repr=False,
field_type=FieldType.Auth,
)
job_reference: str = Field(
None,
description="front or back office",
description="reference of the job offer to which the candidate is applying",
repr=False,
field_type=FieldType.Auth,
)
Expand Down Expand Up @@ -381,7 +392,7 @@ def write_profiles(
client_url=parameters.client_url,
client_id=parameters.client_id,
client_secret=parameters.client_secret,
front_or_back=parameters.front_or_back,
front_or_back="front",
)
for profile in profiles:
attachment = profile.pop("attachment", None)
Expand Down

0 comments on commit 41ada3e

Please sign in to comment.