Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 86 additions & 8 deletions examples/job/job_endpoints_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -293,30 +293,108 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'code': 200,\n",
" 'message': 'Job edited',\n",
" 'data': {'id': 1264450,\n",
" 'key': '8cee3ead87a38cc1f7f3cf9298b7e58e16406e05',\n",
" 'reference': 'my_custom_reference',\n",
" 'board_key': '7fce016712fa373456ef279c297da5009a2020d9',\n",
" 'board': {'key': '7fce016712fa373456ef279c297da5009a2020d9',\n",
" 'name': 'vulcain_test',\n",
" 'type': 'api',\n",
" 'subtype': 'python',\n",
" 'environment': 'production'},\n",
" 'name': 'Data Engineer',\n",
" 'url': 'https://www.pole-emploi.ai/jobs/data_engineer',\n",
" 'picture': None,\n",
" 'summary': 'As an engineer for the Data Engineering Infrastructure team, you will design, build, scale, and evolve our data engineering platform, services and tooling. Your work will have a critical impact on all areas of business:supporting detailed internal analytics, calculating customer usage, securing our platform, and much more.',\n",
" 'location': {'text': 'Dampierre en Burly (45)',\n",
" 'lat': None,\n",
" 'lng': None,\n",
" 'gmaps': None,\n",
" 'fields': []},\n",
" 'archive': None,\n",
" 'archived_at': None,\n",
" 'updated_at': '2023-06-21T15:54:45+0000',\n",
" 'created_at': '2023-06-21T15:54:45+0000',\n",
" 'sections': [{'name': 'section 1',\n",
" 'title': 'title section 1',\n",
" 'description': 'text section 1'}],\n",
" 'culture': 'This is a New CULTURE 123!!',\n",
" 'responsibilities': 'FILL THIS WITH A TEXT ABOUT THE RESPONSIBILITIES OF THE JOB',\n",
" 'requirements': 'FILL THIS WITH A TEXT ABOUT THE REQUIREMENTS OF THE JOB',\n",
" 'benefits': 'FILL THIS WITH A TEXT ABOUT THE BENEFITS OF THE JOB',\n",
" 'interviews': 'FILL THIS WITH A TEXT ABOUT THE INTERVIEWS OF THE JOB',\n",
" 'skills': [{'name': 'python', 'value': None, 'type': 'hard'},\n",
" {'name': 'spark', 'value': 0.9, 'type': 'hard'}],\n",
" 'languages': [{'name': 'english', 'value': None},\n",
" {'name': 'french', 'value': None}],\n",
" 'certifications': [],\n",
" 'courses': [],\n",
" 'tasks': [],\n",
" 'tags': [{'name': 'company', 'value': 'Google'}],\n",
" 'metadatas': [{'name': 'metadata example', 'value': 'metadata'}],\n",
" 'ranges_float': [{'name': 'salary',\n",
" 'value_min': 45000,\n",
" 'value_max': 50000,\n",
" 'unit': 'eur'}],\n",
" 'ranges_date': [{'name': 'interview_dates',\n",
" 'value_min': '2023-05-18T21:59',\n",
" 'value_max': '2023-09-15T21:59'}]}}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Edit a job : edit is a Put not a Patch so you need to provide all the fields\n",
"\n",
"# let's get the job by reference\n",
"reference = \"a2n1j000000g0AAAAY\" # <-- Replace with your job reference\n",
"reference = \"my_custom_reference\" # <-- Replace with your job reference\n",
"\n",
"response = client.job.storing.get(board_key=board_key, reference=reference)\n",
"\n",
"job = response['data']\n",
"\n",
"# edit a field or more \n",
"job['culture'] = \"This is a New CULTURE !!!\"\n",
"job['culture'] = \"This is a New CULTURE 123!!\"\n",
"\n",
"# edit the job\n",
"response = client.job.storing.edit(board_key=board_key,\n",
" key=job['key'],\n",
" # key=job['key'], # This is Optional, fand left for backward compatibility\n",
" job_json=job)\n",
"\n",
"response"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'This is a New CULTURE !!'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response[\"data\"][\"culture\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -341,7 +419,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.10.5"
},
"orig_nbformat": 4
},
Expand Down
78 changes: 65 additions & 13 deletions examples/profile/profile_endpoints_examples.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# Make sure you run the latest version of the SDK. You can update it with pip install hrflow --upgrade."
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -10,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -19,10 +28,21 @@
"import json \n",
"from hrflow import Hrflow\n",
"\n",
"# # Get API credentials from environment variables\n",
"api_secret = getpass(\"Enter your API secret: \")\n",
"source_key = getpass(\"Enter your source key: \")\n",
"user_email = getpass(\"Enter your user email: \")"
"# # # Get API credentials from environment variables\n",
"# api_secret = getpass(\"Enter your API secret: \")\n",
"# source_key = getpass(\"Enter your source key: \")\n",
"# user_email = getpass(\"Enter your user email: \")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"api_secret, source_key, user_email = ('ask_a7922c4df9e584fe191daff7c6e002ab',\n",
" '2b4bf676b1a9aee2b7c2b422242c7d7fdb6cc093',\n",
" 'connectors@hrflow.ai')"
]
},
{
Expand All @@ -35,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -104,9 +124,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'code': 400,\n",
" 'message': 'Cannot create profile with this reference: my_custom_reference. Already used!'}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"input_data = {\n",
" \"reference\": \"my_custom_reference\", # <-- Replace with your profile reference you want to set\n",
Expand Down Expand Up @@ -1055,28 +1087,48 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# Edit a profile : edit is a Put not a Patch so you need to provide all the fields\n",
"\n",
"# let's get the profile by reference\n",
"reference = \"ref_1234\" # <-- Replace with your profile reference\n",
"reference = \"my_custom_reference\" # <-- Replace with your profile reference\n",
"\n",
"response = client.profile.storing.get(source_key=source_key, reference=reference)\n",
"\n",
"profile = response['data']\n",
"\n",
"# edit a field or more \n",
"profile['info']['location']['text'] = \"Paris, France\"\n",
"profile['info']['location']['text'] = \"Puteaux, France\"\n",
"\n",
"# edit the profile\n",
"response = client.profile.storing.edit(source_key=source_key,\n",
" key=profile['key'],\n",
" # key=profile['key'], # This is Optional, it's kept for backward compatibility with previous versions of the SDK\n",
" profile_json=profile)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"200"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response[\"code\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -1101,7 +1153,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.10.5"
},
"orig_nbformat": 4
},
Expand Down
2 changes: 1 addition & 1 deletion hrflow/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__title__ = "hrflow"
__description__ = "Python hrflow.ai API package"
__url__ = "https://github.com/hrflow/python-hrflow-api"
__version__ = "3.0.0"
__version__ = "3.1.0"
__author__ = "HrFlow.ai"
__author_email__ = "contact@hrflow.ai"
__license__ = "MIT"
32 changes: 14 additions & 18 deletions hrflow/hrflow/job/storing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,28 @@ def add_json(self, board_key, job_json):
response = self.client.post("job/indexing", json=job_json)
return validate_response(response)

