Skip to content
nicno90 edited this page Mar 23, 2015 · 6 revisions

This is the API for web development; the Android and iOS apps will use a different API. This API consists of several resources, which each represent a different table in the database. These resources are accessed through actions, which are similar to methods, but are accessed through a URL. This URL is of the form website/resource/action.php, where website is the name of our website, resource is the resource being used (e.g. tickets), and action is the action name. In order to use these actions, there are a few things you must understand.

First, each action has one of two return types: HTML or JSON. HTML actions return a new webpage, and are accessed by either giving the user a link to click, or setting the action attribute of a form to the action's URL. No JavaScript is needed to use HTML actions. JSON Actions return a JSON string, and are a little more complicated. The must be accessed through a Javascript function, which uses an XMLHttpRequest object to retrieve the string. This string must then be parsed into a Javascript object (Javascript provides functions that do this automatically) and the data in that object will be used to update the current page.

Secondly, each action has a request type; at least for now, the only request types used are GET and POST. GET is used when you are retrieving data from the server, while POST is used for actions that modify the database. To create a request for an HTML action that uses a form, you simply set the method attribute of the form to either "get" or "post". For a JSON action, you set the XMLHttpRequest to use GET or POST. To create a GET request for an HTML action that uses a regular link, you append the parameters to the end of the URL, in the following format: "?param1=value&param2=anotherValue". You cannot create POST requests from a regular link for HTML actions.

In the tables below are the descriptions of actions, sorted by resource. For now, ignore the access level.

Tickets

Action Name Description Request Type Parameters Output Type Access Level
create Creates a new support ticket. POST description HTML all
list Lists all tickets a user has created, or is in charge of (for consultants and managers). GET NA HTML all
view Views the details of a specific ticket. GET ticketID HTML all
change_status Changes the status of a ticket (e.g. is completed). POST ticketID, newstatus JSON consultant or above.
assign_consultant Assigns a consultant to the ticket. POST ticketID, consultantID JSON manager or above.
delete Deletes a ticket. POST ticketID JSON admin

Messages

Action Name Description Request Type Parameters Output Type Access Level
list Lists all messages associated with a certain ticket. GET ticketID HTML all
view Views the details of a specific message. GET messageID HTML all
send Sends a new message to the people associated with a ticket. POST ticketID, message JSON all

Users

Action Name Description Request Type Parameters Output Type Access Level
list Returns a list of users. GET NA HTML consultant or above.
view Views the details of a specific user. GET messageID HTML all
set_position Changes the position of the user. POST userID, message JSON admin

Clone this wiki locally