notifyWorkers method

Future<NotifyWorkersResponse> notifyWorkers({
  1. required String messageText,
  2. required String subject,
  3. required List<String> workerIds,
})

The NotifyWorkers operation sends an email to one or more Workers that you specify with the Worker ID. You can specify up to 100 Worker IDs to send the same message with a single call to the NotifyWorkers operation. The NotifyWorkers operation will send a notification email to a Worker only if you have previously approved or rejected work from the Worker.

May throw ServiceFault. May throw RequestError.

Parameter messageText : The text of the email message to send. Can include up to 4,096 characters

Parameter subject : The subject line of the email message to send. Can include up to 200 characters.

Parameter workerIds : A list of Worker IDs you wish to notify. You can notify upto 100 Workers at a time.

Implementation

Future<NotifyWorkersResponse> notifyWorkers({
  required String messageText,
  required String subject,
  required List<String> workerIds,
}) async {
  ArgumentError.checkNotNull(messageText, 'messageText');
  ArgumentError.checkNotNull(subject, 'subject');
  ArgumentError.checkNotNull(workerIds, 'workerIds');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'MTurkRequesterServiceV20170117.NotifyWorkers'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'MessageText': messageText,
      'Subject': subject,
      'WorkerIds': workerIds,
    },
  );

  return NotifyWorkersResponse.fromJson(jsonResponse.body);
}