Ejemplo n.º 1
0
        public void PostCategoriesChangesTest()
        {
            PostCategoriesChangesRequest request = new PostCategoriesChangesRequest(GetComparisonRequest("source.docx", new List <string> {
                "target.docx"
            }));
            var response = ChangesApi.PostCategoriesChanges(request);

            Assert.IsInstanceOf <List <ComparisonChangesCategoryDto> >(response, "response is List<ComparisonChangesCategoryDto>");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Posts the categories changes.
        /// </summary>
        /// <param name="request">Request. <see cref="PostCategoriesChangesRequest" /></param>
        /// <returns><see cref="List<ComparisonChangesCategoryDto>"/></returns>
        public List <ComparisonChangesCategoryDto> PostCategoriesChanges(PostCategoriesChangesRequest request)
        {
            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/comparison/compareDocuments/changes/categories";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "categoriesType", request.CategoriesType);
            var postBody = SerializationHelper.Serialize(request.Request); // http body (model) parameter

            try
            {
                var response = this.apiInvoker.InvokeApi(
                    resourcePath,
                    "POST",
                    postBody,
                    null,
                    null);
                if (response != null)
                {
                    return((List <ComparisonChangesCategoryDto>)SerializationHelper.Deserialize(response, typeof(List <ComparisonChangesCategoryDto>)));
                }

                return(null);
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }

                throw;
            }
        }