/// <summary>
        /// Updates the given <see cref="InventoryLevel"/>.
        /// </summary>
        /// <param name="updatedInventoryLevel">The updated <see cref="InventoryLevel"/></param>
        /// <param name="disconnectIfNecessary">Whether inventory for any previously connected locations will be set to 0 and the locations disconnected. This property is ignored when no fulfillment service is involved.</param>
        /// <returns>The updated <see cref="InventoryLevel"/></returns>
        public virtual async Task <InventoryLevel> SetAsync(InventoryLevel updatedInventoryLevel, bool disconnectIfNecessary = false)
        {
            var req  = PrepareRequest($"inventory_levels/set.json");
            var body = updatedInventoryLevel.ToDictionary();

            body.Add("disconnect_if_necessary", disconnectIfNecessary);
            JsonContent content = new JsonContent(body);

            return(await ExecuteRequestAsync <InventoryLevel>(req, HttpMethod.Post, content, "inventory_level"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the given <see cref="InventoryLevel"/>.
        /// </summary>
        /// <param name="updatedInventoryLevel">The updated <see cref="InventoryLevel"/></param>
        /// <param name="disconnectIfNecessary">Whether inventory for any previously connected locations will be set to 0 and the locations disconnected. This property is ignored when no fulfillment service is involved.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// <returns>The updated <see cref="InventoryLevel"/></returns>
        public virtual async Task <InventoryLevel> SetAsync(InventoryLevel updatedInventoryLevel, bool disconnectIfNecessary = false, CancellationToken cancellationToken = default)
        {
            var req  = PrepareRequest($"inventory_levels/set.json");
            var body = updatedInventoryLevel.ToDictionary();

            body.Add("disconnect_if_necessary", disconnectIfNecessary);

            var content  = new JsonContent(body);
            var response = await ExecuteRequestAsync <InventoryLevel>(req, HttpMethod.Post, cancellationToken, content, "inventory_level");

            return(response.Result);
        }