예제 #1
0
파일: operations.go 프로젝트: jesand/crowds
// CreateHITFromHITTypeId creates a new Human Intelligence Task (HIT) from a
// HITTypeId.
func (client amtClient) CreateHITFromHITTypeId(hitTypeId, question string,
	hitLayoutId string, hitLayoutParameters map[string]string,
	lifetimeInSeconds, maxAssignments int,
	assignmentReviewPolicy, hitReviewPolicy *amtgen.TReviewPolicy,
	requesterAnnotation, uniqueRequestToken string) (
	amtgen.TxsdCreateHITResponse, error) {

	// Prepare the request
	var (
		args amtgen.TCreateHITRequest
	)
	args.HITTypeId = xsdt.String(hitTypeId)
	args.Question = xsdt.String(question)
	args.HITLayoutId = xsdt.String(hitLayoutId)
	var hitLayoutParameterOrder []string
	for name, _ := range hitLayoutParameters {
		hitLayoutParameterOrder = append(hitLayoutParameterOrder, name)
	}
	sort.Strings(hitLayoutParameterOrder)
	for _, name := range hitLayoutParameterOrder {
		value := hitLayoutParameters[name]
		var param amtgen.THITLayoutParameter
		param.Name = xsdt.String(name)
		param.Value = xsdt.String(value)
		args.HITLayoutParameters = append(args.HITLayoutParameters, &param)
	}
	args.LifetimeInSeconds = xsdt.Long(lifetimeInSeconds)
	args.MaxAssignments = xsdt.Int(maxAssignments)
	args.AssignmentReviewPolicy = assignmentReviewPolicy
	args.HITReviewPolicy = hitReviewPolicy
	args.RequesterAnnotation = xsdt.String(requesterAnnotation)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	return client.CreateHITFromArgs(args)
}
예제 #2
0
파일: operations.go 프로젝트: jesand/crowds
// CreateHIT creates a new Human Intelligence Task (HIT) without a HITTypeId.
func (client amtClient) CreateHIT(title, description, question string,
	hitLayoutId string, hitLayoutParameters map[string]string,
	reward float32, assignmentDurationInSeconds,
	lifetimeInSeconds, maxAssignments, autoApprovalDelayInSeconds int,
	keywords []string,
	qualificationRequirements []*amtgen.TQualificationRequirement,
	assignmentReviewPolicy, hitReviewPolicy *amtgen.TReviewPolicy,
	requesterAnnotation, uniqueRequestToken string) (
	amtgen.TxsdCreateHITResponse, error) {

	// Prepare the request
	var (
		args amtgen.TCreateHITRequest
	)
	args.Title = xsdt.String(title)
	args.Description = xsdt.String(description)
	args.Question = xsdt.String(question)
	args.HITLayoutId = xsdt.String(hitLayoutId)
	var hitLayoutParameterOrder []string
	for name, _ := range hitLayoutParameters {
		hitLayoutParameterOrder = append(hitLayoutParameterOrder, name)
	}
	sort.Strings(hitLayoutParameterOrder)
	for _, name := range hitLayoutParameterOrder {
		value := hitLayoutParameters[name]
		var param amtgen.THITLayoutParameter
		param.Name = xsdt.String(name)
		param.Value = xsdt.String(value)
		args.HITLayoutParameters = append(args.HITLayoutParameters, &param)
	}
	args.Reward = &amtgen.TPrice{}
	args.Reward.Amount = xsdt.Decimal(fmt.Sprint(reward))
	args.Reward.CurrencyCode = CURRENCY_USD
	args.AssignmentDurationInSeconds = xsdt.Long(assignmentDurationInSeconds)
	args.LifetimeInSeconds = xsdt.Long(lifetimeInSeconds)
	args.MaxAssignments = xsdt.Int(maxAssignments)
	args.AutoApprovalDelayInSeconds = xsdt.Long(autoApprovalDelayInSeconds)
	args.Keywords = xsdt.String(strings.Join(keywords, ","))
	args.QualificationRequirements = qualificationRequirements
	args.AssignmentReviewPolicy = assignmentReviewPolicy
	args.HITReviewPolicy = hitReviewPolicy
	args.RequesterAnnotation = xsdt.String(requesterAnnotation)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	return client.CreateHITFromArgs(args)
}