public long?CreateNewZendeskTicketWithPDFFile(MemoryFile file, string rmaNo, string amazonBucketURL, string customerEmail, string customerName, bool fileAttached, string ExtDocNo, bool validURL) { ConnectToZendesk(); string uploadToken = string.Empty; long? createdTicketID; Ticket newTicket = new Ticket(); Ticket updateNewTicket = new Ticket(); Ticket ticketReponse; // First we need to create the Zendesk Ticket per the customer request BEFORE we send the return shipping information newTicket.Subject = "Return Label Request for: " + ExtDocNo; TicketComment newComment = new TicketComment { IsPublic = true, Type = TicketEventType.Comment, Body = "Return Label Request" }; newTicket.Comment = newComment; Via via = new Via { Channel = "web_service" }; newTicket.Via = via; TicketRequester ticketRequester = new TicketRequester { Name = customerName, Email = customerEmail, }; newTicket.Requester = ticketRequester; newTicket.Recipient = customerEmail; TicketRequest newRequest = new TicketRequest { Item = newTicket }; IResponse <Ticket> responseTicket = client.Tickets.Post(newRequest); // We need to retrieve the ticket ID of the newly created Ticket createdTicketID = responseTicket.Item.Id; string ticketID = createdTicketID.ToString(); long.TryParse(ticketID, out long updateTicketID); // Now we immediately update the newly created ticket with the return shipping information IResponse <Ticket> updateTicketResponse = client.Tickets.Get(createdTicketID.Value); ticketReponse = updateTicketResponse.Item; updateNewTicket = ticketReponse; //UpdateZendeskTicketWithPDFFile(updateTicketID, file, rmaNo, amazonBucketURL, fileAttached); TicketComment comment = new TicketComment { IsPublic = true, Type = TicketEventType.Comment, Id = createdTicketID }; if (fileAttached) { IResponse <Upload> response = client.Upload.Post(new UploadRequest { Item = file }); uploadToken = response.Item.Token; comment.AddAttachmentToComment(uploadToken); comment.HtmlBody = @"Hello, <br/><br/> Your return request has been approved. Your Return Merchandise Authorization number is " + rmaNo + @". <br/><br/>"; if (validURL) { comment.HtmlBody += @"Please see attached document for return instructions and shipping label. Alternatively <a href = '" + amazonBucketURL + @"'> Click Here </a> to download your return instructions and shipping label manually. <br/><br/>"; } comment.HtmlBody += @"IMPORTANT: Please remove ALL locks and passwords. Any device(s) received locked with your information will be denied, returned at your expense with no refund submitted for processing. <br/><br/> Thank You"; } else if (validURL) { comment.HtmlBody = @"Hello, <br/><br/> Your return request has been approved. Your Return Merchandise Authorization number is " + rmaNo + @". <br/><br/> <a href='" + amazonBucketURL + @"'>Click Here</a> to download your return instructions and shipping label. <br/><br/> IMPORTANT: Please remove ALL locks and passwords. Any device(s) received locked with your information will be denied, returned at your expense with no refund submitted for processing. <br/><br/> Thank You"; } updateNewTicket.Comment = comment; updateNewTicket.Status = TicketStatus.Solved; client.Tickets.Put(new TicketRequest { Item = updateNewTicket }); return(createdTicketID); }
public void UpdateZendeskTicketWithPDFFile(long ticketNo, MemoryFile file, string rmaNo, string amazonBucketURL, bool fileAttached, bool validURL) { ConnectToZendesk(); IResponse <Ticket> ticketResponse = client.Tickets.Get(ticketNo); Ticket ticket = ticketResponse.Item; Ticket newTicket = ticket; TicketComment newComment = new TicketComment { Id = ticketNo }; if (fileAttached) { string uploadToken = string.Empty; IResponse <Upload> response = client.Upload.Post(new UploadRequest { Item = file }); uploadToken = response.Item.Token; newComment.AddAttachmentToComment(uploadToken); newComment.HtmlBody = @"Hello, <br/><br/> Your return request has been approved. Your Return Merchandise Authorization number is " + rmaNo + @". <br/><br/>"; if (validURL) { newComment.HtmlBody += @"Please see attached document for return instructions and shipping label. Alternatively <a href = '" + amazonBucketURL + @"'> Click Here </a> to download your return instructions and shipping label manually. <br/><br/>"; } newComment.HtmlBody += @"IMPORTANT: Please remove ALL locks and passwords. Any device(s) received locked with your information will be denied, returned at your expense with no refund submitted for processing. <br/><br/> Thank You"; } else if (validURL) { newComment.HtmlBody = @"Hello, <br/><br/> Your return request has been approved. Your Return Merchandise Authorization number is " + rmaNo + @". <br/><br/> <a href='" + amazonBucketURL + @"'>Click Here</a> to download your return instructions and shipping label. <br/><br/> IMPORTANT: Please remove ALL locks and passwords. Any device(s) received locked with your information will be denied, returned at your expense with no refund submitted for processing. <br/><br/> Thank You"; } newComment.IsPublic = true; newComment.Type = TicketEventType.Comment; newTicket.Comment = newComment; newTicket.Status = TicketStatus.Solved; client.Tickets.Put(new TicketRequest { Item = newTicket }); }