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\AllTrait; |
12
|
|
|
use Freshdesk\Resources\Traits\CreateTrait; |
13
|
|
|
use Freshdesk\Resources\Traits\DeleteTrait; |
14
|
|
|
use Freshdesk\Resources\Traits\FilterTrait; |
15
|
|
|
use Freshdesk\Resources\Traits\UpdateTrait; |
16
|
|
|
use Freshdesk\Resources\Traits\ViewTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Ticket resource |
20
|
|
|
* |
21
|
|
|
* Provides access to ticket resources |
22
|
|
|
* |
23
|
|
|
* @package Api\Resources |
24
|
|
|
*/ |
25
|
|
|
class Ticket extends AbstractResource |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
use AllTrait, CreateTrait, ViewTrait, UpdateTrait, DeleteTrait, FilterTrait; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The resource endpoint |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $endpoint = '/tickets'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Restore a ticket |
39
|
|
|
* |
40
|
|
|
* Restores a previously deleted ticket |
41
|
|
|
* |
42
|
|
|
* @api |
43
|
|
|
* @param $id |
44
|
|
|
* @return mixed|null |
45
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
46
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
47
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
48
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
49
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
50
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
51
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
52
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
53
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
54
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
55
|
|
|
*/ |
56
|
|
|
public function restore($id) |
57
|
|
|
{ |
58
|
|
|
$end = $id . '/restore'; |
59
|
|
|
|
60
|
|
|
return $this->api()->request('PUT', $this->endpoint($end)); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* List ticket fields |
65
|
|
|
* |
66
|
|
|
* The agent whose credentials (API key or username/password) are being used to make this API call should be |
67
|
|
|
* authorised to view the ticket fields |
68
|
|
|
* |
69
|
|
|
* @param array|null $query |
70
|
|
|
* @return mixed|null |
71
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
72
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
73
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
74
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
75
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
76
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
77
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
78
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
79
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
80
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
81
|
|
|
*/ |
82
|
|
|
public function fields(array $query = null) |
83
|
|
|
{ |
84
|
|
|
return $this->api()->request('GET', '/ticket_fields', null, $query); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* List conversations associated with a ticket |
89
|
|
|
* |
90
|
|
|
* @param int $id The ticket id |
91
|
|
|
* @param array|null $query |
92
|
|
|
* @return mixed|null |
93
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
94
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
95
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
96
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
97
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
98
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
99
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
100
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
101
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
102
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
103
|
|
|
*/ |
104
|
|
|
public function conversations($id, array $query = null) |
105
|
|
|
{ |
106
|
|
|
$end = $id . '/conversations'; |
107
|
|
|
|
108
|
|
|
return $this->api()->request('GET', $this->endpoint($end), null, $query); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* List time entries associated with a ticket |
113
|
|
|
* |
114
|
|
|
* @param int $id The ticket id |
115
|
|
|
* @param array|null $query |
116
|
|
|
* @return mixed|null |
117
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
118
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
119
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
120
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
121
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
122
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
123
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
124
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
125
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
126
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
127
|
|
|
*/ |
128
|
|
|
public function timeEntries($id, array $query = null) |
129
|
|
|
{ |
130
|
|
|
$end = $id . '/time_entries'; |
131
|
|
|
|
132
|
|
|
return $this->api()->request('GET', $this->endpoint($end), null, $query); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|