예제 #1
0
        /// <summary>
        /// Updates the draft order with the given id.
        /// </summary>
        /// <param name="id">The id of the item being updated.</param>
        /// <param name="order">The updated draft order.</param>
        public virtual async Task <DraftOrder> UpdateAsync(long id, DraftOrder order)
        {
            var req     = PrepareRequest($"draft_orders/{id}.json");
            var content = new JsonContent(new
            {
                draft_order = order.ToDictionary()
            });

            return(await ExecuteRequestAsync <DraftOrder>(req, HttpMethod.Put, content, "draft_order"));
        }
예제 #2
0
        /// <summary>
        /// Updates the draft order with the given id.
        /// </summary>
        /// <param name="id">The id of the item being updated.</param>
        /// <param name="order">The updated draft order.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        public virtual async Task <DraftOrder> UpdateAsync(long id, DraftOrder order, CancellationToken cancellationToken = default)
        {
            var req     = PrepareRequest($"draft_orders/{id}.json");
            var content = new JsonContent(new
            {
                draft_order = order.ToDictionary()
            });

            var response = await ExecuteRequestAsync <DraftOrder>(req, HttpMethod.Put, cancellationToken, content, "draft_order");

            return(response.Result);
        }
예제 #3
0
        /// <summary>
        /// Creates a new draft order.
        /// </summary>
        /// <param name="order">A new DraftOrder. Id should be set to null.</param>
        /// <param name="useCustomerDefaultAddress">Optional boolean that you can send as part of a draft order object to load customer shipping information. Defaults to false.</param>
        public virtual async Task <DraftOrder> CreateAsync(DraftOrder order, bool useCustomerDefaultAddress = false)
        {
            var req  = PrepareRequest("draft_orders.json");
            var body = order.ToDictionary();

            body.Add("use_customer_default_address", useCustomerDefaultAddress);

            var content = new JsonContent(new
            {
                draft_order = body
            });

            return(await ExecuteRequestAsync <DraftOrder>(req, HttpMethod.Post, content, "draft_order"));
        }