1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: Matt |
5
|
|
|
* Date: 20/04/2016 |
6
|
|
|
* Time: 2:32 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Freshdesk\Resources; |
10
|
|
|
|
11
|
|
|
use Freshdesk\Resources\Traits\DeleteTrait; |
12
|
|
|
use Freshdesk\Resources\Traits\UpdateTrait; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Conversation resource |
16
|
|
|
* |
17
|
|
|
* This provides access to the agent resources |
18
|
|
|
* |
19
|
|
|
* @package Api\Resources |
20
|
|
|
*/ |
21
|
|
|
class Conversation extends AbstractResource |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
use UpdateTrait, DeleteTrait; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The resource endpoint |
28
|
|
|
* @internal |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $endpoint = '/conversations'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The ticket resource endpoint |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
* @internal |
38
|
|
|
*/ |
39
|
|
|
private $ticketsEndpoint = '/tickets'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Creates the ticket endpoint |
43
|
|
|
* @param string $id |
44
|
|
|
* @return string |
45
|
|
|
* @internal |
46
|
|
|
*/ |
47
|
|
|
protected function ticketsEndpoint($id = null) |
48
|
|
|
{ |
49
|
|
|
return $id === null ? $this->ticketsEndpoint : $this->ticketsEndpoint . '/' . $id; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* |
54
|
|
|
* Reply to a ticket |
55
|
|
|
* |
56
|
|
|
* @api |
57
|
|
|
* @param int $id |
58
|
|
|
* @param array $data |
59
|
|
|
* @return array|null |
60
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
61
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
62
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
63
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
64
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
65
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
66
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
67
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
68
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
69
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
70
|
|
|
*/ |
71
|
|
|
public function reply($id, array $data) |
72
|
|
|
{ |
73
|
|
|
return $this->api()->request('POST', $this->ticketsEndpoint($id . '/reply'), $data); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* |
78
|
|
|
* Create a note for a ticket |
79
|
|
|
* |
80
|
|
|
* @api |
81
|
|
|
* @param int $id |
82
|
|
|
* @param array $data |
83
|
|
|
* @return array|null |
84
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
85
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
86
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
87
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
88
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
89
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
90
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
91
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
92
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
93
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
94
|
|
|
*/ |
95
|
|
|
public function note($id, array $data) |
96
|
|
|
{ |
97
|
|
|
return $this->api()->request('POST', $this->ticketsEndpoint($id . '/note'), $data); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
} |