/// <summary> /// Removes the specified coupons for a specific cart instance. /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task RemoveCouponsAsync(RemoveCouponsParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (string.IsNullOrWhiteSpace(param.CartName)) { throw new ArgumentException("Cart name cannot be null or whitespace", "param"); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("Scope cannot be null or whitespace", "param"); } if (param.CustomerId == Guid.Empty) { throw new ArgumentException("CustomerId cannot be Empty GUID", "param"); } if (param.CouponCodes == null) { throw new ArgumentNullException("param"); } foreach (var couponCode in param.CouponCodes) { var request = new RemoveCouponRequest { CouponCode = couponCode, CartName = param.CartName, CustomerId = param.CustomerId, ScopeId = param.Scope }; // Do not remove coupons in parallel, because otherwise it could corrupt your cart. await OvertureClient.SendAsync(request).ConfigureAwait(false); } }
/// <summary> /// Removes the specified coupons for a specific cart instance. /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task RemoveCouponsAsync(RemoveCouponsParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (string.IsNullOrWhiteSpace(param.CartName)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } if (param.CustomerId == Guid.Empty) { throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param)); } if (param.CouponCodes == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CouponCodes)), nameof(param)); } foreach (var couponCode in param.CouponCodes) { var request = new RemoveCouponRequest { CouponCode = couponCode, CartName = param.CartName, CartType = param.CartType, CustomerId = param.CustomerId, ScopeId = param.Scope }; // Do not remove coupons in parallel, because otherwise it could corrupt your cart. await OvertureClient.SendAsync(request).ConfigureAwait(false); } }