Programmatically adding tickets
While end-users can manually submit tickets through the ASAP help widget, you can also configure your app to record tickets automatically when certain events occur in the app. For instance, if you run a clothing business and your app fails to load the For Women screen when a user tries to access it, this failure instance can be automatically recorded as a ticket on your help desk. The user does not need to visit your help center and manually submit a ticket.
To make this automatic submission of tickets possible, incorporate the following methods in your app code:
ZDPortalTicketsAPI.createTicket(new CreateTicketCallback() {
@Override
public void onTicketCreated(Ticket ticket) {
}
@Override
public void onException(ZDPortalException exception) {
}
}, ticketData, params);
ticketData - instance of HashMap<String, Object> key-value
The keys passed in the ticketData should match the TicketField's apiName.
Ticket fields can be fetched using the getTicketFields API mentioned below.
The email, subject, and departmentId keys are mandatory parameters in the ticketData.
To fetch the IDs of the departments in your help desk portal, use the following method:
- ZDPortalAPI.getDepartments(new ZDPortalCallback.DepartmensCallback() {
@Override
public void onDepartmentsDownloaded(DepartmentsList response) {
}
@Override
public void onException(ZDPortalException exception) {
}
});
Use the following method to fetch the IDs of the layouts in your help desk portal:
- HashMap<String, String> params = new HashMap<>();
params.put("departmentId", departmentId);
ZDPortalAPI.getLayouts(new ZDPortalCallback.LayoutsCallback() {
@Override
public void onLayoutsDownloaded(Layouts layouts) {
//layout fetch succeed
}
@Override
public void onException(ZDPortalException e) {
//layout fetch failed
}
}, params);
Use the following method to fetch information on the products configured in a department:
- HashMap<String, String> options = new HashMap<>();
options.put("from", String.valueOf(1));
options.put("limit", String.valueOf(100));
options.put("departmentId", departmentId);
ZDPortalAPI.getProductsList(new ZDPortalCallback.ProductsCallback() {
@Override
public void onProductsDownloaded(ProductsList productsList) {
productsMap.put(departmentId, productsList.getData());
responseLiveData.setValue(productsList.getData());
}
@Override
public void onException(ZDPortalException exception) {
}
}, options);
To fetch the fields configured in the ticket layout of a department, use the following method:
- ZDPortalTicketsAPI.getTicketFields(new TicketFieldsCallback() {
@Override
public void onTicketFieldsDownloaded(TicketFieldsList ticketFieldsList) {
}
@Override
public void onException(ZDPortalException exception) {
}
}, fieldsParams, "apiName");
To include a file attachment in the Ticket, use the following method:
ZDPortalTicketsAPI.uploadAttachment(new UploadAttachmentCallback() {
@Override
public void onAttachmentUploaded(ASAPAttachmentUploadResponse response) {
}
@Override
public void onException(ZDPortalException exception) {
}
}, fileTobeUploaded, null);
Updating user details
The following API helps update the details of users added to your help desk portal:
- HashMap<String, String> params = new HashMap<>();
params.put("timeZone", "asia/kolkatta");
ZDPortalAPI.updateProfileDetails(new ZDPortalCallback.UserDetailsCallback() {
@Override
public void onUserDetailsSuccess(DeskUserProfile userProfile) {
}
@Override
public void onException(ZDPortalException exception) {
}
}, params);
Params
HashMap <String, String> data - Key and value pair. The following keys are included: X, phone, Facebook, name, displayName, mobile, countryLocale, and timeZone.