public static List <Zendesk> SearchCustomFieldTickets(string searchCriteria, ref List <long?> listTickets) { /* Created by Neil Jansen - 5 December 2018 * Create a list of Zendesk objects through filtering the custom fields in Zendesk * * Updated by Neil Jansen - 12 December 2018 * Changed function name to specify 'CustomFields' - Updated Zendesk list object creation to include new parameters */ ConnectToZendesk(); List <Zendesk> zendeskTickets = new List <Zendesk>(); IListResponse <Ticket> responses = client.Search.Find(new ZendeskQuery <Ticket>().WithCustomFilter("fieldvalue", searchCriteria)); List <Ticket> responseTickets = (List <Ticket>)responses.Results; ZendDeskEmailEntry fromEmails = new ZendDeskEmailEntry(); ZendDeskEmailEntry toEmails = new ZendDeskEmailEntry(); foreach (Ticket singleTicket in responseTickets) { if (!listTickets.Any(ticket => ticket.Equals(singleTicket.Id))) { fromEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.From); toEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.To); zendeskTickets.Add(new Zendesk(singleTicket.Id.ToString(), singleTicket.Created, singleTicket.Updated, singleTicket.Subject, singleTicket.Status.ToString(), singleTicket.Priority, false, fromEmails.Address, fromEmails.Name, toEmails.Address, toEmails.Name, singleTicket.RequesterId.GetValueOrDefault())); listTickets.Add(singleTicket.Id); } } return(zendeskTickets); }
public static List <Zendesk> SearchRequestorTickets(string searchCriteria, ref List <long?> listTickets) { /* Created by Neil Jansen - 18 December 2018 * Create a list of Zendesk objects through filtering the Description field in Zendesk */ //true if sandbox, false for production ConnectToZendesk(); List <Zendesk> zendeskTickets = new List <Zendesk>(); IListResponse <Ticket> responses = client.Search.Find(new ZendeskQuery <Ticket>().WithCustomFilter("requester", searchCriteria)); List <Ticket> responseTickets = (List <Ticket>)responses.Results; ZendDeskEmailEntry fromEmails = new ZendDeskEmailEntry(); ZendDeskEmailEntry toEmails = new ZendDeskEmailEntry(); foreach (Ticket singleTicket in responseTickets) { if (!listTickets.Any(ticket => ticket.Equals(singleTicket.Id))) { fromEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.From); toEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.To); zendeskTickets.Add(new Zendesk(singleTicket.Id.ToString(), singleTicket.Created, singleTicket.Updated, singleTicket.Subject, singleTicket.Status.ToString(), singleTicket.Priority, false, fromEmails.Address, fromEmails.Name, toEmails.Address, toEmails.Name, singleTicket.RequesterId.GetValueOrDefault())); listTickets.Add(singleTicket.Id); } } return(zendeskTickets); }
public Zendesk VerifyZendeskTicket(long zendeskTicket) { Zendesk ticket = new Zendesk(); try { IResponse <Ticket> validTicket = client.Tickets.Get(zendeskTicket); Ticket response = validTicket.Item; ZendDeskEmailEntry fromEmails = ZendDeskEmailParser.GetEmailList(response.Via.Source.From); ZendDeskEmailEntry toEmails = ZendDeskEmailParser.GetEmailList(response.Via.Source.To); ticket = new Zendesk(response.Id.ToString(), response.Created, response.Updated, response.Subject, response.Status.ToString(), response.Priority, false, fromEmails.Address, fromEmails.Name, toEmails.Address, toEmails.Name, response.RequesterId.GetValueOrDefault()); } catch (Exception) { ticket = null; } return(ticket); }