Пример #1
0
        /// <summary>
        /// Updates the given <see cref="Fulfillment"/>.
        /// </summary>
        /// <param name="orderId">The order id to which the fulfillments belong.</param>
        /// <param name="fulfillmentId">Id of the object being updated.</param>
        /// <param name="fulfillment">The <see cref="Fulfillment"/> to update.</param>
        /// <returns>The updated <see cref="Fulfillment"/>.</returns>
        public virtual async Task <Fulfillment> UpdateAsync(long orderId, long fulfillmentId, Fulfillment fulfillment)
        {
            var req     = PrepareRequest($"orders/{orderId}/fulfillments/{fulfillmentId}.json");
            var body    = fulfillment.ToDictionary();
            var content = new JsonContent(new
            {
                fulfillment = body
            });

            return(await ExecuteRequestAsync <Fulfillment>(req, HttpMethod.Put, content, "fulfillment"));
        }
Пример #2
0
        /// <summary>
        /// Creates a new <see cref="Fulfillment"/> on the order.
        /// </summary>
        /// <param name="orderId">The order id to which the fulfillments belong.</param>
        /// <param name="fulfillment">A new <see cref="Fulfillment"/>. Id should be set to null.</param>
        /// <param name="notifyCustomer">Whether the customer should be notified that the fulfillment
        /// has been created.</param>
        /// <returns>The new <see cref="Fulfillment"/>.</returns>
        public virtual async Task <Fulfillment> CreateAsync(long orderId, Fulfillment fulfillment, bool notifyCustomer)
        {
            var req  = PrepareRequest($"orders/{orderId}/fulfillments.json");
            var body = fulfillment.ToDictionary();

            body.Add("notify_customer", notifyCustomer);

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

            return(await ExecuteRequestAsync <Fulfillment>(req, HttpMethod.Post, content, "fulfillment"));
        }
Пример #3
0
        /// <summary>
        /// Creates a new <see cref="Fulfillment"/> on the order.
        /// </summary>
        /// <param name="orderId">The order id to which the fulfillments belong.</param>
        /// <param name="fulfillment">A new <see cref="Fulfillment"/>. Id should be set to null.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// <returns>The new <see cref="Fulfillment"/>.</returns>
        public virtual async Task <Fulfillment> CreateAsync(long orderId, Fulfillment fulfillment, CancellationToken cancellationToken = default)
        {
            var req  = PrepareRequest($"orders/{orderId}/fulfillments.json");
            var body = fulfillment.ToDictionary();

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

            var response = await ExecuteRequestAsync <Fulfillment>(req, HttpMethod.Post, cancellationToken, content, "fulfillment");

            return(response.Result);
        }