/// <summary>
        /// Modifies properties of the discount target, for example, the dollar amount, or precentage off the price.
        /// </summary>
        /// <param name="discountId">Unique identifier of the discount. System-supplied and read only.</param>
        /// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
        /// <param name="discountTarget">Properties of the target to which the discount applies, such as the type of discount and which products, categories, or shipping methods are eligible for the discount and the properties of this discount target.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.ProductAdmin.DiscountTarget"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=UpdateDiscountTarget( discountTarget,  discountId,  responseFields);
        ///   var discountTargetClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.ProductAdmin.DiscountTarget> UpdateDiscountTargetClient(Mozu.Api.Contracts.ProductAdmin.DiscountTarget discountTarget, int discountId, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Catalog.Admin.Discounts.DiscountTargetUrl.UpdateDiscountTargetUrl(discountId, responseFields);
            const string verb       = "PUT";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.ProductAdmin.DiscountTarget>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ProductAdmin.DiscountTarget>(discountTarget);

            return(mozuClient);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="discountId">discountId parameter description DOCUMENT_HERE </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="discountTarget">Properties of the target to which the discount applies, such as the type of discount and which products, categories, or shipping methods are eligible for the discount and the properties of this discount target.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ProductAdmin.DiscountTarget"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var discounttarget = new DiscountTarget();
        ///   var discountTarget = await discounttarget.UpdateDiscountTargetAsync( discountTarget,  discountId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ProductAdmin.DiscountTarget> UpdateDiscountTargetAsync(Mozu.Api.Contracts.ProductAdmin.DiscountTarget discountTarget, int discountId, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.DiscountTarget> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.Discounts.DiscountTargetClient.UpdateDiscountTargetClient(discountTarget, discountId, responseFields);

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

            return(await response.ResultAsync());
        }
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = DiscountTargetFactory.UpdateDiscountTarget(handler : handler,  discountTarget :  discountTarget,  discountId :  discountId,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<DiscountTarget/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.ProductAdmin.DiscountTarget UpdateDiscountTarget(ServiceClientMessageHandler handler,
                                                                                          Mozu.Api.Contracts.ProductAdmin.DiscountTarget discountTarget, int discountId, 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.Discounts.DiscountTargetClient.UpdateDiscountTargetClient(
                discountTarget:  discountTarget, discountId:  discountId, 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);
        }
예제 #4
0
        public virtual Mozu.Api.Contracts.ProductAdmin.DiscountTarget UpdateDiscountTarget(Mozu.Api.Contracts.ProductAdmin.DiscountTarget discountTarget, int discountId, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ProductAdmin.DiscountTarget> response;
            var client = Mozu.Api.Clients.Commerce.Catalog.Admin.Discounts.DiscountTargetClient.UpdateDiscountTargetClient(discountTarget, discountId, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }