Skip to content

ICustomerService

// RB2 Core Connect
namespace CoreConnect.Commerce.Customer;
/// <summary>
/// Represents an interface for interacting with customer-related operations.
/// </summary>
public interface ICustomerService
{
/// <summary>
/// Signs in a user based on the provided <paramref name="request"/> and <paramref name="requestContext"/>.
/// </summary>
/// <param name="request"></param>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<SignInResponse> SignIn(SignInRequest request, IRequestContext requestContext, CancellationToken cancellationToken);
/// <summary>
/// Signs in with external authentication.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="requestContext">The request context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task<SignInResponse> SignInExternalOAuth(SignInExternalRequest request, IRequestContext requestContext, CancellationToken cancellationToken);
/// <summary>
/// Signs up a new user based on the provided <paramref name="request"/> and <paramref name="requestContext"/>.
/// </summary>
/// <param name="request">The sign-up request containing user registration details.</param>
/// <param name="requestContext">The request context for additional context information.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation if necessary.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous sign-up operation, returning a <see cref="SignUpResponse"/>.</returns>
Task<SignUpResponse> SignUp(SignUpRequest request, IRequestContext requestContext, CancellationToken cancellationToken);
/// <summary>
/// Signs up with external authentication.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="requestContext">The request context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task<SignUpResponse> SignUpExternalOAuth(SignUpRequest request, IRequestContext requestContext, CancellationToken cancellationToken);
/// <summary>
/// Confirms a user's email address using the provided confirmation <paramref name="token"/>.
/// </summary>
/// <param name="token">The confirmation token sent to the user's email address.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation if necessary.</param>
/// <returns>
/// A <see cref="Task"/> representing the asynchronous email confirmation operation,
/// returning a nullable <see cref="bool"/> indicating whether the confirmation was successful.
/// </returns>
Task<bool?> EmailConfirmation(string token, CancellationToken cancellationToken);
/// <summary>
/// Resets a user's password based on the provided <paramref name="request"/> and reset token.
/// </summary>
/// <param name="request">The password reset request containing new password details.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation if necessary.</param>
/// <returns>
/// A <see cref="Task"/> representing the asynchronous password reset operation, returning a <see cref="bool"/>
/// indicating whether the password reset was successful.
/// </returns>
Task<bool> ResetPassword(ResetPasswordRequest request, CancellationToken cancellationToken);
/// <summary>
/// Creates a password reset token for a user based on their <paramref name="email"/>.
/// </summary>
/// <param name="email">The email address of the user requesting a password reset.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation if necessary.</param>
/// <returns>
/// A <see cref="Task"/> representing the asynchronous token creation operation, returning a <see cref="bool"/>
/// indicating whether the token creation was successful.
/// </returns>
Task<CreateResetPasswordTokenResponse> CreateResetPasswordToken(string email, CancellationToken cancellationToken);
/// <summary>
/// Retrieves current or customer's information based on the provided
/// </summary>
/// <param name="cancellationToken">A cancellation token to cancel the operation if necessary.</param>
/// <returns>
/// A <see cref="Task"/> representing the asynchronous customer retrieval operation, returning a <see cref="Customer"/>.
/// </returns>
Task<Customer?> GetCustomer(CancellationToken cancellationToken);
/// <summary>
/// Retrieves current or customer's information based on the provided
/// </summary>
/// <param name="CustomerId"></param>
/// <param name="cancellationToken">A cancellation token to cancel the operation if necessary.</param>
/// <returns>
/// A <see cref="Task"/> representing the asynchronous customer retrieval operation, returning a <see cref="Customer"/>.
/// </returns>
Task<Customer?> GetCustomerById(string CustomerId, CancellationToken cancellationToken);
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Customer> UpdateAddress(UpdateCustomerAddressRequest request, CancellationToken cancellationToken);
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Customer> AddAddress(AddCustomerAddressRequest request, CancellationToken cancellationToken);
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Customer> RemoveAddress(RemoveCustomerAddressRequest request, CancellationToken cancellationToken);
/// <summary>
///
/// </summary>
/// <param name="customerId"></param>
/// <param name="version"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<string> GetTargetTokenEmail(string customerId, long version, CancellationToken cancellationToken);
/// <summary>
/// Update cutomer profile information
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Commerce.Customer.Customer?> UpdateCustomerProfile(UpdateCustomerProfileRequest request, CancellationToken cancellationToken);
/// <summary>
/// Deletes a customer account
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<bool> DeleteCustomer(DeleteCustomerRequest request, CancellationToken cancellationToken);
/// <summary>
/// Refresh Token
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<SignInResponse> RefreshToken(RefreshTokenRequest request, CancellationToken cancellationToken);
/// <summary>
/// Change your password
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<bool> ChangePassword(ChangePasswordRequest request, CancellationToken cancellationToken);
/// <summary>
/// Subscribe newsletter for guests.
/// </summary>
/// <param name="subscribe"></param>
/// <param name="email"></param>
/// <param name="context"></param>
/// <returns></returns>
Task<bool> SubscribeNewsletter(bool? subscribe, string? email, IRequestContext context);
/// <summary>
/// Sign in guest.
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<SignInResponse> GuestSignIn(GuestSignInRequest request, CancellationToken cancellationToken = default);
}