Пример #1
0
        /// <summary>
        /// Evaluates whether a collection of discounts specified in the request can be redeemed for the supplied product code.
        /// <example>
        ///  <code>
        /// var result = ProductRuntimeFactory.ValidateDiscounts(handler : handler,  discountSelections :  discountSelections,  productCode :  productCode,  variationProductCode :  variationProductCode,  customerAccountId :  customerAccountId,  allowInactive :  allowInactive,  skipInventoryCheck :  skipInventoryCheck,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<DiscountValidationSummary/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary ValidateDiscounts(ServiceClientMessageHandler handler,
                                                                                                    Mozu.Api.Contracts.ProductRuntime.DiscountSelections discountSelections, string productCode, string variationProductCode = null, int?customerAccountId = null, bool?allowInactive = null, bool?skipInventoryCheck = 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.Storefront.ProductClient.ValidateDiscountsClient(
                discountSelections:  discountSelections, productCode:  productCode, variationProductCode:  variationProductCode, customerAccountId:  customerAccountId, allowInactive:  allowInactive, skipInventoryCheck:  skipInventoryCheck, 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);
        }
Пример #2
0
        /// <summary>
        /// Evaluates whether a collection of discounts specified in the request can be redeemed for the supplied product code.
        /// </summary>
        /// <param name="allowInactive">If true, allow inactive categories to be retrieved in the category list response. If false, the categories retrieved will not include ones marked inactive.</param>
        /// <param name="customerAccountId">The unique identifier of the customer account for which to retrieve wish lists.</param>
        /// <param name="productCode">Merchant-created code that uniquely identifies the product such as a SKU or item number. Once created, the product code is read-only.</param>
        /// <param name="responseFields">A list or array of fields returned for a call. These fields may be customized and may be used for various types of data calls in Mozu. For example, responseFields are returned for retrieving or updating attributes, carts, and messages in Mozu.</param>
        /// <param name="skipInventoryCheck">If true, skip the process to validate inventory when creating this product reservation.</param>
        /// <param name="variationProductCode">Merchant-created code associated with a specific product variation. Variation product codes maintain an association with the base product code.</param>
        /// <param name="discountSelections">The discounts to evaluate for a specified product code at the time of purchase.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=ValidateDiscounts( discountSelections,  productCode,  variationProductCode,  customerAccountId,  allowInactive,  skipInventoryCheck,  responseFields);
        ///   var discountValidationSummaryClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary> ValidateDiscountsClient(Mozu.Api.Contracts.ProductRuntime.DiscountSelections discountSelections, string productCode, string variationProductCode = null, int?customerAccountId = null, bool?allowInactive = null, bool?skipInventoryCheck = null, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Catalog.Storefront.ProductUrl.ValidateDiscountsUrl(productCode, variationProductCode, customerAccountId, allowInactive, skipInventoryCheck, responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ProductRuntime.DiscountSelections>(discountSelections);

            return(mozuClient);
        }
Пример #3
0
        /// <summary>
        /// Evaluates whether a collection of discounts specified in the request can be redeemed for the supplied product code.
        /// </summary>
        /// <param name="allowInactive">If true, allow inactive categories to be retrieved in the category list response. If false, the categories retrieved will not include ones marked inactive.</param>
        /// <param name="customerAccountId">The unique identifier of the customer account for which to retrieve wish lists.</param>
        /// <param name="productCode">Merchant-created code that uniquely identifies the product such as a SKU or item number. Once created, the product code is read-only.</param>
        /// <param name="responseFields">A list or array of fields returned for a call. These fields may be customized and may be used for various types of data calls in Mozu. For example, responseFields are returned for retrieving or updating attributes, carts, and messages in Mozu.</param>
        /// <param name="skipInventoryCheck">If true, skip the process to validate inventory when creating this product reservation.</param>
        /// <param name="variationProductCode">Merchant-created code associated with a specific product variation. Variation product codes maintain an association with the base product code.</param>
        /// <param name="discountSelections">The discounts to evaluate for a specified product code at the time of purchase.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var product = new Product();
        ///   var discountValidationSummary = await product.ValidateDiscountsAsync( discountSelections,  productCode,  variationProductCode,  customerAccountId,  allowInactive,  skipInventoryCheck,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary> ValidateDiscountsAsync(Mozu.Api.Contracts.ProductRuntime.DiscountSelections discountSelections, string productCode, string variationProductCode = null, int?customerAccountId = null, bool?allowInactive = null, bool?skipInventoryCheck = null, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ProductRuntime.DiscountValidationSummary> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Storefront.ProductClient.ValidateDiscountsClient(discountSelections, productCode, variationProductCode, customerAccountId, allowInactive, skipInventoryCheck, responseFields);

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

            return(await response.ResultAsync());
        }