public void GetAllTicketNotes() { DepartmentCollection depts = TestSetup.KayakoApiService.Departments.GetDepartments(); TicketCollection tickets = TestSetup.KayakoApiService.Tickets.GetTickets(depts.Select(d => d.Id).ToArray()); Ticket randomTicket = tickets[new Random().Next(tickets.Count)]; TicketNoteCollection notes = TestSetup.KayakoApiService.Tickets.GetTicketNotes(randomTicket.Id); //Assert.IsNotNull(notes, "No ticket notes were returned for ticket id " + randomTicket.Id); //Assert.IsNotEmpty(notes, "No ticket notes were returned for ticket id " + randomTicket.Id); }
/// <summary> /// Retrieve the note identified by <paramref name="noteId"/> that belongs to a ticket identified by <paramref name="ticketId"/>. /// </summary> /// <param name="ticketId">The unique numeric identifier of the ticket.</param> /// <param name="noteId">The unique numeric identifier of the ticket note.</param> /// <returns>List of ticket notes</returns> public TicketNote GetTicketNote(int ticketId, int noteId) { string apiMethod = String.Format("/Tickets/TicketNote/{0}/{1}/", ticketId, noteId); TicketNoteCollection notes = Connector.ExecuteGet <TicketNoteCollection>(apiMethod); if (notes != null && notes.Count > 0) { return(notes[0]); } return(null); }
///// <summary> ///// Add a new note to a ticket. ///// </summary> ///// <remarks> ///// http://wiki.kayako.com/display/DEV/REST+-+TicketNote#REST-TicketNote-POST%2FTickets%2FTicketNote</remarks> ///// <returns>The added ticket note.</returns> public TicketNote AddTicketNote(TicketNoteRequest request) { string apiMethod = "/Tickets/TicketNote"; request.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("contents", request.Content); parameters.AppendRequestData("notecolor", (int)request.NoteColor); if (request.FullName == null && request.StaffId == null) { throw new ArgumentException("Neither FullName nor StaffId are set, one of these fields are required field and cannot be null."); } if (request.FullName != null && request.StaffId != null) { throw new ArgumentException("FullName are StaffId are both set, only one of these fields must be set."); } if (request.FullName != null) { parameters.AppendRequestData("fullname", request.FullName); } if (request.StaffId != null) { parameters.AppendRequestData("staffid", request.StaffId.Value); } if (request.ForStaffId != null) { parameters.AppendRequestData("forstaffid", request.ForStaffId.Value); } TicketNoteCollection notes = Connector.ExecutePost <TicketNoteCollection>(apiMethod, parameters.ToString()); if (notes.Count > 0) { return(notes[0]); } return(null); }
public void GetTicketNote() { DepartmentCollection depts = TestSetup.KayakoApiService.Departments.GetDepartments(); TicketCollection tickets = TestSetup.KayakoApiService.Tickets.GetTickets(depts.Select(d => d.Id).ToArray()); Ticket randomTicket = tickets[new Random().Next(tickets.Count)]; TicketNoteCollection notes = TestSetup.KayakoApiService.Tickets.GetTicketNotes(randomTicket.Id); Assert.IsNotNull(notes, "No ticket notes were returned for ticket id " + randomTicket.Id); Assert.IsNotEmpty(notes, "No ticket notes were returned for ticket id " + randomTicket.Id); TicketNote randomTicketNoteToGet = notes[new Random().Next(notes.Count)]; Trace.WriteLine("GetTicketNote using ticket note id: " + randomTicketNoteToGet.Id); TicketNote ticketNote = TestSetup.KayakoApiService.Tickets.GetTicketNote(randomTicket.Id, randomTicketNoteToGet.Id); CompareTicketNote(ticketNote, randomTicketNoteToGet); }