Exemplo n.º 1
0
// GrantBonus issues a payment of money from your account to a Worker.
func (client amtClient) GrantBonus(workerId, assignmentId string,
	bonusAmount float32, reason, uniqueRequestToken string) (
	amtgen.TxsdGrantBonusResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGrantBonus
		args     amtgen.TGrantBonusRequest
		response amtgen.TxsdGrantBonusResponse
	)
	args.WorkerId = xsdt.String(workerId)
	args.AssignmentId = xsdt.String(assignmentId)
	args.BonusAmount = &amtgen.TPrice{}
	args.BonusAmount.Amount = xsdt.Decimal(fmt.Sprint(bonusAmount))
	args.BonusAmount.CurrencyCode = CURRENCY_USD
	args.Reason = xsdt.String(reason)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GrantBonus", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 2
0
// 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)
}
Exemplo n.º 3
0
// RegisterHITType creates a new HIT type.
func (client amtClient) RegisterHITType(title, description string,
	reward float32, assignmentDurationInSeconds, autoApprovalDelayInSeconds int,
	keywords []string,
	qualificationRequirements []*amtgen.TQualificationRequirement) (
	amtgen.TxsdRegisterHITTypeResponse, error) {

	// Prepare the request
	var (
		args amtgen.TRegisterHITTypeRequest
	)
	args.Title = xsdt.String(title)
	args.Description = xsdt.String(description)
	args.Reward = &amtgen.TPrice{}
	args.Reward.Amount = xsdt.Decimal(fmt.Sprint(reward))
	args.Reward.CurrencyCode = CURRENCY_USD
	args.AssignmentDurationInSeconds = xsdt.Long(assignmentDurationInSeconds)
	args.AutoApprovalDelayInSeconds = xsdt.Long(autoApprovalDelayInSeconds)
	args.Keywords = xsdt.String(strings.Join(keywords, ","))
	args.QualificationRequirements = qualificationRequirements

	return client.RegisterHITTypeFromArgs(args)
}