createHITType method

Future<CreateHITTypeResponse> createHITType({
  1. required int assignmentDurationInSeconds,
  2. required String description,
  3. required String reward,
  4. required String title,
  5. int? autoApprovalDelayInSeconds,
  6. String? keywords,
  7. List<QualificationRequirement>? qualificationRequirements,
})

The CreateHITType operation creates a new HIT type. This operation allows you to define a standard set of HIT properties to use when creating HITs. If you register a HIT type with values that match an existing HIT type, the HIT type ID of the existing type will be returned.

May throw ServiceFault. May throw RequestError.

Parameter assignmentDurationInSeconds : The amount of time, in seconds, that a Worker has to complete the HIT after accepting it. If a Worker does not complete the assignment within the specified duration, the assignment is considered abandoned. If the HIT is still active (that is, its lifetime has not elapsed), the assignment becomes available for other users to find and accept.

Parameter description : A general description of the HIT. A description includes detailed information about the kind of task the HIT contains. On the Amazon Mechanical Turk web site, the HIT description appears in the expanded view of search results, and in the HIT and assignment screens. A good description gives the user enough information to evaluate the HIT before accepting it.

Parameter reward : The amount of money the Requester will pay a Worker for successfully completing the HIT.

Parameter title : The title of the HIT. A title should be short and descriptive about the kind of task the HIT contains. On the Amazon Mechanical Turk web site, the HIT title appears in search results, and everywhere the HIT is mentioned.

Parameter autoApprovalDelayInSeconds : The number of seconds after an assignment for the HIT has been submitted, after which the assignment is considered Approved automatically unless the Requester explicitly rejects it.

Parameter keywords : One or more words or phrases that describe the HIT, separated by commas. These words are used in searches to find HITs.

Parameter qualificationRequirements : Conditions that a Worker's Qualifications must meet in order to accept the HIT. A HIT can have between zero and ten Qualification requirements. All requirements must be met in order for a Worker to accept the HIT. Additionally, other actions can be restricted using the ActionsGuarded field on each QualificationRequirement structure.

Implementation

Future<CreateHITTypeResponse> createHITType({
  required int assignmentDurationInSeconds,
  required String description,
  required String reward,
  required String title,
  int? autoApprovalDelayInSeconds,
  String? keywords,
  List<QualificationRequirement>? qualificationRequirements,
}) async {
  ArgumentError.checkNotNull(
      assignmentDurationInSeconds, 'assignmentDurationInSeconds');
  ArgumentError.checkNotNull(description, 'description');
  ArgumentError.checkNotNull(reward, 'reward');
  ArgumentError.checkNotNull(title, 'title');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'MTurkRequesterServiceV20170117.CreateHITType'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AssignmentDurationInSeconds': assignmentDurationInSeconds,
      'Description': description,
      'Reward': reward,
      'Title': title,
      if (autoApprovalDelayInSeconds != null)
        'AutoApprovalDelayInSeconds': autoApprovalDelayInSeconds,
      if (keywords != null) 'Keywords': keywords,
      if (qualificationRequirements != null)
        'QualificationRequirements': qualificationRequirements,
    },
  );

  return CreateHITTypeResponse.fromJson(jsonResponse.body);
}