1 | <?php |
||
44 | class Api |
||
45 | { |
||
46 | /** |
||
47 | * Agent resources |
||
48 | * |
||
49 | * @api |
||
50 | * @var Agent |
||
51 | */ |
||
52 | public $agents; |
||
53 | |||
54 | /** |
||
55 | * Company resources |
||
56 | * |
||
57 | * @api |
||
58 | * @var Company |
||
59 | */ |
||
60 | public $companies; |
||
61 | |||
62 | /** |
||
63 | * Contact resources |
||
64 | * |
||
65 | * @api |
||
66 | * @var Contact |
||
67 | */ |
||
68 | public $contacts; |
||
69 | |||
70 | /** |
||
71 | * Group resources |
||
72 | * |
||
73 | * @api |
||
74 | * @var Group |
||
75 | */ |
||
76 | public $groups; |
||
77 | |||
78 | /** |
||
79 | * Ticket resources |
||
80 | * |
||
81 | * @api |
||
82 | * @var Ticket |
||
83 | */ |
||
84 | public $tickets; |
||
85 | |||
86 | /** |
||
87 | * TimeEntry resources |
||
88 | * |
||
89 | * @api |
||
90 | * @var TimeEntry |
||
91 | */ |
||
92 | public $timeEntries; |
||
93 | |||
94 | /** |
||
95 | * Conversation resources |
||
96 | * |
||
97 | * @api |
||
98 | * @var Conversation |
||
99 | */ |
||
100 | public $conversations; |
||
101 | |||
102 | /** |
||
103 | * Category resources |
||
104 | * |
||
105 | * @api |
||
106 | * @var Category |
||
107 | */ |
||
108 | public $categories; |
||
109 | |||
110 | /** |
||
111 | * Forum resources |
||
112 | * |
||
113 | * @api |
||
114 | * @var Forum |
||
115 | */ |
||
116 | public $forums; |
||
117 | |||
118 | /** |
||
119 | * Topic resources |
||
120 | * |
||
121 | * @api |
||
122 | * @var Topic |
||
123 | */ |
||
124 | public $topics; |
||
125 | |||
126 | /** |
||
127 | * Comment resources |
||
128 | * |
||
129 | * @api |
||
130 | * @var Comment |
||
131 | */ |
||
132 | public $comments; |
||
133 | |||
134 | //Admin |
||
135 | |||
136 | /** |
||
137 | * Email Config resources |
||
138 | * |
||
139 | * @api |
||
140 | * @var EmailConfig |
||
141 | */ |
||
142 | public $emailConfigs; |
||
143 | |||
144 | /** |
||
145 | * Access Product resources |
||
146 | * |
||
147 | * @api |
||
148 | * @var Product |
||
149 | */ |
||
150 | public $products; |
||
151 | |||
152 | /** |
||
153 | * Business Hours resources |
||
154 | * |
||
155 | * @api |
||
156 | * @var BusinessHour |
||
157 | */ |
||
158 | public $businessHours; |
||
159 | |||
160 | /** |
||
161 | * SLA Policy resources |
||
162 | * |
||
163 | * @api |
||
164 | * @var SLAPolicy |
||
165 | */ |
||
166 | public $slaPolicies; |
||
167 | |||
168 | /** |
||
169 | * @internal |
||
170 | * @var Client |
||
171 | */ |
||
172 | protected $client; |
||
173 | |||
174 | /** |
||
175 | * @internal |
||
176 | * @var string |
||
177 | */ |
||
178 | private $baseUrl; |
||
179 | |||
180 | /** |
||
181 | * Constructs a new api instance |
||
182 | * |
||
183 | * @api |
||
184 | * @param string $apiKey |
||
185 | * @param string $domain |
||
186 | * @throws Exceptions\InvalidConfigurationException |
||
187 | */ |
||
188 | public function __construct($apiKey, $domain) |
||
201 | |||
202 | |||
203 | /** |
||
204 | * Internal method for handling requests |
||
205 | * |
||
206 | * @internal |
||
207 | * @param $method |
||
208 | * @param $endpoint |
||
209 | * @param array|null $data |
||
210 | * @param array|null $query |
||
211 | * @return mixed|null |
||
212 | * @throws ApiException |
||
213 | * @throws ConflictingStateException |
||
214 | * @throws RateLimitExceededException |
||
215 | * @throws UnsupportedContentTypeException |
||
216 | */ |
||
217 | public function request($method, $endpoint, array $data = null, array $query = null) |
||
234 | |||
235 | /** |
||
236 | * Checks for attachments in the $data payload |
||
237 | * |
||
238 | * @internal |
||
239 | * |
||
240 | * @param $data |
||
241 | */ |
||
242 | private function hasAttachments($data) |
||
246 | |||
247 | |||
248 | /** |
||
249 | * Formats the data into a Guzzle Mulitpart request format |
||
250 | * |
||
251 | * @internal |
||
252 | * |
||
253 | * @param $data |
||
254 | */ |
||
255 | private function formatDataForMultipart($data) |
||
277 | |||
278 | /** |
||
279 | * Performs the request |
||
280 | * |
||
281 | * @internal |
||
282 | * |
||
283 | * @param $method |
||
284 | * @param $url |
||
285 | * @param $options |
||
286 | * @return mixed|null |
||
287 | * @throws AccessDeniedException |
||
288 | * @throws ApiException |
||
289 | * @throws AuthenticationException |
||
290 | * @throws ConflictingStateException |
||
291 | */ |
||
292 | private function performRequest($method, $url, $options) { |
||
311 | |||
312 | |||
313 | /** |
||
314 | * @param $apiKey |
||
315 | * @param $domain |
||
316 | * @throws Exceptions\InvalidConfigurationException |
||
317 | * @internal |
||
318 | * |
||
319 | */ |
||
320 | private function validateConstructorArgs($apiKey, $domain) |
||
330 | |||
331 | /** |
||
332 | * @internal |
||
333 | */ |
||
334 | private function setupResources() |
||
359 | } |
||
360 |