Example #1
0
        /// <summary>
        /// Updates the given <see cref="GiftCard"/>.
        /// </summary>
        /// <param name="giftCardId">Id of the object being updated.</param>
        /// <param name="giftCard">The <see cref="GiftCard"/> to update.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// <returns>The updated <see cref="GiftCard"/>.</returns>
        public virtual async Task <Entities.GiftCard> UpdateAsync(long giftCardId, Entities.GiftCard giftCard, CancellationToken cancellationToken = default)
        {
            var req     = PrepareRequest($"gift_cards/{giftCardId}.json");
            var content = new JsonContent(new
            {
                gift_card = giftCard
            });
            var response = await ExecuteRequestAsync <Entities.GiftCard>(req, HttpMethod.Put, cancellationToken, content, "gift_card");

            return(response.Result);
        }
Example #2
0
        /// <summary>
        /// Creates a new <see cref="GiftCard"/>.
        /// </summary>
        /// <param name="giftCard">A new <see cref="GiftCard"/>. Id should be set to null.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// <returns>The new <see cref="GiftCard"/>.</returns>
        public virtual async Task <Entities.GiftCard> CreateAsync(Entities.GiftCard giftCard, CancellationToken cancellationToken = default)
        {
            var req  = PrepareRequest("gift_cards.json");
            var body = giftCard.ToDictionary();

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

            var response = await ExecuteRequestAsync <Entities.GiftCard>(req, HttpMethod.Post, cancellationToken, content, "gift_card");

            return(response.Result);
        }