Interface IEmailClient<TRequest, TResponse>
Base Mailtrap API client for sending emails.
public interface IEmailClient<TRequest, TResponse> : IRestResource where TRequest : class where TResponse : class
Type Parameters
TRequestThe type of the email request object. One of SendEmailRequest or BatchEmailRequest.
TResponseThe type of the email response object. One of SendEmailResponse or BatchEmailResponse.
- Inherited Members
Methods
Send(TRequest, CancellationToken)
Sends email, represented by the request, and returns send operation result.
Task<TResponse> Send(TRequest request, CancellationToken cancellationToken = default)
Parameters
requestTRequestRequest object, containing email data.
cancellationTokenCancellationTokenToken to control operation cancellation.
Returns
- Task<TResponse>
TResponseinstance with response data.
Remarks
Request is checked for validity before send.
ArgumentException is thrown if validation fails.
Exceptions
- ArgumentNullException
When
requestis null.- ArgumentException
When
requestcontains invalid data.- JsonException
When request serialization or API response deserialization fails for any reason.
- TaskCanceledException
When operation is canceled by
cancellationToken.- OperationCanceledException
When operation is canceled by
cancellationToken.- HttpRequestException
When request to the API fails for any reason.
- MailtrapApiException
When request failed for any other reason.