waitForMatchingFirstEmailWithHttpInfo method
Wait for or return the first email that matches provided MatchOptions array
Perform a search of emails in an inbox with the given patterns. If a result if found then return or else retry the search until a result is found or timeout is reached. Match options allow simple CONTAINS or EQUALS filtering on SUBJECT, TO, BCC, CC, and FROM. See the MatchOptions
object for options. An example payload is { matches: [{field: 'SUBJECT',should:'CONTAIN',value:'needle'}] }
. You can use an array of matches and they will be applied sequentially to filter out emails. If you want to perform matches and extractions of content using Regex patterns see the EmailController getEmailContentMatch
method.
Note: This method returns the HTTP Response
.
Parameters:
-
String inboxId (required): Id of the inbox we are matching an email for
-
MatchOptions matchOptions (required):
-
int timeout: Max milliseconds to wait
-
bool unreadOnly: Optional filter for unread only
-
DateTime since: Filter for emails that were received after the given timestamp
-
DateTime before: Filter for emails that were received before the given timestamp
-
String sort: Sort direction
-
int delay: Max milliseconds delay between calls
Implementation
Future<Response> waitForMatchingFirstEmailWithHttpInfo(String inboxId, MatchOptions matchOptions, { int? timeout, bool? unreadOnly, DateTime? since, DateTime? before, String? sort, int? delay, }) async {
// ignore: prefer_const_declarations
final path = r'/waitForMatchingFirstEmail';
// ignore: prefer_final_locals
Object? postBody = matchOptions;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
queryParams.addAll(_queryParams('', 'inboxId', inboxId));
if (timeout != null) {
queryParams.addAll(_queryParams('', 'timeout', timeout));
}
if (unreadOnly != null) {
queryParams.addAll(_queryParams('', 'unreadOnly', unreadOnly));
}
if (since != null) {
queryParams.addAll(_queryParams('', 'since', since));
}
if (before != null) {
queryParams.addAll(_queryParams('', 'before', before));
}
if (sort != null) {
queryParams.addAll(_queryParams('', 'sort', sort));
}
if (delay != null) {
queryParams.addAll(_queryParams('', 'delay', delay));
}
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}