コード例 #1
0
        /// <summary>
        /// Updates the given object.
        /// </summary>
        /// <param name="id">Id of the object being updated.</param>
        /// <param name="rule">The updated rule.</param>
        public virtual async Task <PriceRule> UpdateAsync(long id, PriceRule rule)
        {
            var req     = PrepareRequest($"price_rules/{id}.json");
            var content = new JsonContent(new
            {
                price_rule = rule
            });

            return(await ExecuteRequestAsync <PriceRule>(req, HttpMethod.Put, content, "price_rule"));
        }
コード例 #2
0
        /// <summary>
        /// Updates the given object.
        /// </summary>
        /// <param name="id">Id of the object being updated.</param>
        /// <param name="rule">The updated rule.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        public virtual async Task <PriceRule> UpdateAsync(long id, PriceRule rule, CancellationToken cancellationToken = default)
        {
            var req     = PrepareRequest($"price_rules/{id}.json");
            var content = new JsonContent(new
            {
                price_rule = rule
            });
            var response = await ExecuteRequestAsync <PriceRule>(req, HttpMethod.Put, cancellationToken, content, "price_rule");

            return(response.Result);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new price rule.
        /// </summary>
        /// <param name="rule">A new price rule. Id should be set to null.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        public virtual async Task <PriceRule> CreateAsync(PriceRule rule, CancellationToken cancellationToken = default)
        {
            var req     = PrepareRequest("price_rules.json");
            var body    = rule.ToDictionary();
            var content = new JsonContent(new
            {
                price_rule = body
            });
            var response = await ExecuteRequestAsync <PriceRule>(req, HttpMethod.Post, cancellationToken, content, "price_rule");

            return(response.Result);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new price rule.
        /// </summary>
        /// <param name="rule">A new price rule. Id should be set to null.</param>
        public virtual async Task <PriceRule> CreateAsync(PriceRule rule)
        {
            var req  = PrepareRequest("price_rules.json");
            var body = rule.ToDictionary();

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

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