Skip to content

Commit 0fd47ab

Browse files
committed
📝 SDK Notebook examples
1 parent 2063bc4 commit 0fd47ab

2 files changed

Lines changed: 1460 additions & 0 deletions

File tree

Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"# Setup the config and authentication"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 2,
14+
"metadata": {},
15+
"outputs": [],
16+
"source": [
17+
"from getpass import getpass\n",
18+
"import os\n",
19+
"import json \n",
20+
"from hrflow import Hrflow\n",
21+
"\n",
22+
"# # Get API credentials from environment variables\n",
23+
"api_secret = getpass(\"Enter your API secret: \")\n",
24+
"board_key = getpass(\"Enter your board key: \")\n",
25+
"user_email = getpass(\"Enter your user email: \")"
26+
]
27+
},
28+
{
29+
"attachments": {},
30+
"cell_type": "markdown",
31+
"metadata": {},
32+
"source": [
33+
"# Setup HrFlow.ai Client "
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": 3,
39+
"metadata": {},
40+
"outputs": [],
41+
"source": [
42+
"client = Hrflow(api_secret=api_secret, api_user=user_email)"
43+
]
44+
},
45+
{
46+
"attachments": {},
47+
"cell_type": "markdown",
48+
"metadata": {},
49+
"source": [
50+
"# 1 - Read a Job in a Board in HrFlow.ai "
51+
]
52+
},
53+
{
54+
"attachments": {},
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"### a - Using external ID set : `reference` in HrFlow.ai"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"reference = \"a2n1j000000g0AAAAY\" # <-- Replace with your job reference\n",
68+
"\n",
69+
"# Get job by reference\n",
70+
"response = client.job.storing.get(board_key=board_key, reference=reference)\n",
71+
"\n",
72+
"response"
73+
]
74+
},
75+
{
76+
"attachments": {},
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"### b - Using profile key (internal set by HrFlow.ai) : `key` in HrFlow.ai"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": null,
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"key = \"FILL THIS\" # <-- Replace with your job key\n",
90+
"\n",
91+
"# Get job by reference\n",
92+
"response = client.job.storing.get(board_key=board_key, key=key)\n",
93+
"\n",
94+
"response"
95+
]
96+
},
97+
{
98+
"attachments": {},
99+
"cell_type": "markdown",
100+
"metadata": {},
101+
"source": [
102+
"# 2 - Write a job in a board from a Structured data "
103+
]
104+
},
105+
{
106+
"cell_type": "code",
107+
"execution_count": 8,
108+
"metadata": {},
109+
"outputs": [
110+
{
111+
"data": {
112+
"text/plain": [
113+
"{'code': 201,\n",
114+
" 'message': 'Job created',\n",
115+
" 'data': {'id': 1245507,\n",
116+
" 'key': '4f2e11266a11e728e794dc5f0867462fa60321ba',\n",
117+
" 'reference': 'my_custom_reference',\n",
118+
" 'board_key': '7fce016712fa373456ef279c297da5009a2020d9',\n",
119+
" 'board': {'key': '7fce016712fa373456ef279c297da5009a2020d9',\n",
120+
" 'name': 'vulcain_test',\n",
121+
" 'type': 'api',\n",
122+
" 'subtype': 'python',\n",
123+
" 'environment': 'production'},\n",
124+
" 'name': 'Data Engineer',\n",
125+
" 'url': 'https://www.pole-emploi.ai/jobs/data_engineer',\n",
126+
" 'picture': None,\n",
127+
" '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",
128+
" 'location': {'text': 'Dampierre en Burly (45)',\n",
129+
" 'lat': None,\n",
130+
" 'lng': None,\n",
131+
" 'gmaps': None,\n",
132+
" 'fields': None},\n",
133+
" 'archive': None,\n",
134+
" 'archived_at': None,\n",
135+
" 'updated_at': '2023-06-20T15:50:32+0000',\n",
136+
" 'created_at': '2023-06-20T15:50:32+0000',\n",
137+
" 'sections': [{'name': 'section 1',\n",
138+
" 'title': 'title section 1',\n",
139+
" 'description': 'text section 1'}],\n",
140+
" 'culture': 'FILL THIS WITH A TEXT ABOUT YOUR COMPANY CULTURE',\n",
141+
" 'responsibilities': 'FILL THIS WITH A TEXT ABOUT THE RESPONSIBILITIES OF THE JOB',\n",
142+
" 'requirements': 'FILL THIS WITH A TEXT ABOUT THE REQUIREMENTS OF THE JOB',\n",
143+
" 'benefits': 'FILL THIS WITH A TEXT ABOUT THE BENEFITS OF THE JOB',\n",
144+
" 'interviews': 'FILL THIS WITH A TEXT ABOUT THE INTERVIEWS OF THE JOB',\n",
145+
" 'skills': [{'name': 'python', 'value': None, 'type': 'hard'},\n",
146+
" {'name': 'spark', 'value': 0.9, 'type': 'hard'}],\n",
147+
" 'languages': [{'name': 'english', 'value': None},\n",
148+
" {'name': 'french', 'value': None}],\n",
149+
" 'certifications': None,\n",
150+
" 'courses': None,\n",
151+
" 'tasks': None,\n",
152+
" 'tags': [{'name': 'company', 'value': 'Google'}],\n",
153+
" 'metadatas': [{'name': 'metadata example', 'value': 'metadata'}],\n",
154+
" 'ranges_float': [{'name': 'salary',\n",
155+
" 'value_min': 45000,\n",
156+
" 'value_max': 50000,\n",
157+
" 'unit': 'eur'}],\n",
158+
" 'ranges_date': [{'name': 'interview_dates',\n",
159+
" 'value_min': '2023-05-18T21:59',\n",
160+
" 'value_max': '2023-09-15T21:59'}]}}"
161+
]
162+
},
163+
"execution_count": 8,
164+
"metadata": {},
165+
"output_type": "execute_result"
166+
}
167+
],
168+
"source": [
169+
"input_data = {\n",
170+
" \"name\": \"Data Engineer\",\n",
171+
" \"reference\": \"my_custom_reference\", # <-- Replace with your job reference\n",
172+
" \"url\": \"https://www.pole-emploi.ai/jobs/data_engineer\",\n",
173+
" \"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",
174+
" \"location\": {\n",
175+
" \"text\": \"Dampierre en Burly (45)\",\n",
176+
" \"geopoint\": {\n",
177+
" \"lat\": 47.7667,\n",
178+
" \"lon\": 2.5167\n",
179+
" }\n",
180+
" },\n",
181+
" \"culture\": \"FILL THIS WITH A TEXT ABOUT YOUR COMPANY CULTURE\",\n",
182+
" \"responsibilities\": \"FILL THIS WITH A TEXT ABOUT THE RESPONSIBILITIES OF THE JOB\",\n",
183+
" \"requirements\": \"FILL THIS WITH A TEXT ABOUT THE REQUIREMENTS OF THE JOB\",\n",
184+
" \"benefits\": \"FILL THIS WITH A TEXT ABOUT THE BENEFITS OF THE JOB\",\n",
185+
" \"interviews\": \"FILL THIS WITH A TEXT ABOUT THE INTERVIEWS OF THE JOB\",\n",
186+
" \"sections\": [{ # <-- Sections are mandatory, leave as empty list if no section is provided\n",
187+
" \"name\": \"section 1\",\n",
188+
" \"title\": \"title section 1\",\n",
189+
" \"description\": \"text section 1\"\n",
190+
" }\n",
191+
" ],\n",
192+
" \"skills\": [{\n",
193+
" \"name\": \"python\",\n",
194+
" \"value\": None, # <-- Leave None if no assessment to skills is provided\n",
195+
" \"type\": \"hard\"\n",
196+
" },\n",
197+
" {\n",
198+
" \"name\": \"spark\",\n",
199+
" \"value\": 0.9,\n",
200+
" \"type\": \"hard\"\n",
201+
" }\n",
202+
" ],\n",
203+
" \"languages\": [{\n",
204+
" \"name\": \"english\",\n",
205+
" \"value\": None\n",
206+
" },\n",
207+
" { \n",
208+
" \"name\": \"french\",\n",
209+
" \"value\": None\n",
210+
" }\n",
211+
" ],\n",
212+
" \"tags\": [{\n",
213+
" \"name\": \"company\", # <-- Other custom fields can be added as tags\n",
214+
" \"value\": \"Google\"\n",
215+
" }\n",
216+
" ],\n",
217+
" \"ranges_date\": [{\n",
218+
" \"name\": \"interview_dates\",\n",
219+
" \"value_min\": \"2023-05-18T21:59\",\n",
220+
" \"value_max\": \"2023-09-15T21:59\"\n",
221+
" }\n",
222+
" ],\n",
223+
" \"ranges_float\": [{\n",
224+
" \"name\": \"salary\",\n",
225+
" \"value_min\": 45000,\n",
226+
" \"value_max\": 50000,\n",
227+
" \"unit\": \"eur\"\n",
228+
" }\n",
229+
" ],\n",
230+
" \"metadatas\": [{\n",
231+
" \"name\": \"metadata example\",\n",
232+
" \"value\": \"metadata\"\n",
233+
" }\n",
234+
" ]\n",
235+
" }\n",
236+
"\n",
237+
"response = client.job.storing.add_json(board_key=board_key, job_json=input_data)\n",
238+
"\n",
239+
"response"
240+
]
241+
},
242+
{
243+
"attachments": {},
244+
"cell_type": "markdown",
245+
"metadata": {},
246+
"source": [
247+
"# 3 - Archive a Job already in a Board "
248+
]
249+
},
250+
{
251+
"attachments": {},
252+
"cell_type": "markdown",
253+
"metadata": {},
254+
"source": [
255+
"### a - Archive a Job from a Board"
256+
]
257+
},
258+
{
259+
"cell_type": "code",
260+
"execution_count": 9,
261+
"metadata": {},
262+
"outputs": [
263+
{
264+
"data": {
265+
"text/plain": [
266+
"{'code': 200,\n",
267+
" 'message': 'Job archived',\n",
268+
" 'data': {'key': '4f2e11266a11e728e794dc5f0867462fa60321ba'}}"
269+
]
270+
},
271+
"execution_count": 9,
272+
"metadata": {},
273+
"output_type": "execute_result"
274+
}
275+
],
276+
"source": [
277+
"# Let's archive the job with reference \"my_custom_reference\"\n",
278+
"reference = \"my_custom_reference\" # <-- Replace with your job reference\n",
279+
"\n",
280+
"response = client.job.storing.archive(board_key=board_key,\n",
281+
" reference=reference)\n",
282+
"\n",
283+
"response"
284+
]
285+
},
286+
{
287+
"attachments": {},
288+
"cell_type": "markdown",
289+
"metadata": {},
290+
"source": [
291+
"# 5 - Edit a Job already in a Board "
292+
]
293+
},
294+
{
295+
"cell_type": "code",
296+
"execution_count": null,
297+
"metadata": {},
298+
"outputs": [],
299+
"source": [
300+
"# Edit a job : edit is a Put not a Patch so you need to provide all the fields\n",
301+
"\n",
302+
"# let's get the job by reference\n",
303+
"reference = \"a2n1j000000g0AAAAY\" # <-- Replace with your job reference\n",
304+
"\n",
305+
"response = client.job.storing.get(board_key=board_key, reference=reference)\n",
306+
"\n",
307+
"job = response['data']\n",
308+
"\n",
309+
"# edit a field or more \n",
310+
"job['culture'] = \"This is a New CULTURE !!!\"\n",
311+
"\n",
312+
"# edit the job\n",
313+
"response = client.job.storing.edit(board_key=board_key,\n",
314+
" key=job['key'],\n",
315+
" job_json=job)\n",
316+
"\n",
317+
"response"
318+
]
319+
},
320+
{
321+
"cell_type": "code",
322+
"execution_count": null,
323+
"metadata": {},
324+
"outputs": [],
325+
"source": []
326+
}
327+
],
328+
"metadata": {
329+
"kernelspec": {
330+
"display_name": "python-hrflow-api-S_mz3ndj-py3.8",
331+
"language": "python",
332+
"name": "python3"
333+
},
334+
"language_info": {
335+
"codemirror_mode": {
336+
"name": "ipython",
337+
"version": 3
338+
},
339+
"file_extension": ".py",
340+
"mimetype": "text/x-python",
341+
"name": "python",
342+
"nbconvert_exporter": "python",
343+
"pygments_lexer": "ipython3",
344+
"version": "3.8.6"
345+
},
346+
"orig_nbformat": 4
347+
},
348+
"nbformat": 4,
349+
"nbformat_minor": 2
350+
}

0 commit comments

Comments
 (0)