|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace seregazhuk\HeadHunterApi\EndPoints; |
|
4
|
|
|
|
|
5
|
|
|
use seregazhuk\HeadHunterApi\Traits\HasView; |
|
6
|
|
|
|
|
7
|
|
|
class Comments extends Endpoint |
|
8
|
|
|
{ |
|
9
|
|
|
use HasView; |
|
10
|
|
|
|
|
11
|
|
|
const RESOURCE = 'applicant_comments'; |
|
12
|
|
|
|
|
13
|
|
|
const COMMENT_TYPE_PUBLIC = 'coworkers'; |
|
14
|
|
|
const COMMENT_TYPE_PRIVATE = 'owner'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param string $applicantId |
|
18
|
|
|
* @param string $text |
|
19
|
|
|
* @param string $type |
|
20
|
|
|
* @return mixed |
|
21
|
|
|
*/ |
|
22
|
|
|
public function create($applicantId, $text, $type = self::COMMENT_TYPE_PUBLIC) |
|
23
|
|
|
{ |
|
24
|
|
|
return $this->postResource($applicantId, ['text' => $text, 'access_type' => $type]); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param string $applicantId |
|
29
|
|
|
* @param string $text |
|
30
|
|
|
* @return mixed |
|
31
|
|
|
*/ |
|
32
|
|
|
public function createPrivate($applicantId, $text) |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->create($applicantId, $text, self::COMMENT_TYPE_PRIVATE); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param string $applicantId |
|
39
|
|
|
* @param string $commentId |
|
40
|
|
|
* @param string $text |
|
41
|
|
|
* @param string $type |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
public function edit($applicantId, $commentId, $text, $type = self::COMMENT_TYPE_PUBLIC) |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->putResource( |
|
47
|
|
|
"$applicantId/$commentId", |
|
48
|
|
|
['text' => $text, 'access_type' => $type] |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param string $applicantId |
|
54
|
|
|
* @param string $commentId |
|
55
|
|
|
* @param string $text |
|
56
|
|
|
* @return mixed |
|
57
|
|
|
*/ |
|
58
|
|
|
public function editPrivate($applicantId, $commentId, $text) |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->edit($applicantId, $commentId, $text, self::COMMENT_TYPE_PRIVATE); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $applicantId |
|
65
|
|
|
* @param string $commentId |
|
66
|
|
|
*/ |
|
67
|
|
|
public function delete($applicantId, $commentId) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->deleteResource("$applicantId/$commentId"); |
|
70
|
|
|
} |
|
71
|
|
|
} |