Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cartItemId">Identifier of the cart item to delete.</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="cartItem">Properties of an item added to an active shopping cart.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var cartitem = new CartItem();
        ///   var cartItem = await cartitem.UpdateCartItemAsync( cartItem,  cartItemId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem> UpdateCartItemAsync(Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem cartItem, string cartItemId, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem> response;
            var client = Mozu.Api.Clients.Commerce.Carts.CartItemClient.UpdateCartItemClient(cartItem, cartItemId, responseFields);

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

            return(await response.ResultAsync());
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cartItemId">Identifier of the cart item to delete.</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="cartItem">Properties of an item added to an active shopping cart.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=UpdateCartItem( cartItem,  cartItemId,  responseFields);
        ///   var cartItemClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem> UpdateCartItemClient(Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem cartItem, string cartItemId, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Carts.CartItemUrl.UpdateCartItemUrl(cartItemId, responseFields);
            const string verb       = "PUT";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem>(cartItem);

            return(mozuClient);
        }
Пример #3
0
        /// <summary>
        /// Update the product or product quantity of an item in the current shopper's cart.
        /// </summary>
        /// <param name="cartItemId">Identifier of the cart item to delete.</param>
        /// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
        /// <param name="cartItem">Properties of an item added to an active shopping cart.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var cartitem = new CartItem();
        ///   var cartItem = await cartitem.UpdateCartItemAsync( cartItem,  cartItemId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem> UpdateCartItemAsync(Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem cartItem, string cartItemId, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem> response;
            var client = Mozu.Api.Clients.Commerce.Carts.CartItemClient.UpdateCartItemClient(cartItem, cartItemId, responseFields);

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

            return(await response.ResultAsync());
        }
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = CartItemFactory.UpdateCartItem(handler : handler,  cartItem :  cartItem,  cartItemId :  cartItemId,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<CartItem/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem UpdateCartItem(ServiceClientMessageHandler handler,
                                                                                       Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem cartItem, string cartItemId, 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.Carts.CartItemClient.UpdateCartItemClient(
                cartItem:  cartItem, cartItemId:  cartItemId, 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);
        }
Пример #5
0
        public virtual Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem UpdateCartItem(Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem cartItem, string cartItemId, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Carts.CartItem> response;
            var client = Mozu.Api.Clients.Commerce.Carts.CartItemClient.UpdateCartItemClient(cartItem, cartItemId, responseFields);

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