Beispiel #1
0
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = OrderFactory.UpdateOrder(handler : handler,  order :  order,  orderId :  orderId,  updateMode :  updateMode,  version :  version,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<Order/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.CommerceRuntime.Orders.Order UpdateOrder(ServiceClientMessageHandler handler,
                                                                                  Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, string orderId, string updateMode = null, string version = 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.OrderClient.UpdateOrderClient(
                order:  order, orderId:  orderId, updateMode:  updateMode, version:  version, 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);
        }
        public virtual Mozu.Api.Contracts.CommerceRuntime.Orders.Order UpdateOrder(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, string orderId, string updateMode = null, string version = null, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> response;
            var client = Mozu.Api.Clients.Commerce.OrderClient.UpdateOrderClient(order, orderId, updateMode, version, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
        public virtual Mozu.Api.Contracts.CommerceRuntime.Orders.Order CreateOrder(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> response;
            var client = Mozu.Api.Clients.Commerce.OrderClient.CreateOrderClient(order, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
        public void Exercise_14_1_Get_Orders()
        {
            //Create an Order resource. This resource is used to get, create, update orders
            var orderResource = new Mozu.Api.Resources.Commerce.OrderResource(_apiContext);

            //Filter orders by statuses
            var acceptedOrders = orderResource.GetOrdersAsync(filter: "Status eq 'Accepted'").Result;
            var closedOrders   = orderResource.GetOrdersAsync(filter: "Status eq 'Closed'").Result;

            //Filter orders by acct number
            var orderByCustId = orderResource.GetOrdersAsync(filter: "CustomerAccountId eq '1001'").Result;

            //Filter orders by email
            var orderByEmail = orderResource.GetOrdersAsync(filter: "Email eq '*****@*****.**'").Result;

            //Filter orders by order number
            var existingOrders = orderResource.GetOrdersAsync(filter: "OrderNumber eq '1'").Result;

            //Initialize the Order variable
            Mozu.Api.Contracts.CommerceRuntime.Orders.Order existingOrder = null;
            //Check if an Order was returned
            if (existingOrders.TotalCount > 0)
            {
                //Set the Order to the first occurance in the collection
                existingOrder = existingOrders.Items[0];
            }

            if (existingOrder != null)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Order Status Values: "
                                                                 + Environment.NewLine +
                                                                 "Status={0}"
                                                                 + Environment.NewLine +
                                                                 "FulfillmentStatus={1}"
                                                                 + Environment.NewLine +
                                                                 "PaymentStatus={2}"
                                                                 + Environment.NewLine +
                                                                 "ReturnStatus={3}",
                                                                 existingOrder.Status,
                                                                 existingOrder.FulfillmentStatus,
                                                                 existingOrder.PaymentStatus,
                                                                 existingOrder.ReturnStatus));


                //Write out payment statuses
                foreach (var existingPayment in existingOrder.Payments)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Payment Status Value[{0}]: Status={1}",
                                                                     existingPayment.Id,
                                                                     existingPayment.Status));

                    //Write out payment interaction statuses
                    foreach (var existingInteraction in existingPayment.Interactions)
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("Payment Interaction Status Value[{0}]: Status={1}",
                                                                         existingInteraction.Id,
                                                                         existingInteraction.Status));
                    }
                }

                //Write out order package statuses
                foreach (var existingPackage in existingOrder.Packages)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Package Status Value[{0}]: Status={1}",
                                                                     existingPackage.Id,
                                                                     existingPackage.Status));
                }
            }
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderId">Unique identifier of the order.</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="updateMode">Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."</param>
        /// <param name="version">Determines whether or not to check versioning of items for concurrency purposes.</param>
        /// <param name="order">Properties of an order, including its components.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.CommerceRuntime.Orders.Order"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=UpdateOrder( order,  orderId,  updateMode,  version,  responseFields);
        ///   var orderClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> UpdateOrderClient(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, string orderId, string updateMode = null, string version = null, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.OrderUrl.UpdateOrderUrl(orderId, updateMode, version, responseFields);
            const string verb       = "PUT";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.CommerceRuntime.Orders.Order>(order);

            return(mozuClient);
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="refreshShipping">Specifies whether shipping rates should be re-evaluated while pricing.</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="order">The order payload to price.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.CommerceRuntime.Orders.Order"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=PriceOrder( order,  refreshShipping,  responseFields);
        ///   var orderClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> PriceOrderClient(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, bool refreshShipping, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.OrderUrl.PriceOrderUrl(refreshShipping, responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.CommerceRuntime.Orders.Order>(order);

            return(mozuClient);
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderId">Unique identifier of the order.</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="updateMode">Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."</param>
        /// <param name="version">Determines whether or not to check versioning of items for concurrency purposes.</param>
        /// <param name="order">Properties of an order, including its components.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.CommerceRuntime.Orders.Order"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var order = new Order();
        ///   var order = await order.UpdateOrderAsync( order,  orderId,  updateMode,  version,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> UpdateOrderAsync(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, string orderId, string updateMode = null, string version = null, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> response;
            var client = Mozu.Api.Clients.Commerce.OrderClient.UpdateOrderClient(order, orderId, updateMode, version, responseFields);

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

            return(await response.ResultAsync());
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="refreshShipping"></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="order"></param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.CommerceRuntime.Orders.Order"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var order = new Order();
        ///   var order = await order.PriceOrderAsync( order,  refreshShipping,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> PriceOrderAsync(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, bool refreshShipping, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> response;
            var client = Mozu.Api.Clients.Commerce.OrderClient.PriceOrderClient(order, refreshShipping, responseFields);

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

            return(await response.ResultAsync());
        }
        /// <summary>
        /// Creates a new order for no-cart quick-ordering scenarios.
        /// </summary>
        /// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
        /// <param name="order">Properties of an order, including its components.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.CommerceRuntime.Orders.Order"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var order = new Order();
        ///   var order = await order.CreateOrderAsync( order,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> CreateOrderAsync(Mozu.Api.Contracts.CommerceRuntime.Orders.Order order, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.CommerceRuntime.Orders.Order> response;
            var client = Mozu.Api.Clients.Commerce.OrderClient.CreateOrderClient(order, responseFields);

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

            return(await response.ResultAsync());
        }