@@ -230,4 +230,128 @@ public function getOrderMessages($orderID) : array
230230
231231 return $ data ;
232232 }
233+
234+ public function createTicket ($ subject , $ note , $ user_id , $ status = 1 )
235+ {
236+ $ response = $ this ->client ->request ('POST ' , 'tickets ' , [
237+ 'auth ' => [$ this ->apiKey , '' ],
238+ 'form_params ' => [
239+ 'user_id ' => $ user_id ,
240+ 'status ' => $ status ,
241+ 'subject ' => $ subject ,
242+ 'note ' => $ note ,
243+ ],
244+ ]);
245+
246+ return $ response ->getStatusCode ();
247+ }
248+
249+ public function getTicket ($ ticketID )
250+ {
251+ $ response = $ this ->client ->request ('GET ' , 'tickets/ ' . $ ticketID , [
252+ 'auth ' => [$ this ->apiKey , '' ],
253+ ]);
254+
255+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
256+
257+ return $ data ;
258+ }
259+
260+ public function updateTicket ($ ticketID , $ subject = null , $ note = null , $ status = null , $ employees = null , $ tags = null )
261+ {
262+ $ formParams = [];
263+
264+ if ($ subject ) {
265+ $ formParams ['subject ' ] = $ subject ;
266+ }
267+
268+ if ($ note ) {
269+ $ formParams ['note ' ] = $ note ;
270+ }
271+
272+ if ($ status ) {
273+ $ formParams ['status ' ] = $ status ;
274+ }
275+
276+ if ($ employees ) {
277+ $ formParams ['employees ' ] = $ employees ;
278+ }
279+
280+ if ($ tags ) {
281+ $ formParams ['tags ' ] = $ tags ;
282+ }
283+
284+ $ response = $ this ->client ->request ('POST ' , 'tickets/ ' . $ ticketID , [
285+ 'auth ' => [$ this ->apiKey , '' ],
286+ 'form_params ' => $ formParams ,
287+ ]);
288+
289+ return $ response ->getStatusCode ();
290+ }
291+
292+ public function deleteTicket ($ ticketID )
293+ {
294+ $ response = $ this ->client ->request ('DELETE ' , 'tickets/ ' . $ ticketID , [
295+ 'auth ' => [$ this ->apiKey , '' ],
296+ ]);
297+
298+ return $ response ->getStatusCode ();
299+ }
300+
301+ public function getTickets (array $ options = []) : array
302+ {
303+ $ response = $ this ->client ->request ('GET ' , 'tickets ' , [
304+ 'query ' => $ options ,
305+ 'auth ' => [$ this ->apiKey , '' ],
306+ ]);
307+
308+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
309+
310+ return $ data ;
311+ }
312+
313+ public function createTicketMessage ($ ticketID , $ message , $ user_id , $ staff_only = 0 )
314+ {
315+ $ response = $ this ->client ->request ('POST ' , 'ticket_messages/ ' . $ ticketID , [
316+ 'auth ' => [$ this ->apiKey , '' ],
317+ 'form_params ' => [
318+ 'user_id ' => $ user_id ,
319+ 'staff_only ' => $ staff_only ,
320+ 'message ' => $ message ,
321+ ],
322+ ]);
323+
324+ return $ response ->getStatusCode ();
325+ }
326+
327+ public function deleteTicketMessage ($ ticketID , $ messageID )
328+ {
329+ $ response = $ this ->client ->request ('DELETE ' , 'ticket_messages/ ' . $ ticketID . '/ ' . $ messageID , [
330+ 'auth ' => [$ this ->apiKey , '' ],
331+ ]);
332+
333+ return $ response ->getStatusCode ();
334+ }
335+
336+ public function getTicketMessages ($ ticketID ) : array
337+ {
338+ $ response = $ this ->client ->request ('GET ' , 'ticket_messages/ ' . $ ticketID , [
339+ 'auth ' => [$ this ->apiKey , '' ],
340+ ]);
341+
342+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
343+
344+ return $ data ;
345+ }
346+
347+ public function loginLink ($ clientID ) : string
348+ {
349+ $ response = $ this ->client ->request ('GET ' , 'login_links/ ' . $ clientID , [
350+ 'auth ' => [$ this ->apiKey , '' ],
351+ ]);
352+
353+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
354+
355+ return $ data ['link ' ];
356+ }
233357}
0 commit comments