コード例 #1
0
        public void CreateTroubleshooterCategory()
        {
            var troubleshooterCategoryRequest = new TroubleshooterCategoryRequest
            {
                Title = "TitleCategory",
                CategoryType = TroubleshooterCategoryType.Private,
                StaffId = 2,
                DisplayOrder = 1,
                Description = "Description",
                UserVisibilityCustom = true,
                UserGroupIdList = new [] { 1, 2, 3 },
                StaffVisibilityCustom = true,
                StaffGroupIdList = new [] { 3, 4, 5}
            };

            const string apiMethod = "/Troubleshooter/Category";
            const string parameters = "title=TitleCategory&categorytype=3&staffid=2&displayorder=1&description=Description&uservisibilitycustom=1&usergroupidlist=1,2,3&staffvisibilitycustom=1&staffgroupidlist=3,4,5";

            _kayakoApiRequest.Setup(x => x.ExecutePost<TroubleshooterCategoryCollection>(apiMethod, parameters)).Returns(_responseTroubleshooterCategoryCollection);

            var troubleshooterCategory = _troubleshooterController.CreateTroubleshooterCategory(troubleshooterCategoryRequest);

            _kayakoApiRequest.Verify(x => x.ExecutePost<TroubleshooterCategoryCollection>(apiMethod, parameters), Times.Once());
            Assert.That(troubleshooterCategory, Is.EqualTo(_responseTroubleshooterCategoryCollection.FirstOrDefault()));
        }
コード例 #2
0
        public void CreateUpdateDeleteNewsCategory()
        {
            TroubleshooterCategoryRequest troubleshooterCategoryRequest = new TroubleshooterCategoryRequest
                {
                    Title = "Troubleshooter Category Request",
                    CategoryType = TroubleshooterCategoryType.Public,
                    StaffId = 1,
                    DisplayOrder = 5,
                    Description = "Description of Troubleshooter Category Request",
                    UserVisibilityCustom = false,
                    StaffVisibilityCustom = false
                };

            var troubleshooterCategory = TestSetup.KayakoApiService.Troubleshooter.CreateTroubleshooterCategory(troubleshooterCategoryRequest);

            Assert.IsNotNull(troubleshooterCategory);
            Assert.That(troubleshooterCategory.Title, Is.EqualTo(troubleshooterCategoryRequest.Title));
            Assert.That(troubleshooterCategory.CategoryType, Is.EqualTo(troubleshooterCategoryRequest.CategoryType));
            Assert.That(troubleshooterCategory.StaffId, Is.EqualTo(troubleshooterCategoryRequest.StaffId));
            Assert.That(troubleshooterCategory.DisplayOrder, Is.EqualTo(troubleshooterCategoryRequest.DisplayOrder));
            Assert.That(troubleshooterCategory.Description, Is.EqualTo(troubleshooterCategoryRequest.Description));
            Assert.That(troubleshooterCategory.UserVisibilityCustom, Is.EqualTo(troubleshooterCategoryRequest.UserVisibilityCustom));
            Assert.That(troubleshooterCategory.StaffVisibilityCustom, Is.EqualTo(troubleshooterCategoryRequest.StaffVisibilityCustom));

            troubleshooterCategoryRequest.Id = troubleshooterCategory.Id;
            troubleshooterCategoryRequest.Title += "_Title";
            troubleshooterCategoryRequest.Description += "_Updated";

            troubleshooterCategory = TestSetup.KayakoApiService.Troubleshooter.UpdateTroubleshooterCategory(troubleshooterCategoryRequest);

            Assert.IsNotNull(troubleshooterCategory);
            Assert.That(troubleshooterCategory.Title, Is.EqualTo(troubleshooterCategoryRequest.Title));
            Assert.That(troubleshooterCategory.Description, Is.EqualTo(troubleshooterCategoryRequest.Description));

            var deleteResult = TestSetup.KayakoApiService.Troubleshooter.DeleteTroubleshooterCategory(troubleshooterCategoryRequest.Id);
            Assert.IsTrue(deleteResult);
        }
コード例 #3
0
		public TroubleshooterCategory CreateTroubleshooterCategory(TroubleshooterCategoryRequest troubleshooterCategoryRequest)
		{
			RequestBodyBuilder parameters = PopulateRequestParameters(troubleshooterCategoryRequest, RequestTypes.Create);

			TroubleshooterCategoryCollection troubleshooterCategories = Connector.ExecutePost<TroubleshooterCategoryCollection>(TroubleshooterCategoryBaseUrl, parameters.ToString());

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

			return null;
		}
コード例 #4
0
		private RequestBodyBuilder PopulateRequestParameters(TroubleshooterCategoryRequest troubleshooterCategoryRequest, RequestTypes requestType)
		{
			troubleshooterCategoryRequest.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();
			parameters.AppendRequestDataNonEmptyString("title", troubleshooterCategoryRequest.Title);
			parameters.AppendRequestData("categorytype", EnumUtility.ToApiString(troubleshooterCategoryRequest.CategoryType));

			if (requestType == RequestTypes.Create)
			{
				parameters.AppendRequestDataNonNegativeInt("staffid", troubleshooterCategoryRequest.StaffId);
			}

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

			parameters.AppendRequestDataNonEmptyString("description", troubleshooterCategoryRequest.Description);
			parameters.AppendRequestDataBool("uservisibilitycustom", troubleshooterCategoryRequest.UserVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", troubleshooterCategoryRequest.UserGroupIdList);
			parameters.AppendRequestDataBool("staffvisibilitycustom", troubleshooterCategoryRequest.StaffVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", troubleshooterCategoryRequest.StaffGroupIdList);

			return parameters;
		}
コード例 #5
0
		public TroubleshooterCategory UpdateTroubleshooterCategory(TroubleshooterCategoryRequest troubleshooterCategoryRequest)
		{
			string apiMethod = String.Format("{0}/{1}", TroubleshooterCategoryBaseUrl, troubleshooterCategoryRequest.Id);
			RequestBodyBuilder parameters = PopulateRequestParameters(troubleshooterCategoryRequest, RequestTypes.Update);

			TroubleshooterCategoryCollection troubleshooterCategories = Connector.ExecutePut<TroubleshooterCategoryCollection>(apiMethod, parameters.ToString());

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

			return null;
		}
 public static TroubleshooterCategory ToResponseData(TroubleshooterCategoryRequest requestData) => ToResponseType <TroubleshooterCategoryRequest, TroubleshooterCategory>(requestData);
コード例 #7
0
		public static TroubleshooterCategory ToResponseData(TroubleshooterCategoryRequest requestData)
		{
			return ToResponseType<TroubleshooterCategoryRequest, TroubleshooterCategory>(requestData);
		}