|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace seregazhuk\HeadHunterApi\EndPoints; |
|
4
|
|
|
|
|
5
|
|
|
use seregazhuk\HeadHunterApi\Traits\HasView; |
|
6
|
|
|
use seregazhuk\HeadHunterApi\Traits\ResolvesCurrentUser; |
|
7
|
|
|
use seregazhuk\HeadHunterApi\Traits\Searchable; |
|
8
|
|
|
use seregazhuk\HeadHunterApi\Traits\HasSimilarVacancies; |
|
9
|
|
|
|
|
10
|
|
|
class Vacancies extends Endpoint |
|
11
|
|
|
{ |
|
12
|
|
|
const RESOURCE = 'vacancies'; |
|
13
|
|
|
|
|
14
|
|
|
use HasView, Searchable, HasSimilarVacancies, ResolvesCurrentUser; |
|
15
|
|
|
|
|
16
|
|
|
public function blacklisted(array $pagination = []) |
|
17
|
|
|
{ |
|
18
|
|
|
return $this->getResource('blacklisted', $pagination); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param array $pagination |
|
23
|
|
|
* @return mixed |
|
24
|
|
|
*/ |
|
25
|
|
|
public function favorited(array $pagination = []) |
|
26
|
|
|
{ |
|
27
|
|
|
return $this->getResource('favorited', $pagination); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param string $id |
|
32
|
|
|
* @param array $pagination |
|
33
|
|
|
* @return mixed |
|
34
|
|
|
*/ |
|
35
|
|
|
public function similar($id, array $pagination = []) |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->getSimilarVacanciesFor($id, $pagination); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param string $id |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
public function statistics($id) |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->getResource($id . '/stats'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string|null $managerId |
|
51
|
|
|
* @param array $pagination |
|
52
|
|
|
* @return array|null |
|
53
|
|
|
*/ |
|
54
|
|
|
public function active($managerId = null, array $pagination = []) |
|
55
|
|
|
{ |
|
56
|
|
|
$managerId = $managerId ?: $this->getCurrentManagerId(); |
|
57
|
|
|
|
|
58
|
|
|
$params = array_merge( |
|
59
|
|
|
$pagination, |
|
60
|
|
|
['manager_id' => $managerId] |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
return $this->callEmployersVacanciesEndpoint("active", $params); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param array $pagination |
|
68
|
|
|
* @return array|null |
|
69
|
|
|
*/ |
|
70
|
|
|
public function archived(array $pagination = []) |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->callEmployersVacanciesEndpoint("archived", $pagination); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param array $pagination |
|
77
|
|
|
* @return array|null |
|
78
|
|
|
*/ |
|
79
|
|
|
public function hidden(array $pagination = []) |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->callEmployersVacanciesEndpoint("hidden", $pagination); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param string $endpoint |
|
86
|
|
|
* @param array $pagination |
|
87
|
|
|
* @return array|null |
|
88
|
|
|
*/ |
|
89
|
|
|
protected function callEmployersVacanciesEndpoint($endpoint, $pagination = []) |
|
90
|
|
|
{ |
|
91
|
|
|
$employerId = $this->getCurrentEmployerId(); |
|
92
|
|
|
|
|
93
|
|
|
return $this->request->get("/employers/$employerId/vacancies/$endpoint", $pagination); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param string $id |
|
98
|
|
|
* @return array|null |
|
99
|
|
|
*/ |
|
100
|
|
|
public function hide($id) |
|
101
|
|
|
{ |
|
102
|
|
|
$employerId = $this->getCurrentEmployerId(); |
|
103
|
|
|
|
|
104
|
|
|
return $this->request->put("/employers/$employerId/vacancies/hidden/$id"); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param string $id |
|
109
|
|
|
* @return array|null |
|
110
|
|
|
*/ |
|
111
|
|
|
public function restore($id) |
|
112
|
|
|
{ |
|
113
|
|
|
$employerId = $this->getCurrentEmployerId(); |
|
114
|
|
|
|
|
115
|
|
|
return $this->request->delete("/employers/$employerId/vacancies/hidden/$id"); |
|
116
|
|
|
} |
|
117
|
|
|
} |