public void CreateUpdateDeleteNewsStep()
        {
            TroubleshooterStepRequest troubleshooterStepRequest = new TroubleshooterStepRequest
                {
                    CategoryId = 1,
                    Subject = "Subject",
                    Contents = "Contents",
                    StaffId = 1,
                    DisplayOrder = 23,
                    AllowComments = true,
                    EnableTicketRedirection = false,
                    RedirectDepartmentId = 1,
                    TicketTypeId = 1,
                    TicketPriorityId = 1,
                    TicketSubject = "TicketSubject",
                    StepStatus = TroubleshooterStepStatus.Draft,
                    ParentStepIdList = new [] { 0 }
                };

            var troubleshooterStep = TestSetup.KayakoApiService.Troubleshooter.CreateTroubleshooterStep(troubleshooterStepRequest);

            Assert.IsNotNull(troubleshooterStep);
            Assert.That(troubleshooterStep.CategoryId, Is.EqualTo(troubleshooterStepRequest.CategoryId));
            Assert.That(troubleshooterStep.Subject, Is.EqualTo(troubleshooterStepRequest.Subject));
            Assert.That(troubleshooterStep.Contents, Is.EqualTo(troubleshooterStepRequest.Contents));
            Assert.That(troubleshooterStep.StaffId, Is.EqualTo(troubleshooterStepRequest.StaffId));
            Assert.That(troubleshooterStep.DisplayOrder, Is.EqualTo(troubleshooterStepRequest.DisplayOrder));
            Assert.That(troubleshooterStep.AllowComments, Is.EqualTo(troubleshooterStepRequest.AllowComments));
            Assert.That(troubleshooterStep.RedirectTickets, Is.EqualTo(troubleshooterStepRequest.EnableTicketRedirection));
            Assert.That(troubleshooterStep.RedirectDepartmentId, Is.EqualTo(troubleshooterStepRequest.RedirectDepartmentId));
            Assert.That(troubleshooterStep.TicketTypeId, Is.EqualTo(troubleshooterStepRequest.TicketTypeId));
            Assert.That(troubleshooterStep.TicketPriorityId, Is.EqualTo(troubleshooterStepRequest.TicketPriorityId));
            //Assert.That(troubleshooterStep.TicketSubject, Is.EqualTo(troubleshooterStepRequest.TicketSubject));
            Assert.That(troubleshooterStep.ParentSteps, Is.EqualTo(troubleshooterStepRequest.ParentStepIdList));

            troubleshooterStepRequest.Id = troubleshooterStep.Id;
            troubleshooterStepRequest.Subject += "_Title";
            troubleshooterStepRequest.DisplayOrder = 21;

            troubleshooterStep = TestSetup.KayakoApiService.Troubleshooter.UpdateTroubleshooterStep(troubleshooterStepRequest);

            Assert.IsNotNull(troubleshooterStep);
            Assert.That(troubleshooterStep.Subject, Is.EqualTo(troubleshooterStepRequest.Subject));
            Assert.That(troubleshooterStep.DisplayOrder, Is.EqualTo(troubleshooterStepRequest.DisplayOrder));

            var deleteResult = TestSetup.KayakoApiService.Troubleshooter.DeleteTroubleshooterStep(troubleshooterStepRequest.Id);
            Assert.IsTrue(deleteResult);
        }
        public void UpdateTroubleshooterStep()
        {
            var troubleshooterStepRequest = new TroubleshooterStepRequest
            {
                StaffId = 3,
                Subject = "Subject",
                Contents = "Contents",
                DisplayOrder = 4,
                AllowComments = true,
                EnableTicketRedirection = false,
                RedirectDepartmentId = 3,
                TicketTypeId = 1,
                TicketPriorityId = 3,
                TicketSubject = "Ticket Subject",
                StepStatus = TroubleshooterStepStatus.Published,
                ParentStepIdList = new [] { 1, 3, 5 }
            };

            var apiMethod = string.Format("/Troubleshooter/Step/{0}", troubleshooterStepRequest.Id);
            const string parameters = "subject=Subject&contents=Contents&editedstaffid=3&displayorder=4&allowcomments=1&enableticketredirection=0&redirectdepartmentid=3&tickettypeid=1&ticketpriorityid=3&ticketsubject=Ticket Subject&stepstatus=1&parentstepidlist=1,3,5";

            _kayakoApiRequest.Setup(x => x.ExecutePut<TroubleshooterStepCollection>(apiMethod, parameters)).Returns(_responseTroubleshooterStepCollection);

            var troubleshooterStep = _troubleshooterController.UpdateTroubleshooterStep(troubleshooterStepRequest);

            _kayakoApiRequest.Verify(x => x.ExecutePut<TroubleshooterStepCollection>(apiMethod, parameters), Times.Once());
            Assert.That(troubleshooterStep, Is.EqualTo(_responseTroubleshooterStepCollection.FirstOrDefault()));
        }
        public void CreateTroubleshooterStep()
        {
            var troubleshooterStepRequest = new TroubleshooterStepRequest
            {
                CategoryId = 1,
                Subject = "Subject",
                Contents = "Contents",
                StaffId = 3,
                DisplayOrder = 15,
                AllowComments = true,
                EnableTicketRedirection = false,
                RedirectDepartmentId = 4,
                TicketTypeId = 4,
                TicketPriorityId = 2,
                TicketSubject = "Ticket Subject",
                StepStatus = TroubleshooterStepStatus.Published,
                ParentStepIdList = new [] { 1, 2, 3 }
            };

            const string apiMethod = "/Troubleshooter/Step";
            const string parameters = "categoryid=1&subject=Subject&contents=Contents&staffid=3&displayorder=15&allowcomments=1&enableticketredirection=0&redirectdepartmentid=4&tickettypeid=4&ticketpriorityid=2&ticketsubject=Ticket Subject&stepstatus=1&parentstepidlist=1,2,3";

            _kayakoApiRequest.Setup(x => x.ExecutePost<TroubleshooterStepCollection>(apiMethod, parameters)).Returns(_responseTroubleshooterStepCollection);

            var troubleshooterStep = _troubleshooterController.CreateTroubleshooterStep(troubleshooterStepRequest);

            _kayakoApiRequest.Verify(x => x.ExecutePost<TroubleshooterStepCollection>(apiMethod, parameters), Times.Once());
            Assert.That(troubleshooterStep, Is.EqualTo(_responseTroubleshooterStepCollection.FirstOrDefault()));
        }
		private RequestBodyBuilder PopulateRequestParameters(TroubleshooterStepRequest troubleshooterStepRequest, RequestTypes requestType)
		{
			troubleshooterStepRequest.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();

			if (requestType == RequestTypes.Create)
			{
				parameters.AppendRequestData("categoryid", troubleshooterStepRequest.CategoryId);
			}

			parameters.AppendRequestDataNonEmptyString("subject", troubleshooterStepRequest.Subject);
			parameters.AppendRequestDataNonEmptyString("contents", troubleshooterStepRequest.Contents);

			parameters.AppendRequestDataNonNegativeInt(requestType == RequestTypes.Create ? "staffid" : "editedstaffid",
			                                           troubleshooterStepRequest.StaffId);

			if (troubleshooterStepRequest.DisplayOrder.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("displayorder", troubleshooterStepRequest.DisplayOrder.Value);
			}

			parameters.AppendRequestDataBool("allowcomments", troubleshooterStepRequest.AllowComments);
			parameters.AppendRequestDataBool("enableticketredirection", troubleshooterStepRequest.EnableTicketRedirection);

			if (troubleshooterStepRequest.RedirectDepartmentId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("redirectdepartmentid", troubleshooterStepRequest.RedirectDepartmentId.Value);
			}

			if (troubleshooterStepRequest.TicketTypeId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("tickettypeid", troubleshooterStepRequest.TicketTypeId.Value);
			}

			if(troubleshooterStepRequest.TicketPriorityId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("ticketpriorityid", troubleshooterStepRequest.TicketPriorityId.Value);
			}

			parameters.AppendRequestDataNonEmptyString("ticketsubject", troubleshooterStepRequest.TicketSubject);
			
			if (troubleshooterStepRequest.StepStatus.HasValue)
			{
				parameters.AppendRequestData("stepstatus", EnumUtility.ToApiString(troubleshooterStepRequest.StepStatus.Value));
			}

			parameters.AppendRequestDataArrayCommaSeparated("parentstepidlist", troubleshooterStepRequest.ParentStepIdList);

			return parameters;
		}
		public TroubleshooterStep UpdateTroubleshooterStep(TroubleshooterStepRequest troubleshooterStepRequest)
		{
			string apiMethod = String.Format("{0}/{1}", TroubleshooterStepBaseUrl, troubleshooterStepRequest.Id);
			RequestBodyBuilder parameters = PopulateRequestParameters(troubleshooterStepRequest, RequestTypes.Update);

			TroubleshooterStepCollection troubleshooterStep = Connector.ExecutePut<TroubleshooterStepCollection>(apiMethod, parameters.ToString());

			if (troubleshooterStep != null && troubleshooterStep.Count > 0)
			{
				return troubleshooterStep[0];
			}

			return null;
		}
		public TroubleshooterStep CreateTroubleshooterStep(TroubleshooterStepRequest troubleshooterStepRequest)
		{
			RequestBodyBuilder parameters = PopulateRequestParameters(troubleshooterStepRequest, RequestTypes.Create);

			TroubleshooterStepCollection troubleshooterSteps = Connector.ExecutePost<TroubleshooterStepCollection>(TroubleshooterStepBaseUrl, parameters.ToString());

			if (troubleshooterSteps != null && troubleshooterSteps.Count > 0)
			{
				return troubleshooterSteps[0];
			}

			return null;
		}
예제 #7
0
 public static TroubleshooterStep ToResponseData(TroubleshooterStepRequest requestData) => ToResponseType <TroubleshooterStepRequest, TroubleshooterStep>(requestData);
		public static TroubleshooterStep ToResponseData(TroubleshooterStepRequest requestData)
		{
			return ToResponseType<TroubleshooterStepRequest, TroubleshooterStep>(requestData);
		}
예제 #9
0
 public static TroubleshooterStep ToResponseData(TroubleshooterStepRequest requestData)
 {
     return(ToResponseType <TroubleshooterStepRequest, TroubleshooterStep>(requestData));
 }