From b985d02f1b608428bdda45155348a3e2be307f80 Mon Sep 17 00:00:00 2001
From: ivan <ivan@opensupports.com>
Date: Thu, 20 Apr 2017 00:55:38 -0300
Subject: [PATCH] Ivan - Add error documentation

---
 .../ticket/add-custom-response.php            |  12 +-
 server/controllers/ticket/get.php             |  16 +-
 server/data/ERRORS.php                        | 173 ++++++++++++++++++
 server/models/Ticket.php                      |  25 +++
 server/models/Ticketevent.php                 |  14 ++
 5 files changed, 227 insertions(+), 13 deletions(-)

diff --git a/server/controllers/ticket/add-custom-response.php b/server/controllers/ticket/add-custom-response.php
index b51142bc..37cb0199 100644
--- a/server/controllers/ticket/add-custom-response.php
+++ b/server/controllers/ticket/add-custom-response.php
@@ -3,13 +3,13 @@ use Respect\Validation\Validator as DataValidator;
 DataValidator::with('CustomValidations', true);
 
 /**
- * @api {post} /ticket/add-custom-response Add new responses.
+ * @api {post} /ticket/add-custom-response Add new custom responses.
  *
- * @apiName Add custom response
+ * @apiName Add a custom response
  *
  * @apiGroup Ticket
  *
- * @apiDescription This path allows create new responses to tickets.
+ * @apiDescription This path allows create new custom responses for tickets.
  *
  * @apiPermission Staff Level 2
  *
@@ -19,9 +19,11 @@ DataValidator::with('CustomValidations', true);
  *
  * @apiParam {String} language Language of the response.
  *
- * @apiError {String} message
+ * @apiUse INVALID_NAME
+ * @apiUse INVALID_CONTENT
+ * @apiUse INVALID_LANGUAGE
  *
- * @apiSuccess {Object} data
+ * @apiSuccess {Object} data Empty object
  *
  */
 
diff --git a/server/controllers/ticket/get.php b/server/controllers/ticket/get.php
index 9eb5241f..0eca2d82 100644
--- a/server/controllers/ticket/get.php
+++ b/server/controllers/ticket/get.php
@@ -1,28 +1,28 @@
 <?php
 use Respect\Validation\Validator as DataValidator;
 DataValidator::with('CustomValidations', true);
-
 /**
- * @api {post} /ticket/get give back information about a ticket.
+ * @api {post} /ticket/get Retrieve Ticket information.
  *
- * @apiName Get
+ * @apiName GetTicket
  *
  * @apiGroup Ticket
  *
- * @apiDescription This path give back information about a ticket.
+ * @apiDescription This path gives back information about a ticket.
  *
  * @apiPermission any
  *
  * @apiParam {number} ticketNumber The number of the ticket.
  *
- * @apiParam {string} csrf_token Token of the session.
+ * @apiParam {string} csrf_token Token of the current session.
  *
- * @apiError {String} message
- *
- * @apiSuccess {Object} data
+ * @apiUse NO_PERMISSION
+ * @apiUse INVALID_TICKET
  *
+ * @apiSuccess {[Ticket](#api-Data_Structures-ObjectTicket)} events The requested event(s).
  */
 
