Exemplo n.º 1
0
        /// <summary>
        /// Updates the given <see cref="ShopifyOrder"/>. Id must not be null.
        /// </summary>
        /// <param name="order">The <see cref="ShopifyOrder"/> to update.</param>
        /// <returns>The updated <see cref="ShopifyOrder"/>.</returns>
        public async Task <ShopifyOrder> UpdateAsync(ShopifyOrder order)
        {
            IRestRequest req = RequestEngine.CreateRequest($"orders/{order.Id.Value}.json", Method.PUT, "order");

            req.AddJsonBody(new { order });

            return(await RequestEngine.ExecuteRequestAsync <ShopifyOrder>(_RestClient, req));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="ShopifyOrder"/> on the store.
        /// </summary>
        /// <param name="order">A new <see cref="ShopifyOrder"/>. Id should be set to null.</param>
        /// <param name="options">Options for creating the order.</param>
        /// <returns>The new <see cref="ShopifyOrder"/>.</returns>
        public async Task <ShopifyOrder> CreateAsync(ShopifyOrder order, ShopifyOrderCreateOptions options = null)
        {
            IRestRequest req = RequestEngine.CreateRequest("orders.json", Method.POST, "order");

            //Build the request body
            Dictionary <string, object> body = new Dictionary <string, object>(options?.ToDictionary() ?? new Dictionary <string, object>())
            {
                { "order", order }
            };

            req.AddJsonBody(body);

            return(await RequestEngine.ExecuteRequestAsync <ShopifyOrder>(_RestClient, req));
        }
        /// <summary>
        /// Updates the given <see cref="ShopifyOrder"/>. Id must not be null.
        /// </summary>
        /// <param name="order">The <see cref="ShopifyOrder"/> to update.</param>
        /// <returns>The updated <see cref="ShopifyOrder"/>.</returns>
        public async Task<ShopifyOrder> UpdateAsync(ShopifyOrder order)
        {
            IRestRequest req = RequestEngine.CreateRequest($"orders/{order.Id.Value}.json", Method.PUT, "order");

            req.AddJsonBody(new { order });

            return await RequestEngine.ExecuteRequestAsync<ShopifyOrder>(_RestClient, req);
        }
        /// <summary>
        /// Creates a new <see cref="ShopifyOrder"/> on the store.
        /// </summary>
        /// <param name="order">A new <see cref="ShopifyOrder"/>. Id should be set to null.</param>
        /// <param name="options">Options for creating the order.</param>
        /// <returns>The new <see cref="ShopifyOrder"/>.</returns>
        public async Task<ShopifyOrder> CreateAsync(ShopifyOrder order, ShopifyOrderCreateOptions options = null)
        {
            IRestRequest req = RequestEngine.CreateRequest("orders.json", Method.POST, "order");

            //Build the request body
            Dictionary<string, object> body = new Dictionary<string, object>(options?.ToDictionary() ?? new Dictionary<string, object>())
            {
                { "order", order }
            };

            req.AddJsonBody(body);

            return await RequestEngine.ExecuteRequestAsync<ShopifyOrder>(_RestClient, req);
        }