Skip to content

ICartService

// RB2 Core Connect
namespace CoreConnect.Commerce.Cart;
/// <summary>
/// The cart service Interface.
/// </summary>
public interface ICartService
{
/// <summary>
/// Gets the specified cart.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The request context.</param>
/// <param name="cancellationToken">A cancellation token which can be used to cancel the operation.</param>
/// <returns>Commerce.Cart.Cart</returns>
Task<CartResponse> GetCart(CartRequest request, IRequestContext context, CancellationToken cancellationToken = default);
/// <summary>
/// Creates the cart.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The cart</returns>
Task<CartResponse> CreateCart(CreateCartRequest request, IRequestContext context, CancellationToken cancellationToken = default);
/// <summary>
/// Adds line items to the cart.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Commerce.Cart.Cart</returns>
Task<CartResponse> AddCartLineItems(AddCartLineItemsRequest request, IRequestContext context, CancellationToken cancellationToken = default);
/// <summary>
/// Removes the cart line item.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Commerce.Cart.Cart</returns>
Task<CartResponse> RemoveCartLineItem(RemoveCartLineItemRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Updates the cart line item.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Commerce.Cart.Cart</returns>
Task<CartResponse> UpdateCartLineItem(UpdateCartLineItemRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Updates cart.
/// </summary>
/// <param name="request"></param>
/// <param name="context"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<CartResponse> CartUpdate(CartUpdateRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// MergeCarts
/// </summary>
/// <param name="sourceCartId"></param>
/// <param name="destinationCartId"></param>
/// <param name="useNewCart"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<string> MergeCarts(string sourceCartId, string destinationCartId, bool useNewCart, CancellationToken cancellationToken);
/// <summary>
/// Removes multiples line items from a cart.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<CartResponse> RemoveCartLineItems(RemoveCartLineItemsRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Removes all cart items.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task<CartResponse> ClearCart(ClearCartRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Gets the shipping methods.
/// </summary>
/// <param name="request">The cart identifier.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<IEnumerable<ShippingMethodResponse>> GetShippingMethods(ShippingMethodRequest request, IRequestContext context, CancellationToken cancellationToken = default);
/// <summary>
/// Replaces a cart line item with the provided new cart item.
/// </summary>
/// <param name="request"></param>
/// <param name="context"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<CartResponse> ReplaceCartLineItem(ReplaceCartLineItemRequest request, IRequestContext context, CancellationToken cancellationToken = default);
/// <summary>
/// Apply discount codes to cart
/// </summary>
/// <param name="request"></param>
/// <param name="context"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<CartResponse> ApplyDiscountCode(CartApplyDiscountCodeRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Remove a DiscountCode from the Cart.
/// </summary>
/// <param name="request"></param>
/// <param name="context"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<CartResponse> RemoveDiscountCode(CartRemoveDiscountCodeRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Gets a discount code by id
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<string> GetDiscountById(CartGetDiscountByIdRequest request, CancellationToken cancellationToken);
/// <summary>
/// Replaces the cart custom line item.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task<CartResponse> ReplaceCartCustomLineItem(ReplaceCartCustomLineItemRequest request, IRequestContext context, CancellationToken cancellationToken);
/// <summary>
/// Adds gift information
/// </summary>
/// <param name="cartId"></param>
/// <param name="giftPayment"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task AddGiftPaymentMethod(string cartId, ApplyGiftPaymentMethodResponse giftPayment, CancellationToken cancellationToken);
}