-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecruiter.php
More file actions
103 lines (97 loc) · 3.14 KB
/
Recruiter.php
File metadata and controls
103 lines (97 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
class Recruiter {
public function __construct(&$session)
{
$this->session = &$session;
$this->config = new Config($this->session);
}
public function getAllJobAds($accessToken)
{
$url = $this->config->getTalentecaBaseUrl() . "/api/v1/recruiter/job-ad/list";
$data = [
'access_token' => $accessToken
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
$status_code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status_code == 200)
{
$json = json_decode($response);
if ($json->status == "ok")
{
$activeJobAds = $json->active_job_ads;
$inactiveJobAds = $json->inactive_job_ads;
return [
'activeJobAds' => $activeJobAds,
'inactiveJobAds' => $inactiveJobAds
];
}
}
$this->session['error_message'] = "Unable to get job ads";
$this->session['error_detail'] = $response;
return null;
}
public function createJobAdInProgress($accessToken, $jobAd)
{
$url = $this->config->getTalentecaBaseUrl() . "/api/v1/recruiter/job-ad/create-in-progress";
$data = [
'access_token' => $accessToken,
'job_ad' => $jobAd
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
$status_code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status_code == 200)
{
$json = json_decode($response);
if ($json->status == "ok")
{
$job_ad_id = $json->job_ad_id;
return $job_ad_id;
}
}
$this->session['error_message'] = "Unable to create job ad in progress";
$this->session['error_detail'] = $response;
return null;
}
public function activateJobAd($accessToken, $jobAdId)
{
$url = $this->config->getTalentecaBaseUrl() . "/api/v1/recruiter/job-ad/activate";
$data = [
'access_token' => $accessToken,
'job_ad_id' => $jobAdId
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
$status_code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status_code == 200)
{
$json = json_decode($response);
if ($json->status == "ok")
{
return "ok";
}
}
$this->session['error_message'] = "Unable to activate job ad";
$this->session['error_detail'] = $response;
return null;
}
}