Ejemplo n.º 1
0
        /// <summary>
        /// Update the properties of a defined category or move it to another location in the category hierarchy. Because this operation replaces the defined resource,include all the information to maintain for the category in the request.
        /// <example>
        ///  <code>
        /// var result = CategoryFactory.UpdateCategory(handler : handler,  category :  category,  categoryId :  categoryId,  cascadeVisibility :  cascadeVisibility,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<Category/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.ProductAdmin.Category UpdateCategory(ServiceClientMessageHandler handler,
                                                                              Mozu.Api.Contracts.ProductAdmin.Category category, int categoryId, bool?cascadeVisibility = null, string responseFields = null,
                                                                              HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
        {
            SetSdKparameters();
            var currentClassName  = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.WriteLine(currentMethodName + '.' + currentMethodName);
            var apiClient = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.UpdateCategoryClient(
                category:  category, categoryId:  categoryId, cascadeVisibility:  cascadeVisibility, responseFields:  responseFields);

            try
            {
                apiClient.WithContext(handler.ApiContext).Execute();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                {
                    throw customException;
                }
                return(null);
            }
            return(ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                                         ? (apiClient.Result())
                                         : null);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = CategoryFactory.AddCategory(handler : handler,  category :  category,  incrementSequence :  incrementSequence,  useProvidedId :  useProvidedId,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<Category/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.ProductAdmin.Category AddCategory(ServiceClientMessageHandler handler,
                                                                           Mozu.Api.Contracts.ProductAdmin.Category category, bool?incrementSequence = null, bool?useProvidedId = null, string responseFields = null,
                                                                           HttpStatusCode expectedCode = HttpStatusCode.Created, HttpStatusCode successCode = HttpStatusCode.Created)
        {
            SetSdKparameters();
            var currentClassName  = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.WriteLine(currentMethodName + '.' + currentMethodName);
            var apiClient = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.AddCategoryClient(
                category:  category, incrementSequence:  incrementSequence, useProvidedId:  useProvidedId, responseFields:  responseFields);

            try
            {
                apiClient.WithContext(handler.ApiContext).ExecuteAsync(default(CancellationToken)).Wait();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                {
                    throw customException;
                }
                return(null);
            }
            return(ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                                         ? (apiClient.Result())
                                         : null);
        }
Ejemplo n.º 3
0
	    public static string GetCategoryUrl(Site site, Category category)
	    {
	        var domain = GetSiteDomain(site);

	        return String.IsNullOrEmpty(category.Content.Slug) ? 
                string.Format("https://{0}/c/{1}", domain, category.Id) : 
                string.Format("https://{0}/{1}/c/{2}", domain,category.Content.Slug, category.Id);
	    }
Ejemplo n.º 4
0
        public static string GetCategoryUrl(Site site, Category category)
        {
            var domain = GetSiteDomain(site);

            return(String.IsNullOrEmpty(category.Content.Slug) ?
                   string.Format("https://{0}/c/{1}", domain, category.Id) :
                   string.Format("https://{0}/{1}/c/{2}", domain, category.Content.Slug, category.Id));
        }
Ejemplo n.º 5
0
        public virtual Mozu.Api.Contracts.ProductAdmin.Category UpdateCategory(Mozu.Api.Contracts.ProductAdmin.Category category, int categoryId, bool?cascadeVisibility = null, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.UpdateCategoryClient(category, categoryId, cascadeVisibility, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
Ejemplo n.º 6
0
        public virtual Mozu.Api.Contracts.ProductAdmin.Category AddCategory(Mozu.Api.Contracts.ProductAdmin.Category category, bool?incrementSequence = null, bool?useProvidedId = null, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.AddCategoryClient(category, incrementSequence, useProvidedId, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cascadeVisibility">If true, when changing the display option for the category, change it for all subcategories also. The default value is false.</param>
        /// <param name="categoryId">Unique identifier of the category to modify.</param>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="category">A descriptive container that groups products. A category is merchant defined with associated products and discounts as configured. GThe storefront displays products in a hierarchy of categories. As such, categories can include a nesting of sub-categories to organize products and product options per set guidelines such as color, brand, material, and size.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ProductAdmin.Category"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var category = new Category();
        ///   var category = await category.UpdateCategoryAsync( category,  categoryId,  cascadeVisibility,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ProductAdmin.Category> UpdateCategoryAsync(Mozu.Api.Contracts.ProductAdmin.Category category, int categoryId, bool?cascadeVisibility = null, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.UpdateCategoryClient(category, categoryId, cascadeVisibility, responseFields);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync(ct).ConfigureAwait(false);

            return(await response.ResultAsync());
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="incrementSequence">If true, when adding a new product category, set the sequence number of the new category to an increment of one integer greater than the maximum available sequence number across all product categories. If false, set the sequence number to zero.</param>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="useProvidedId">Optional. If ,  uses the  you specify in the request as the category's id. If ,  generates an  for the category regardless if you specify an id in the request.If you specify an id already in use and set this parameter to ,  returns an error.</param>
        /// <param name="category">A descriptive container that groups products. A category is merchant defined with associated products and discounts as configured. GThe storefront displays products in a hierarchy of categories. As such, categories can include a nesting of sub-categories to organize products and product options per set guidelines such as color, brand, material, and size.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ProductAdmin.Category"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var category = new Category();
        ///   var category = await category.AddCategoryAsync( category,  incrementSequence,  useProvidedId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ProductAdmin.Category> AddCategoryAsync(Mozu.Api.Contracts.ProductAdmin.Category category, bool?incrementSequence = null, bool?useProvidedId = null, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.AddCategoryClient(category, incrementSequence, useProvidedId, responseFields);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync(ct).ConfigureAwait(false);

            return(await response.ResultAsync());
        }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cascadeVisibility">If true, when changing the display option for the category, change it for all subcategories also. The default value is false.</param>
        /// <param name="categoryId">Unique identifier of the category to modify.</param>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="category">A descriptive container that groups products. A category is merchant defined with associated products and discounts as configured. GThe storefront displays products in a hierarchy of categories. As such, categories can include a nesting of sub-categories to organize products and product options per set guidelines such as color, brand, material, and size.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.ProductAdmin.Category"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=UpdateCategory( category,  categoryId,  cascadeVisibility,  responseFields);
        ///   var categoryClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> UpdateCategoryClient(Mozu.Api.Contracts.ProductAdmin.Category category, int categoryId, bool?cascadeVisibility = null, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Catalog.Admin.CategoryUrl.UpdateCategoryUrl(categoryId, cascadeVisibility, responseFields);
            const string verb       = "PUT";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.ProductAdmin.Category>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ProductAdmin.Category>(category);

            return(mozuClient);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="incrementSequence">If true, when adding a new product category, set the sequence number of the new category to an increment of one integer greater than the maximum available sequence number across all product categories. If false, set the sequence number to zero.</param>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="useProvidedId">Optional. If ,  uses the  you specify in the request as the category's id. If ,  generates an  for the category regardless if you specify an id in the request.If you specify an id already in use and set this parameter to ,  returns an error.</param>
        /// <param name="category">A descriptive container that groups products. A category is merchant defined with associated products and discounts as configured. GThe storefront displays products in a hierarchy of categories. As such, categories can include a nesting of sub-categories to organize products and product options per set guidelines such as color, brand, material, and size.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.ProductAdmin.Category"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=AddCategory( category,  incrementSequence,  useProvidedId,  responseFields);
        ///   var categoryClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> AddCategoryClient(Mozu.Api.Contracts.ProductAdmin.Category category, bool?incrementSequence = null, bool?useProvidedId = null, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Catalog.Admin.CategoryUrl.AddCategoryUrl(incrementSequence, useProvidedId, responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.ProductAdmin.Category>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ProductAdmin.Category>(category);

            return(mozuClient);
        }
Ejemplo n.º 11
0
 public static string GetCategoryUrl(int tenantId, int siteId, Category category)
 {
     var site = GetSite(tenantId, siteId);
     return GetCategoryUrl(site, category);
 }
Ejemplo n.º 12
0
        public static string GetCategoryUrl(int tenantId, int siteId, Category category)
        {
            var site = GetSite(tenantId, siteId);

            return(GetCategoryUrl(site, category));
        }
Ejemplo n.º 13
0
        public static async Task <string> GetCategoryUrl(int tenantId, int siteId, Category category)
        {
            var site = await GetSite(tenantId, siteId).ConfigureAwait(false);

            return(GetCategoryUrl(site, category));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Adds a new category to the site's category hierarchy. Specify a ParentCategoryID to determine where to place the category in the hierarchy. If no ParentCategoryID is specified, the new category is a top-level category.
        /// </summary>
        /// <param name="incrementSequence">If true, when adding a new product category, set the sequence number of the new category to an increment of one integer greater than the maximum available sequence number across all product categories. If false, set the sequence number to zero.</param>
        /// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
        /// <param name="category">A descriptive container that groups products. A category is merchant defined with associated products and discounts as configured. GThe storefront displays products in a hierarchy of categories. As such, categories can include a nesting of sub-categories to organize products and product options per set guidelines such as color, brand, material, and size.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ProductAdmin.Category"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var category = new Category();
        ///   var category = await category.AddCategoryAsync( category,  incrementSequence,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ProductAdmin.Category> AddCategoryAsync(Mozu.Api.Contracts.ProductAdmin.Category category, bool?incrementSequence = null, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.Category> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.CategoryClient.AddCategoryClient(category, incrementSequence, responseFields);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync();

            return(await response.ResultAsync());
        }