NotionCommotion
The API currently allows the creation of a new ticket (https://docs.osticket.com/en/latest/Developer%20Documentation/API/Tickets.html).
In addition, I need api endpoints to allow a client-user to be able to perform the following:
1. Display a given users tickets.
2. Display available topics.
3. Display a ticket based on a given ticket ID.
4. Close a ticket.
5. Reopen a ticket.
6. Post a reply to an existing ticket.
I added this functionality and it is located at https://github.com/NotionCommotion/osTicket
Typical output is as follows:
getTickets: GET / api / tickets.json: {
"email": "michael.test@gmail.com"
}
response: [{
"id": 0,
"value": {
"ticket_number": "177501",
"subject": "New ticket",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-10 16:22:54",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "Web",
"due_timestamp": "2018-11-12 16:22:54",
"close_timestamp": "2018-11-12 17:09:16",
"help_topic": "General Inquiry",
"last_message_timestamp": "2018-11-12 17:09:16",
"last_response_timestamp": "2018-11-10 16:23:15",
"assigned_to": [{
"format": "full",
"parts": {
"first": "Michael",
"last": "Reed"
},
"name": "Michael Reed"
}
],
"thread_entries": null
}
}, {
"id": 1,
"value": {
"ticket_number": "186507",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 17:09:17",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 17:09:17",
"close_timestamp": "2018-11-12 17:50:20",
"help_topic": null,
"last_message_timestamp": "2018-11-12 17:10:15",
"last_response_timestamp": null,
"assigned_to": [{
"format": "full",
"parts": {
"first": "Michael",
"last": "Reed"
},
"name": "Michael Reed"
}
],
"thread_entries": null
}
}, {
"id": 2,
"value": {
"ticket_number": "374116",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 17:10:15",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 17:10:15",
"close_timestamp": null,
"help_topic": null,
"last_message_timestamp": "2018-11-12 17:10:15",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
}, {
"id": 3,
"value": {
"ticket_number": "839034",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 17:11:29",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 17:11:29",
"close_timestamp": "2018-11-12 21:26:27",
"help_topic": null,
"last_message_timestamp": "2018-11-12 21:26:27",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
}, {
"id": 4,
"value": {
"ticket_number": "134605",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 21:26:28",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 21:26:28",
"close_timestamp": null,
"help_topic": null,
"last_message_timestamp": "2018-11-12 21:26:28",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
}
]
getTopics: GET / api / topics.json: {}
response: [{
"id": 2,
"value": "Feedback"
}, {
"id": 1,
"value": "General Inquiry"
}, {
"id": 10,
"value": "Report a Problem"
}, {
"id": 11,
"value": "Report a Problem / Access Issue"
}
]
getTicket: GET / api / tickets.json / 839034: {
"email": "michael.test@gmail.com"
}
response: {
"ticket_number": "839034",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 17:11:29",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 17:11:29",
"close_timestamp": "2018-11-12 21:26:27",
"help_topic": null,
"last_message_timestamp": "2018-11-12 21:26:27",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
closeTicket: DELETE / api / tickets.json / 839034: {
"email": "michael.test@gmail.com"
}
response: undefined
reopenTicket: POST / api / tickets.json / 839034: {
"email": "michael.test@gmail.com"
}
response: {
"ticket_number": "839034",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 17:11:29",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 17:11:29",
"close_timestamp": "2018-11-12 21:35:15",
"help_topic": null,
"last_message_timestamp": "2018-11-12 21:26:27",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
updateTicket: PUT / api / tickets.json / 839034: {
"email": "michael.test@gmail.com",
"message": "My updated message"
}
response: {
"ticket_number": "839034",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 17:11:29",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 17:11:29",
"close_timestamp": "2018-11-12 21:35:15",
"help_topic": null,
"last_message_timestamp": "2018-11-12 21:35:15",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
create: POST / api / tickets.json: {
"email": "michael.test@gmail.com",
"message": "My original message",
"name": "John Doe",
"subject": "Testing API"
}
response: {
"ticket_number": "117341",
"subject": "Testing API",
"ticket_status": "Open",
"statusId": 1,
"priority": "Normal",
"department": "Support",
"create_timestamp": "2018-11-12 21:35:16",
"user_name": "Michael User2",
"user_email": {
"address": "michael.test@gmail.com"
},
"user_phone": "",
"source": "API",
"due_timestamp": "2018-11-14 21:35:16",
"close_timestamp": null,
"help_topic": null,
"last_message_timestamp": "2018-11-12 21:35:16",
"last_response_timestamp": null,
"assigned_to": [],
"thread_entries": null
}
After getting half way there, I discovered that amalmagdy had a similar need (https://github.com/osTicket/osTicket/pull/4361), however, it addressed admin-user needs. While I didn't testing any of this functionality, I did add it to my branch.
For the most part, it works, however, would like some input from others. I tried to follow the design patters used by the base code, however, expect I deviated it from time to time. One specific think I wish to change is when a ticket is closed and reopened, it shows performed by "SYSTEM" instead of by the user's name or at least by "USER". I also haven't yet gotten around to allowing files to be included when posting a reply to a topic. Also, I still need to get the treads included when viewing a given ticket.
Any recommendations how it should be changed?
Also, I've never done a pull request to allow my changes to be considered to be merged into the master. How is this accomplished? When trying to do so, it appears that I need write access to the main repository. Is just providing my own branch enough?
Thanks
PS. Is it possible to format code on this forum?