ASAP for Mobile Platforms

Programmatically Adding Tickets

While end-users can manually submit tickets through the ASAP add-on, you can also configure your app to automatically record tickets 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 in your help desk. The user would not need to visit your help center and manually submit a ticket. 

To make this automatic submission of tickets possible, incorporate the following method in your app code. 

DeskNewTicketData ticketData = new DeskNewTicketData();
	ticketData.setEmail("emailAddress@test.com");
	ticketData.setContactName("ContactName");
	ticketData.setDepartmentId(departmentId);
	ticketData.setSubject("Subject of the Ticket");
	ticketData.setDescription("Description of the ticket");

	MyApplication.deskInstance.addGuestTicket(ticketData, new DeskCallback.DeskAddGuestTicketCallback() {
	      @Override
	      public void onTicketAdded() {
	            Log.i("APITEST", "addGuestTicket success ");
	      }
	      @Override
	      public void onException(DeskException exception) {
	            Log.i("APITEST", "addGuestTicket exception "+exception.getErrorMsg());
	      }
	});

EmailAddressSubject, and DepartmentID are mandatory parameters in the method call. 

To fetch the IDs of the departments in your help desk portal, use the following method. 

MyApplication.deskInstance.getDepartmentsList(new DeskCallback.DeskDepartmentsCallback() {
  @Override
  public void onDepartmentsLoaded(DeskDepartmentsList response) {
        Log.i("APITEST", "getDepartmentsList success ");
  }
  @Override
  public void onException(DeskException exception) {
        Log.i("APITEST", "getDepartments exception "+exception.getErrorMsg());
  }
});

To fetch information on the products configured in a department, use the following method.

public void getProducts(View view) {
  MyApplication.deskInstance.getProductsList(new DeskCallback.DeskProductsCallback() {
        @Override
        public void onProductsCompleted(DeskProductsList response) {
              Log.i("APITEST", "getProducts success");
        }
        @Override
        public void onException(DeskException exception) {
              Log.i("APITEST", "getProducts exception "+exception.getErrorMsg());
        }
  }, departmentId,1,10);
}

To fetch the fields configured in the ticket layout of a department, use the following method.

public void getTicketsFields(View view) {
  MyApplication.deskInstance.getTicketsFieldsList(new DeskCallback.DeskTicketsFieldsCallback() {
        @Override
        public void onTicketsFieldsLoaded(DeskTicketFieldList response) {
              Log.i("APITEST", "getTicketsFieldsList success");
        }
        @Override
        public void onException(DeskException exception) {
              Log.i("APITEST", "getTicketsFieldsList exception "+exception.getErrorMsg());
         }
  }, departmentId);
}

To include a file attachment in the ticket, use the following method.

MyApplication.deskInstance.uploadAttachment(new DeskCallback.DeskUploadAttachmentCallback() {
      @Override
      public void onUploadSuccess(DeskUploadAttachmentResponse response) {
            Log.i("APITEST", "uploadAttachment success "); 
      }
      @Override
      public void onException(DeskException exception) {
            Log.i("APITEST", "uploadAttachment exception "+exception.getErrorMsg());
      }
}, fileTobeuploaded);