Completed
Push — master ( 457d5c...f99e05 )
by Sergey
05:31 queued 02:43
created

Vacancies::restore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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()
17
    {
18
        return $this->getResource('blacklisted');
19
    }
20
21
    public function favorited()
22
    {
23
        return $this->getResource('favorited');
24
    }
25
26
    /**
27
     * @param string $id
28
     * @return mixed
29
     */
30
    public function similar($id)
31
    {
32
        return $this->getSimilarVacanciesFor($id);
33
    }
34
35
    /**
36
     * @param string $id
37
     * @return mixed
38
     */
39
    public function statistics($id)
40
    {
41
        return $this->getResource($id . '/stats');
42
    }
43
44
    /**
45
     * @param string|null $managerId
46
     * @return array|null
47
     */
48
    public function active($managerId = null)
49
    {
50
        $managerId = $managerId ?: $this->getCurrentManagerId();
51
52
        return $this->callEmployersVacanciesEndpoint("active", ['manager' => $managerId]);
53
    }
54
55
    public function archived()
56
    {
57
        return $this->callEmployersVacanciesEndpoint("archived");
58
    }
59
60
    public function hidden()
61
    {
62
        return $this->callEmployersVacanciesEndpoint("hidden");
63
    }
64
65
    /**
66
     * @param string $endpoint
67
     * @param array $params
68
     * @return array|null
69
     */
70
    protected function callEmployersVacanciesEndpoint($endpoint, $params = [])
71
    {
72
        $employerId = $this->getCurrentEmployerId();
73
74
        return $this->request->get("/employers/$employerId/vacancies/$endpoint", $params);
75
    }
76
77
    /**
78
     * @param string $id
79
     * @return array|null
80
     */
81
    public function hide($id)
82
    {
83
        $employerId = $this->getCurrentEmployerId();
84
85
        return $this->request->put("/employers/$employerId/vacancies/hidden/$id");
86
    }
87
88
    /**
89
     * @param string $id
90
     * @return array|null
91
     */
92
    public function restore($id)
93
    {
94
        $employerId = $this->getCurrentEmployerId();
95
96
        return $this->request->delete("/employers/$employerId/vacancies/hidden/$id");
97
    }
98
}