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