+
 class TicketGetController extends Controller {
     const PATH = '/get';
     const METHOD = 'POST';
diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php
index 22f2291b..e1e817bd 100644
--- a/server/data/ERRORS.php
+++ b/server/data/ERRORS.php
@@ -1,4 +1,177 @@
 <?php
+/**
+ * @apiDefine INVALID_CREDENTIALS
+ * @apiError {String} INVALID_CREDENTIALS Login credentials does not match.
+ */
+/**
+ * @apiDefine SESSION_EXISTS
+ * @apiError {String} SESSION_EXISTS The session already exists.
+ */
+/**
+ * @apiDefine USER_EXISTS
+ * @apiError {String} USER_EXISTS The user already exists.
+ */
+/**
+ * @apiDefine NO_PERMISSION
+ * @apiError {String} NO_PERMISSION You have no permission to perform this operation.
+ */
+/**
+ * @apiDefine INVALID_TITLE
+ * @apiError {String} INVALID_TITLE The title is invalid, probably too short.
+ */
+/**
+ * @apiDefine INVALID_CONTENT
+ * @apiError {String} INVALID_CONTENT The content is invalid, probably to short.
+ */
+/**
+ * @apiDefine INVALID_EMAIL
+ * @apiError {String} INVALID_EMAIL The email is invalid or already exists.
+ */
+/**
+ * @apiDefine INVALID_PASSWORD
+ * @apiError {String} INVALID_PASSWORD The password is invalid, probably too short.
+ */
+/**
+ * @apiDefine INVALID_NAME
+ * @apiError {String} INVALID_NAME Common error
+ */
+/**
+ * @apiDefine INVALID_SETTING
+ * @apiError {String} INVALID_SETTING Common error
+ */
+/**
+ * @apiDefine INVALID_DEPARTMENT
+ * @apiError {String} INVALID_DEPARTMENT Common error
+ */
+/**
+ * @apiDefine INVALID_TICKET
+ * @apiError {String} INVALID_TICKET Common error
+ */
+/**
+ * @apiDefine INIT_SETTINGS_DONE
+ * @apiError {String} INIT_SETTINGS_DONE Common error
+ */
+/**
+ * @apiDefine INVALID_OLD_PASSWORD
+ * @apiError {String} INVALID_OLD_PASSWORD Common error
+ */
+/**
+ * @apiDefine INVALID_CAPTCHA
+ * @apiError {String} INVALID_CAPTCHA Common error
+ */
+/**
+ * @apiDefine INVALID_TICKET_EVENT
+ * @apiError {String} INVALID_TICKET_EVENT Common error
+ */
+/**
+ * @apiDefine INVALID_LANGUAGE
+ * @apiError {String} INVALID_LANGUAGE Common error
+ */
+/**
+ * @apiDefine TICKET_ALREADY_ASSIGNED
+ * @apiError {String} TICKET_ALREADY_ASSIGNED Common error
+ */
+/**
+ * @apiDefine INVALID_PRIORITY
+ * @apiError {String} INVALID_PRIORITY Common error
+ */
+/**
+ * @apiDefine INVALID_PAGE
+ * @apiError {String} INVALID_PAGE Common error
+ */
+/**
+ * @apiDefine INVALID_QUERY
+ * @apiError {String} INVALID_QUERY Common error
+ */
+/**
+ * @apiDefine INVALID_TOPIC
+ * @apiError {String} INVALID_TOPIC Common error
+ */
+/**
+ * @apiDefine INVALID_SEARCH
+ * @apiError {String} INVALID_SEARCH Common error
+ */
+/**
+ * @apiDefine INVALID_ORDER
+ * @apiError {String} INVALID_ORDER Common error
+ */
+/**
+ * @apiDefine INVALID_USER
+ * @apiError {String} INVALID_USER Common error
+ */
+/**
+ * @apiDefine ALREADY_BANNED
+ * @apiError {String} ALREADY_BANNED Common error
+ */
+/**
+ * @apiDefine INVALID_LEVEL
+ * @apiError {String} INVALID_LEVEL Common error
+ */
+/**
+ * @apiDefine ALREADY_A_STAFF
+ * @apiError {String} ALREADY_A_STAFF Common error
+ */
+/**
+ * @apiDefine INVALID_STAFF
+ * @apiError {String} INVALID_STAFF Common error
+ */
+/**
+ * @apiDefine SAME_DEPARTMENT
+ * @apiError {String} SAME_DEPARTMENT Common error
+ */
+/**
+ * @apiDefine INVALID_TOKEN
+ * @apiError {String} INVALID_TOKEN Common error
+ */
+/**
+ * @apiDefine UNVERIFIED_USER
+ * @apiError {String} UNVERIFIED_USER Common error
+ */
+/**
+ * @apiDefine INVALID_TEMPLATE
+ * @apiError {String} INVALID_TEMPLATE Common error
+ */
+/**
+ * @apiDefine INVALID_SUBJECT
+ * @apiError {String} INVALID_SUBJECT Common error
+ */
+/**
+ * @apiDefine INVALID_BODY
+ * @apiError {String} INVALID_BODY Common error
+ */
+/**
+ * @apiDefine USER_SYSTEM_DISABLED
+ * @apiError {String} USER_SYSTEM_DISABLED Common error
+ */
+/**
+ * @apiDefine SYSTEM_USER_IS_ALREADY_DISABLED
+ * @apiError {String} SYSTEM_USER_IS_ALREADY_DISABLED Common error
+ */
+/**
+ * @apiDefine SYSTEM_USER_IS_ALREADY_ENABLED
+ * @apiError {String} SYSTEM_USER_IS_ALREADY_ENABLED Common error
+ */
+/**
+ * @apiDefine INVALID_PERIOD
+ * @apiError {String} INVALID_PERIOD Common error
+ */
+/**
+ * @apiDefine NAME_ALREADY_USED
+ * @apiError {String} NAME_ALREADY_USED Common error
+ */
+/**
+ * @apiDefine INVALID_FILE
+ * @apiError {String} INVALID_FILE Common error
+ */
+/**
+ * @apiDefine DATABASE_CONNECTION
+ * @apiError {String} DATABASE_CONNECTION Common error
+ */
+/**
+ * @apiDefine DATABASE_CREATION
+ * @apiError {String} DATABASE_CREATION Common error
+ */
+
 class ERRORS {
     const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS';
     const SESSION_EXISTS = 'SESSION_EXISTS';
diff --git a/server/models/Ticket.php b/server/models/Ticket.php
index aeb0a0bd..19c1d0b9 100644
--- a/server/models/Ticket.php
+++ b/server/models/Ticket.php
@@ -1,4 +1,29 @@
 <?php
+/**
+ * @api {OBJECT} Ticket Ticket
+ * @apiGroup Data Structures
+ * @apiParam {Number}  ticketNumber Users age.
+ * @apiParam {String}  title Avatar-Image.
+ * @apiParam {String}  content Avatar-Image.
+ * @apiParam {Object}  department Avatar-Image.
+ * @apiParam {Number}  department.id Avatar-Image.
+ * @apiParam {String}  department.name Avatar-Image.
+ * @apiParam {String}  file Avatar-Image.
+ * @apiParam {String}  language Avatar-Image.
+ * @apiParam {Boolean}  unread Avatar-Image.
+ * @apiParam {Boolean}  unreadStaff Avatar-Image.
+ * @apiParam {Boolean}  closed Avatar-Image.
+ * @apiParam {String}  priority Avatar-Image.
+ * @apiParam {Object}  author Avatar-Image.
+ * @apiParam {Number}  author.id Avatar-Image.
+ * @apiParam {String}  author.name Avatar-Image.
+ * @apiParam {String}  author.email Avatar-Image.
+ * @apiParam {Object}  owner Avatar-Image.
+ * @apiParam {Number}  owner.id Avatar-Image.
+ * @apiParam {String}  owner.name Avatar-Image.
+ * @apiParam {String}  owner.email Avatar-Image.
+ * @apiParam {[TicketEvent](#api-Data_Structures-ObjectTicketevent)[]} events The requested event(s).
+ */
 use RedBeanPHP\Facade as RedBean;
 
 class Ticket extends DataStore {
diff --git a/server/models/Ticketevent.php b/server/models/Ticketevent.php
index c178d349..a9ebe2cc 100644
--- a/server/models/Ticketevent.php
+++ b/server/models/Ticketevent.php
@@ -1,4 +1,18 @@
 <?php
+/**
+ * @api {OBJECT} TicketEvent TicketEvent
+ * @apiGroup Data Structures
+ * @apiParam {String}  type Avatar-Image.
+ * @apiParam {String}  content Avatar-Image.
+ * @apiParam {Object}  author Avatar-Image.
+ * @apiParam {Number}  author.id Avatar-Image.
+ * @apiParam {String}  author.name Avatar-Image.
+ * @apiParam {String}  author.email Avatar-Image.
+ * @apiParam {String}  author.profilePic Avatar-Image.
+ * @apiParam {Boolean}  author.staff Avatar-Image.
+ * @apiParam {String}  date Avatar-Image.
+ * @apiParam {String}  file Avatar-Image.
+ */
 
 class Ticketevent extends DataStore {
     const TABLE = 'ticketevent';