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. 

Swift

ZDProvoider.sharedInstance.getDepartments(onCompletion: { (departments) in
// get departments list in departments variable
}) { (error) in
    // error in departments fetch
}

Objective-C

[[ZDProvoider sharedInstance] getDepartmentsOnCompletion:^(NSArray<DepartmentJsonObject *> * departments) {
    // get departments list in departments variable
} onError:^(NSError * error) {
    // error in departments fetch
}];

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.

Swift

ZDProvoider().getProductsFor(<#Department ID#>, from: <#T##Int#>, limit: <#T##Int#>, onCompletion: { (products) in
    // get products list in products variable
}) { (error) in
    // error in products fetch
}

Objective-C

[ZDProvoider sharedInstance] getProductsFor:@"Department ID" from:<#(NSInteger)#> limit:<#(NSInteger)#> onCompletion:^(NSArray  products) {
    // get products list in products variable
} onError:^(NSError * error) {
    // error in products fetch
}

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

Swift

ZDProvoider.sharedInstance.getTicketForm(<#Department ID#>, onCompletion: { (ticketFilelds) in
    // get Ticket Form in ticketFilelds variable
}) { (error) in
    // error in TicketForm fetch
}

Objective-C

 [[ZDProvoider sharedInstance] getTicketForm:<#Department ID#> onCompletion:^(NSArray<TicketFieldsJsonObject *> * ticketFilelds) {
    // get Ticket Form in ticketFilelds variable
} onError:^(NSError * error) {
    // error in TicketForm fetch
}];

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

Swift

ZDProvoider.sharedInstance.uploadTicketAttachment(<#Your File path#>, onCompletion: { (attachement) in
    // get uploaded attachement object in attachement variable
}) { (error) in
    // error in Attachement upload
}

Objective-C

[[ZDProvoider sharedInstance] uploadTicketAttachment:<#Your File path#> onCompletion:^(AttachmentJsonObject * attachement) {
    // get Ticket Form in ticketFilelds variable
} onError:^(NSError * error) {
    // error in Attachement upload
}];

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

Swift

let ticketForm = ZDTicketForm()
ticketForm.emailID = <#User email ID#>
ticketForm.contactName = <#Contact Name#>
ticketForm.subject = <#Ticket Subject#>
ticketForm.departmentID = <#Ticket Department ID#>
ticketForm.descriptionText = <#Ticket Description Text#>

ZDProvoider.sharedInstance.createTicket(form: ticketForm, onCompletion: { (ticket) in
    // get created ticket object in ticketDetail variable
}) { (error) in
    // error in ticket submission
}

Objective-C

ZDTicketForm * ticketForm = [ZDTicketForm init];
[ticketForm setEmailID:<#User email ID#>];
[ticketForm setContactName:<#Contact Name#>];
[ticketForm setSubject:<#Ticket Subject#>];
[ticketForm setDepartmentID:<#Ticket Department ID#>];
[ticketForm setDescriptionText:<#Ticket Description Text#>];

[[ZDProvoider sharedInstance] createTicketWithForm:ticketForm onCompletion:^(TicketDetailJsonObject * ticket) {
    // get created ticket object in ticketDetail variable
} onError:^(NSError * error) {
    // error in ticket submission
}]