1
|
|
|
<?php |
2
|
|
|
namespace Freshdesk\Resources; |
3
|
|
|
|
4
|
|
|
use Freshdesk\Resources\Traits\AllTrait; |
5
|
|
|
use Freshdesk\Resources\Traits\CreateTrait; |
6
|
|
|
use Freshdesk\Resources\Traits\DeleteTrait; |
7
|
|
|
use Freshdesk\Resources\Traits\UpdateTrait; |
8
|
|
|
use Freshdesk\Resources\Traits\ViewTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Ticket resource |
12
|
|
|
* |
13
|
|
|
* Provides access to ticket resources |
14
|
|
|
* |
15
|
|
|
* @package Api\Resources |
16
|
|
|
*/ |
17
|
|
|
class Ticket extends AbstractResource |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
use AllTrait, CreateTrait, ViewTrait, UpdateTrait, DeleteTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The resource endpoint |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $endpoint = '/tickets'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Restore a ticket |
31
|
|
|
* |
32
|
|
|
* Restores a previously deleted ticket |
33
|
|
|
* |
34
|
|
|
* @api |
35
|
|
|
* @param $id |
36
|
|
|
* @return mixed|null |
37
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
38
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
39
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
40
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
41
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
42
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
43
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
44
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
45
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
46
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
47
|
|
|
*/ |
48
|
|
|
public function restore($id) |
49
|
|
|
{ |
50
|
|
|
$end = $id . '/restore'; |
51
|
|
|
|
52
|
|
|
return $this->api()->request('PUT', $this->endpoint($end)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* List ticket fields |
57
|
|
|
* |
58
|
|
|
* The agent whose credentials (API key or username/password) are being used to make this API call should be |
59
|
|
|
* authorised to view the ticket fields |
60
|
|
|
* |
61
|
|
|
* @param array|null $query |
62
|
|
|
* @return mixed|null |
63
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
64
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
65
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
66
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
67
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
68
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
69
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
70
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
71
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
72
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
73
|
|
|
*/ |
74
|
|
|
public function fields(array $query = null) |
75
|
|
|
{ |
76
|
|
|
return $this->api()->request('GET', '/ticket_fields', null, $query); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* List conversations associated with a ticket |
81
|
|
|
* |
82
|
|
|
* @param int $id The ticket id |
83
|
|
|
* @param array|null $query |
84
|
|
|
* @return mixed|null |
85
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
86
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
87
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
88
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
89
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
90
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
91
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
92
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
93
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
94
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
95
|
|
|
*/ |
96
|
|
|
public function conversations($id, array $query = null) |
97
|
|
|
{ |
98
|
|
|
$end = $id . '/conversations'; |
99
|
|
|
|
100
|
|
|
return $this->api()->request('GET', $this->endpoint($end), null, $query); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* List time entries associated with a ticket |
105
|
|
|
* |
106
|
|
|
* @param int $id The ticket id |
107
|
|
|
* @param array|null $query |
108
|
|
|
* @return mixed|null |
109
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
110
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
111
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
112
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
113
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
114
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
115
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
116
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
117
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
118
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
119
|
|
|
*/ |
120
|
|
|
public function timeEntries($id, array $query = null) |
121
|
|
|
{ |
122
|
|
|
$end = $id . '/time_entries'; |
123
|
|
|
|
124
|
|
|
return $this->api()->request('GET', $this->endpoint($end), null, $query); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Filters by ticket fields |
129
|
|
|
* |
130
|
|
|
* Make sure to pass a valid $filtersQuery string example: "type:question" |
131
|
|
|
* |
132
|
|
|
* @api |
133
|
|
|
* @param string $filtersQuery |
134
|
|
|
* @return array|null |
135
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
136
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
137
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
138
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
139
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
140
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
141
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
142
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
143
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
144
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
145
|
|
|
*/ |
146
|
|
|
public function search(string $filtersQuery) |
147
|
|
|
{ |
148
|
|
|
$end = '/search'.$this->endpoint(); |
149
|
|
|
$query = [ |
150
|
|
|
'query' => '"'.$filtersQuery.'"', |
151
|
|
|
]; |
152
|
|
|
return $this->api()->request('GET', $end, null, $query); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param array $data |
158
|
|
|
* @return mixed|null |
159
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
160
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
161
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
162
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
163
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
164
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
165
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
166
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
167
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
168
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
169
|
|
|
*/ |
170
|
|
|
public function createOutboundEmail($data = []) { |
171
|
|
|
return $this->api()->request('POST', $this->endpoint('outbound_email'), $data); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|