From 22372ca14db0c20078a8a8f64acb99adea19df22 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 29 Nov 2015 11:45:23 -0500 Subject: [PATCH] Add GET /ticket --- api/admin/ticket/index.php | 4 +- api/businesslogic/ticket_retriever.php | 65 +++++++----- api/ticket/index.php | 132 +++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 24 deletions(-) create mode 100644 api/ticket/index.php diff --git a/api/admin/ticket/index.php b/api/admin/ticket/index.php index 4d315efe..a95fc1fb 100644 --- a/api/admin/ticket/index.php +++ b/api/admin/ticket/index.php @@ -118,9 +118,9 @@ if ($request_method == 'GET') { } if (isset($_GET['id'])) { - $results = get_ticket($hesk_settings, $_GET['id']); + $results = get_ticket_for_staff($hesk_settings, $_GET['id']); } else { - $results = get_ticket($hesk_settings); + $results = get_ticket_for_staff($hesk_settings); } if ($results == NULL) { diff --git a/api/businesslogic/ticket_retriever.php b/api/businesslogic/ticket_retriever.php index 82d99f8e..59f4ee69 100644 --- a/api/businesslogic/ticket_retriever.php +++ b/api/businesslogic/ticket_retriever.php @@ -1,22 +1,12 @@ `false` otherwise + * @apiSuccess {Boolean} locked `true` if the ticket is locked
`false` otherwise + * @apiSuccess {Binary[]} attachments Array of attachments, in base-64 encoded binary + * @apiSuccess {Integer[]} merged Array of merged ticket IDs + * @apiSuccess {String} history HTML markup of the entire "Audit Trail" section + * @apiSuccess {String} custom1-20 Custom fields 1-20's values. + * @apiSuccess {Integer} parent The ID of the ticket linked to this ticket + * @apiSuccess {String} latitude The latitudinal coordinate of the user's location, or one of the corresponding error codes. + * @apiSuccess {String} longitude The longitudinal coordinate of the user's location, or one of the corresponding error codes. + * @apiSuccess {Boolean} html `true` if the ticket was created with HTML encoding
`false` otherwise + * @apiSuccess {String} user_agent The user agent of the user who submitted the ticket + * @apiSuccess {Integer} screen_resolution_width The width of the screen resolution of the user who submitted the ticket + * @apiSuccess {Integer} screen_resolution_height The height of the screen resolution of the user who submitted the ticket + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * { + * "id": 22, + * "trackid": "EVL-RRL-DUBG", + * "name": "Test", + * "email": "", + * "category": 1, + * "priority": 3, + * "subject": "test", + * "message": "test", + * "dt": "2014-12-28 00:57:26", + * "articles": null, + * "ip": "127.0.0.1", + * "language": null, + * "status": 3, + * "owner": 1, + * "time_worked": "00:05:07", + * "archive": true, + * "locked": true, + * "attachments": "", + * "merged": "", + * "history": "
  • 2014-12-28 06:57:28 | ticket created by Your name (mkoch)
  • 2014-12-31 21:00:59 | closed by Your name (mkoch)
  • 2014-12-31 21:01:05 | status changed to Waiting reply by Your name (mkoch)
  • 2014-12-31 21:01:58 | closed by Your name (mkoch)
  • 2015-01-17 16:21:18 | closed by Your name (mkoch)
  • 2015-01-17 16:21:31 | closed by Your name (mkoch)
  • 2015-01-17 16:22:05 | closed by Your name (mkoch)
  • 2015-01-17 16:24:06 | status changed to by Your name (mkoch)
  • 2015-01-17 16:25:40 | status changed to On Hold by Your name (mkoch)
  • 2015-01-17 16:25:53 | status changed to In Progress by Your name (mkoch)
  • 2015-01-17 21:39:11 | locked by Your name (mkoch)
  • ", + * "custom1": "1420671600", + * "custom2": "", + * "custom3": "", + * "custom4": "", + * "custom5": "", + * "custom6": "", + * "custom7": "", + * "custom8": "", + * "custom9": "", + * "custom10": "", + * "custom11": "", + * "custom12": "", + * "custom13": "", + * "custom14": "", + * "custom15": "", + * "custom16": "", + * "custom17": "", + * "custom18": "", + * "custom19": "", + * "custom20": "", + * "parent": 139, + * "latitude": "E-0", + * "longitude": "E-0", + * "html": false, + * "user_agent": null, + * "screen_resolution_width": null, + * "screen_resolution_height": null + * } + * + * @apiError (noTokenProvided) 400 No `X-Auth-Token` was provided where it is required + * @apiError (invalidXAuthToken) 401 The `X-Auth-Token` provided was invalid + */ +if ($request_method == 'GET') { + $token = get_header('X-Auth-Token'); + + try { + get_user_for_token($token, $hesk_settings); + } catch (AccessException $e) { + return http_response_code($e->getCode()); + } + + if (isset($_GET['id'])) { + $results = get_ticket($hesk_settings, $_GET['id']); + } else { + return http_response_code(400); + } + + if ($results == NULL) { + return http_response_code(404); + } + return output($results); +} + +return http_response_code(405); \ No newline at end of file