コード例 #1
0
        public void CreateDeleteTicketPosts()
        {
            DepartmentCollection depts = TestSetup.KayakoApiService.Departments.GetDepartments();
            StaffUserCollection staff = TestSetup.KayakoApiService.Staff.GetStaffUsers();
            StaffUser randomStaffUser = staff[new Random().Next(staff.Count)];
            TicketCollection tickets = TestSetup.KayakoApiService.Tickets.GetTickets(depts.Select(d => d.Id).ToArray());
            Ticket randomTicket = tickets[new Random().Next(tickets.Count)];

            string contents = "This will be the contents";

            TicketNoteRequest request = new TicketNoteRequest()
            {
                TicketId = randomTicket.Id,
                Content = contents,
                StaffId = randomStaffUser.Id,
                ForStaffId = randomStaffUser.Id,
                NoteColor = NoteColor.Purple
            };

            TicketNote createdNote = TestSetup.KayakoApiService.Tickets.AddTicketNote(request);

            Assert.IsNotNull(createdNote);
            Assert.AreEqual(createdNote.Content, contents);
            Assert.AreEqual(createdNote.ForStaffId, randomStaffUser.Id);
            //Assert.AreEqual(createdNote.CreatorStaffId, randomStaffUser.Id);
            Assert.AreEqual(createdNote.NoteColor, NoteColor.Purple);
            Assert.AreEqual(createdNote.TicketId, randomTicket.Id);

            bool success = TestSetup.KayakoApiService.Tickets.DeleteTicketNote(randomTicket.Id, createdNote.Id);

            Assert.IsTrue(success);
        }
コード例 #2
0
 public static TicketNote ToResponseData(TicketNoteRequest requestData)
 {
     return TicketNoteRequest.ToResponseType<TicketNoteRequest, TicketNote>(requestData);
 }
コード例 #3
0
 public static TicketNote ToResponseData(TicketNoteRequest requestData)
 {
     return(TicketNoteRequest.ToResponseType <TicketNoteRequest, TicketNote>(requestData));
 }
コード例 #4
0
        ///// <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;
		}
コード例 #5
0
 public static TicketNoteRequest FromResponseData(TicketNote responseData)
 {
     return(TicketNoteRequest.FromResponseType <TicketNote, TicketNoteRequest>(responseData));
 }