codingFive0 /
octadesk
| 1 | <?php |
||
| 2 | |||
| 3 | namespace codingFive0\octadesk; |
||
| 4 | |||
| 5 | class Ticket extends Octadesk |
||
| 6 | { |
||
| 7 | |||
| 8 | public function __construct($accToken) |
||
| 9 | { |
||
| 10 | $this->setAccesToken($accToken); |
||
| 11 | parent::__construct(); |
||
| 12 | } |
||
| 13 | |||
| 14 | public function customList() |
||
| 15 | { |
||
| 16 | $this->request( |
||
| 17 | "GET", |
||
| 18 | "tickets/custom-lists" |
||
| 19 | ); |
||
| 20 | |||
| 21 | return $this; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function defaultList() |
||
| 25 | { |
||
| 26 | $this->request( |
||
| 27 | "GET", |
||
| 28 | "tickets/default-lists" |
||
| 29 | ); |
||
| 30 | |||
| 31 | return $this; |
||
| 32 | } |
||
| 33 | |||
| 34 | public function findByRequesterId($idRequester, $lastNumber = null) |
||
| 35 | { |
||
| 36 | $params["idRequester"] = $idRequester; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 37 | |||
| 38 | if ($lastNumber) { |
||
| 39 | $params["lastNumber"] = $lastNumber; |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->request( |
||
| 43 | "GET", |
||
| 44 | "tickets", |
||
| 45 | $params |
||
| 46 | ); |
||
| 47 | |||
| 48 | return $this; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function findByNumber($number) |
||
| 52 | { |
||
| 53 | $this->request( |
||
| 54 | "GET", |
||
| 55 | "tickets/{$number}" |
||
| 56 | ); |
||
| 57 | |||
| 58 | return $this; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function createTicket(array $ticket, array $customField = []) |
||
| 62 | { |
||
| 63 | $body = [ |
||
| 64 | "requester" => [ |
||
| 65 | "email" => ($ticket["requester_email"]), |
||
| 66 | "name" => ($ticket["requester_name"]) |
||
| 67 | ], |
||
| 68 | "summary" => ($ticket["summary"] ?? null), |
||
| 69 | "comments" => [ |
||
| 70 | "description" => [ |
||
| 71 | "content" => ($ticket["comments_content"] ?? null) |
||
| 72 | ] |
||
| 73 | ], |
||
| 74 | "idProductRelated" => ($ticket["product"] ?? null) |
||
| 75 | ]; |
||
| 76 | |||
| 77 | if ($customField) { |
||
| 78 | $body = array_merge(["customField" => $customField], $body); |
||
| 79 | } |
||
| 80 | |||
| 81 | $this->request( |
||
| 82 | "POST", |
||
| 83 | "tickets", |
||
| 84 | $body, |
||
| 85 | null, |
||
| 86 | true |
||
| 87 | ); |
||
| 88 | |||
| 89 | return $this; |
||
| 90 | } |
||
| 91 | } |