public void GetAllTicketAttachments() { DepartmentCollection depts = TestSetup.KayakoApiService.Departments.GetDepartments(); Ticket ticket = TestSetup.KayakoApiService.Tickets.GetTicket(1); TicketAttachmentCollection attachments = TestSetup.KayakoApiService.Tickets.GetTicketAttachments(ticket.Id); Assert.IsNotNull(attachments, "No ticket attachments were returned for ticket id " + ticket.Id); Assert.IsNotEmpty(attachments, "No ticket attachments were returned for ticket id " + ticket.Id); }
public TicketAttachment GetTicketAttachment(int ticketId, int attachmentId) { string apiMethod = String.Format("/Tickets/TicketAttachment/{0}/{1}", ticketId, attachmentId); TicketAttachmentCollection attachments = Connector.ExecuteGet <TicketAttachmentCollection>(apiMethod); if (attachments != null && attachments.Count > 0) { return(attachments[0]); } return(null); }
public void GetTicketAttachment() { DepartmentCollection depts = TestSetup.KayakoApiService.Departments.GetDepartments(); Ticket ticket = TestSetup.KayakoApiService.Tickets.GetTicket(1); TicketAttachmentCollection attachments = TestSetup.KayakoApiService.Tickets.GetTicketAttachments(ticket.Id); Assert.IsNotNull(attachments, "No ticket attachments were returned for ticket id " + ticket.Id); Assert.IsNotEmpty(attachments, "No ticket attachments were returned for ticket id " + ticket.Id); TicketAttachment randomTicketAttachmentToGet = attachments[new Random().Next(attachments.Count)]; Trace.WriteLine("GetTicketAttachment using ticket attachment id: " + randomTicketAttachmentToGet.Id); TicketAttachment ticketNote = TestSetup.KayakoApiService.Tickets.GetTicketAttachment(ticket.Id, randomTicketAttachmentToGet.Id); CompareTicketAttachment(ticketNote, randomTicketAttachmentToGet); }
/// <summary> /// Add an attachment to a ticket post. /// </summary> /// <param name="ticketId">The unique numeric identifier of the ticket</param> /// <param name="ticketPostId">The unique numeric identifier of the ticket post</param> /// <param name="fileName">The file name for the attachment </param> /// <param name="contents">The BASE64 encoded attachment contents</param> public TicketAttachment AddTicketAttachment(TicketAttachmentRequest request) { string apiMethod = "/Tickets/TicketAttachment"; request.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("ticketpostid", request.TicketPostId); parameters.AppendRequestData("filename", request.FileName); parameters.AppendRequestData("contents", request.Contents); TicketAttachmentCollection attachments = Connector.ExecutePost <TicketAttachmentCollection>(apiMethod, parameters.ToString()); if (attachments != null && attachments.Count > 0) { return(attachments[0]); } return(null); }