def edit(self, board_key, key=None, job_json=None):
def edit(self, board_key, job_json, key=None):
"""
This method allows to edit a job
in HrFlow.ai.
The job can be edited either through its key (passed as an argument) or its reference
which is a field in the job_json,
at least one of the two values must be provided.
Args:
board_key: <string>
board id
key: <string>
job id
job_json: <string>
job json structure must follows the structure here https://developers.hrflow.ai/hr-json/job-objects/job-object

Returns
Edit the job in the board with the specified identifier

Edit a job already stored in the given source.
This method uses the endpoint : [PUT] https://api.hrflow.ai/v1/job/indexing
It requires :
- source_key : <string> The key of the source where the job is stored
- job_json : <dict> The job data to update
The job object must meet the criteria of the HrFlow.ai job Object
Otherwise the Put request will return an error.
A key or a reference must be provided in the job object `job_json`, to identify the job to update.
The method will update the object already stored by the fields provided in the job_json.
"""

if job_json is None:
job_json = {}

job_json["board_key"] = validate_key("Board", board_key)
# The argument key is kept for backward compatibility with previous versions of the SDK
# It should be removed in the future after a Major release
if key:
job_json["key"] = validate_key("Job", key)
"""Use the api to add a new profile using profile_data."""
response = self.client.put("job/indexing", json=job_json)
return validate_response(response)

Expand Down
20 changes: 17 additions & 3 deletions hrflow/hrflow/profile/storing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,24 @@ def add_json(self, source_key, profile_json):
response = self.client.post("profile/indexing", json=profile_json)
return validate_response(response)

def edit(self, source_key, key, profile_json):
"""Use the api to add a new profile using profile_data."""
def edit(self, source_key, profile_json, key=None):
"""
Edit a profile already stored in the given source.
This method uses the endpoint : [PUT] https://api.hrflow.ai/v1/profile/indexing
It requires :
- source_key : <string> The key of the source where the profile is stored
- profile_json : <dict> The profile data to update
The profile object must meet the criteria of the HrFlow.ai Profile Object
Otherwise the Put request will return an error.
A key or a reference must be provided in the profile object `profile_json`, to identify the profile to update.
The method will update the object already stored by the fields provided in the profile_json.
"""
profile_json["source_key"] = validate_key("Source", source_key)
profile_json["key"] = validate_key("Profile", key)
# The argument key is kept for backward compatibility with previous versions of the SDK
# It should be removed in the future after a Major release
if key:
profile_json["key"] = validate_key("Profile", key)

response = self.client.put("profile/indexing", json=profile_json)
return validate_response(response)

Expand Down