Exemplo n.º 1
0
// Add a binary option for a selection answer
func (question *QuestionForm) AddSelectionAnswerBinarySelection(
	selectionIdentifier, mimeType, mimeSubType string,
	dataURL *url.URL, altText string) {
	answer := question.getCurrentAnswer()
	if answer.SelectionAnswer == nil {
		answer.SelectionAnswer = &questionform.TSelectionAnswerType{}
	}
	if answer.SelectionAnswer.Selections == nil {
		answer.SelectionAnswer.Selections = &questionform.TxsdSelectionAnswerTypeSequenceSelections{}
	}
	selection := &questionform.TxsdSelectionAnswerTypeSequenceSelectionsSequenceSelection{}
	selection.SelectionIdentifier = xsdt.String(selectionIdentifier)
	selection.Binary = &questionform.TBinaryContentType{}
	if mimeType != "" || mimeSubType != "" {
		selection.Binary.MimeType = &questionform.TMimeType{}
		if mimeType != "" {
			selection.Binary.MimeType.Type = questionform.TxsdMimeTypeSequenceType(mimeType)
		}
		if mimeSubType != "" {
			selection.Binary.MimeType.SubType = xsdt.String(mimeSubType)
		}
	}
	selection.Binary.DataURL = questionform.TURLType(dataURL.String())
	if altText != "" {
		selection.Binary.AltText = xsdt.String(altText)
	}
	answer.SelectionAnswer.Selections.Selections = append(
		answer.SelectionAnswer.Selections.Selections, selection)
}
Exemplo n.º 2
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.º 3
0
// CreateQualificationType creates a new Qualification type.
func (client amtClient) CreateQualificationType(name, description string,
	keywords []string, retryDelayInSeconds int,
	qualificationTypeStatus, test, answerKey string,
	testDurationInSeconds int, autoGranted bool,
	autoGrantedValue int) (amtgen.TxsdCreateQualificationTypeResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdCreateQualificationType
		args     amtgen.TCreateQualificationTypeRequest
		response amtgen.TxsdCreateQualificationTypeResponse
	)
	args.Name = xsdt.String(name)
	args.Description = xsdt.String(description)
	args.Keywords = xsdt.String(strings.Join(keywords, ","))
	args.RetryDelayInSeconds = xsdt.Long(retryDelayInSeconds)
	args.QualificationTypeStatus = amtgen.TQualificationTypeStatus(
		qualificationTypeStatus)
	args.Test = xsdt.String(test)
	args.AnswerKey = xsdt.String(answerKey)
	args.TestDurationInSeconds = xsdt.Long(testDurationInSeconds)
	args.AutoGranted = xsdt.Boolean(autoGranted)
	args.AutoGrantedValue = xsdt.Int(autoGrantedValue)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("CreateQualificationType", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 4
0
// Add a new Question item, to be populated by subsequent content-adding method
// calls.
func (question *QuestionForm) AddQuestion(questionIdentifier,
	displayName string, isRequired bool) {

	qq := &questionform.TxsdQuestionFormSequenceChoiceQuestion{}
	qq.QuestionIdentifier = xsdt.String(questionIdentifier)
	qq.DisplayName = xsdt.String(displayName)
	qq.IsRequired = xsdt.Boolean(isRequired)

	question.Questions = append(question.Questions, qq)
	question.addedOverviewNext = append(question.addedOverviewNext, false)
}
Exemplo n.º 5
0
// Add a formatted content option for a selection answer
func (question *QuestionForm) AddSelectionAnswerFormattedContentSelection(
	selectionIdentifier, content string) {
	answer := question.getCurrentAnswer()
	if answer.SelectionAnswer == nil {
		answer.SelectionAnswer = &questionform.TSelectionAnswerType{}
	}
	if answer.SelectionAnswer.Selections == nil {
		answer.SelectionAnswer.Selections = &questionform.TxsdSelectionAnswerTypeSequenceSelections{}
	}
	selection := &questionform.TxsdSelectionAnswerTypeSequenceSelectionsSequenceSelection{}
	selection.SelectionIdentifier = xsdt.String(selectionIdentifier)
	selection.FormattedContent = xsdt.String(content)
	answer.SelectionAnswer.Selections.Selections = append(
		answer.SelectionAnswer.Selections.Selections, selection)
}
Exemplo n.º 6
0
// Add default text for a free text answer specification
func (question *QuestionForm) AddFreeTextAnswerDefaultText(text string) {
	answer := question.getCurrentAnswer()
	if answer.FreeTextAnswer == nil {
		answer.FreeTextAnswer = &questionform.TFreeTextAnswerType{}
	}
	answer.FreeTextAnswer.DefaultText = xsdt.String(text)
}
Exemplo n.º 7
0
// GetAssignmentsForHIT retrieves completed assignments for a HIT.
func (client amtClient) GetAssignmentsForHIT(hitId string,
	assignmentStatuses []string, sortProperty string, sortAscending bool,
	pageSize, pageNumber int) (
	amtgen.TxsdGetAssignmentsForHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetAssignmentsForHIT
		args     amtgen.TGetAssignmentsForHITRequest
		response amtgen.TxsdGetAssignmentsForHITResponse
	)
	args.HITId = xsdt.String(hitId)
	for _, status := range assignmentStatuses {
		args.AssignmentStatuses = append(args.AssignmentStatuses,
			amtgen.TAssignmentStatus(status))
	}
	args.SortProperty = amtgen.TGetAssignmentsForHITSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetAssignmentsForHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 8
0
// GetReviewResultsForHIT retrieves the computed results and the actions taken
// in the course of executing your Review Policies during a CreateHIT operation.
func (client amtClient) GetReviewResultsForHIT(hitId string,
	policyLevels []string,
	retrieveActions, retrieveResults bool,
	pageSize, pageNumber int) (amtgen.TxsdGetReviewResultsForHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetReviewResultsForHIT
		args     amtgen.TGetReviewResultsForHITRequest
		response amtgen.TxsdGetReviewResultsForHITResponse
	)
	args.HITId = xsdt.String(hitId)
	for _, level := range policyLevels {
		args.PolicyLevels = append(args.PolicyLevels,
			amtgen.TReviewPolicyLevel(level))
	}
	args.RetrieveActions = xsdt.Boolean(retrieveActions)
	args.RetrieveResults = xsdt.Boolean(retrieveResults)
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetReviewResultsForHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 9
0
// SearchQualificationTypes searches for Qualification types using the specified
// search query, and returns a list of Qualification types.
func (client amtClient) SearchQualificationTypes(
	query, sortProperty string, sortAscending bool,
	pageSize, pageNumber int, mustBeRequestable, mustBeOwnedByCaller bool) (
	amtgen.TxsdSearchQualificationTypesResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdSearchQualificationTypes
		args     amtgen.TSearchQualificationTypesRequest
		response amtgen.TxsdSearchQualificationTypesResponse
	)
	args.Query = xsdt.String(query)
	args.SortProperty = amtgen.TSearchQualificationTypesSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	args.MustBeRequestable = xsdt.Boolean(mustBeRequestable)
	args.MustBeOwnedByCaller = xsdt.Boolean(mustBeOwnedByCaller)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("SearchQualificationTypes", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 10
0
// GetQualificationsForQualificationType returns all of the Qualifications
// granted to Workers for a given Qualification type.
func (client amtClient) GetQualificationsForQualificationType(
	qualificationTypeId string, isGranted bool,
	pageSize, pageNumber int) (
	amtgen.TxsdGetQualificationsForQualificationTypeResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetQualificationsForQualificationType
		args     amtgen.TGetQualificationsForQualificationTypeRequest
		response amtgen.TxsdGetQualificationsForQualificationTypeResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	if isGranted {
		args.Status = amtgen.TQualificationStatus("Granted")
	} else {
		args.Status = amtgen.TQualificationStatus("Revoked")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetQualificationsForQualificationType", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 11
0
// GetReviewableHITs retrieves the HITs with Status equal to Reviewable or
// Status equal to Reviewing that belong to the Requester calling the operation.
func (client amtClient) GetReviewableHITs(hitTypeId, status,
	sortProperty string, sortAscending bool,
	pageSize, pageNumber int) (amtgen.TxsdGetReviewableHITsResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetReviewableHITs
		args     amtgen.TGetReviewableHITsRequest
		response amtgen.TxsdGetReviewableHITsResponse
	)
	args.HITTypeId = xsdt.String(hitTypeId)
	args.Status = amtgen.TReviewableHITStatus(status)
	args.SortProperty = amtgen.TGetReviewableHITsSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetReviewableHITs", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 12
0
// 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)
}
Exemplo n.º 13
0
// Add an EmbeddedBinary item to the most recent Question/Overview added.
func (question *QuestionForm) AddEmbeddedBinaryContent(
	dataURL *url.URL, altText string, width, height int,
	applicationParameters map[string]string, mimeType, mimeSubType string) {
	binary := &questionform.TEmbeddedBinaryContentType{}
	binary.DataURL = questionform.TURLType(dataURL.String())
	binary.AltText = xsdt.String(altText)
	binary.Width = xsdt.String(fmt.Sprint(width))
	binary.Height = xsdt.String(fmt.Sprint(height))
	for key, value := range applicationParameters {
		param := &questionform.TApplicationParameter{}
		param.Name = xsdt.String(key)
		param.Value = xsdt.String(value)
		binary.ApplicationParameters = append(
			binary.ApplicationParameters, param)
	}
	if mimeType != "" || mimeSubType != "" {
		binary.EmbeddedMimeType = &questionform.TEmbeddedMimeType{}
		if mimeType != "" {
			binary.EmbeddedMimeType.Type = xsdt.String(mimeType)
		}
		if mimeSubType != "" {
			binary.EmbeddedMimeType.SubType = xsdt.String(mimeSubType)
		}
	}

	content := question.getCurrentContent()
	content.EmbeddedBinaries = append(content.EmbeddedBinaries, binary)
}
Exemplo n.º 14
0
// Add a List item to the most recent Question/Overview added.
func (question *QuestionForm) AddListContent(listItems []string) {
	list := &questionform.TxsdContentTypeChoiceList{}
	for _, listItem := range listItems {
		list.ListItems = append(list.ListItems, xsdt.String(listItem))
	}

	content := question.getCurrentContent()
	content.Lists = append(content.Lists, list)
}
Exemplo n.º 15
0
// Add a Flash Application item to the most recent Question/Overview added.
func (question *QuestionForm) AddFlashApplicationContent(flashMovieURL *url.URL,
	width, height int, applicationParameters map[string]string) {
	application := &questionform.TApplicationContentType{}
	application.Flash = &questionform.TFlashContentType{}
	application.Flash.FlashMovieURL = questionform.TURLType(flashMovieURL.String())
	application.Flash.Width = xsdt.String(fmt.Sprint(width))
	application.Flash.Height = xsdt.String(fmt.Sprint(height))
	for key, value := range applicationParameters {
		param := &questionform.TApplicationParameter{}
		param.Name = xsdt.String(key)
		param.Value = xsdt.String(value)
		application.Flash.ApplicationParameters = append(
			application.Flash.ApplicationParameters, param)
	}

	content := question.getCurrentContent()
	content.Applications = append(content.Applications, application)
}
Exemplo n.º 16
0
// ApproveRejectedAssignment approves an assignment that was previously
// rejected.
func (client amtClient) ApproveRejectedAssignment(assignmentId,
	requesterFeedback string) (amtgen.TxsdApproveRejectedAssignmentResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdApproveRejectedAssignment
		args     amtgen.TApproveRejectedAssignmentRequest
		response amtgen.TxsdApproveRejectedAssignmentResponse
	)
	args.AssignmentId = xsdt.String(assignmentId)
	args.RequesterFeedback = xsdt.String(requesterFeedback)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("ApproveRejectedAssignment", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 17
0
// Add a Binary item to the most recent Question/Overview added.
func (question *QuestionForm) AddBinaryContent(mimeType, mimeSubType string,
	dataURL *url.URL, altText string) {
	binary := &questionform.TBinaryContentType{}
	if mimeType != "" || mimeSubType != "" {
		binary.MimeType = &questionform.TMimeType{}
		if mimeType != "" {
			binary.MimeType.Type = questionform.TxsdMimeTypeSequenceType(mimeType)
		}
		if mimeSubType != "" {
			binary.MimeType.SubType = xsdt.String(mimeSubType)
		}
	}
	binary.DataURL = questionform.TURLType(dataURL.String())
	if altText != "" {
		binary.AltText = xsdt.String(altText)
	}

	content := question.getCurrentContent()
	content.Binaries = append(content.Binaries, binary)
}
Exemplo n.º 18
0
// BlockWorker allows you to prevent a Worker from working on your HITs.
func (client amtClient) BlockWorker(workerId, reason string) (
	amtgen.TxsdBlockWorkerResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdBlockWorker
		args     amtgen.TBlockWorkerRequest
		response amtgen.TxsdBlockWorkerResponse
	)
	args.WorkerId = xsdt.String(workerId)
	args.Reason = xsdt.String(reason)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("BlockWorker", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 19
0
// ChangeHITTypeOfHIT allows you to change the HITType properties of a HIT.
func (client amtClient) ChangeHITTypeOfHIT(hitId, hitTypeId string) (
	amtgen.TxsdChangeHITTypeOfHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdChangeHITTypeOfHIT
		args     amtgen.TChangeHITTypeOfHITRequest
		response amtgen.TxsdChangeHITTypeOfHITResponse
	)
	args.HITId = xsdt.String(hitId)
	args.HITTypeId = xsdt.String(hitTypeId)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("ChangeHITTypeOfHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 20
0
// GetFileUploadURL generates and returns a temporary URL.
func (client amtClient) GetFileUploadURL(assignmentId,
	questionIdentifier string) (
	amtgen.TxsdGetFileUploadURLResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetFileUploadURL
		args     amtgen.TGetFileUploadURLRequest
		response amtgen.TxsdGetFileUploadURLResponse
	)
	args.AssignmentId = xsdt.String(assignmentId)
	args.QuestionIdentifier = xsdt.String(questionIdentifier)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetFileUploadURL", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 21
0
// RejectQualificationRequest rejects a user's request for a Qualification.
func (client amtClient) RejectQualificationRequest(qualificationRequestId,
	reason string) (
	amtgen.TxsdRejectQualificationRequestResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdRejectQualificationRequest
		args     amtgen.TRejectQualificationRequestRequest
		response amtgen.TxsdRejectQualificationRequestResponse
	)
	args.QualificationRequestId = xsdt.String(qualificationRequestId)
	args.Reason = xsdt.String(reason)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("RejectQualificationRequest", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 22
0
// GetQualificationScore returns the value of a Worker's Qualification for a
// given Qualification type.
func (client amtClient) GetQualificationScore(
	qualificationTypeId, subjectId string) (
	amtgen.TxsdGetQualificationScoreResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetQualificationScore
		args     amtgen.TGetQualificationScoreRequest
		response amtgen.TxsdGetQualificationScoreResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	args.SubjectId = xsdt.String(subjectId)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetQualificationScore", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 23
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.º 24
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)
}
Exemplo n.º 25
0
// Add a JavaApplet Application item to the most recent Question/Overview added.
func (question *QuestionForm) AddJavaAppletApplicationContent(
	appletFilename string, width, height int,
	applicationParameters map[string]string, appletPath *url.URL) {
	application := &questionform.TApplicationContentType{}
	application.JavaApplet = &questionform.TJavaAppletContentType{}
	application.JavaApplet.AppletFilename = xsdt.String(appletFilename)
	application.JavaApplet.Width = xsdt.String(fmt.Sprint(width))
	application.JavaApplet.Height = xsdt.String(fmt.Sprint(height))
	for key, value := range applicationParameters {
		param := &questionform.TApplicationParameter{}
		param.Name = xsdt.String(key)
		param.Value = xsdt.String(value)
		application.JavaApplet.ApplicationParameters = append(
			application.JavaApplet.ApplicationParameters, param)
	}
	if appletPath != nil {
		application.JavaApplet.AppletPath = questionform.TURLType(appletPath.String())
	}

	content := question.getCurrentContent()
	content.Applications = append(content.Applications, application)
}
Exemplo n.º 26
0
// UpdateQualificationScore changes the value of a Qualification previously
// granted to a Worker.
func (client amtClient) UpdateQualificationScore(qualificationTypeId,
	subjectId string, integerValue int) (
	amtgen.TxsdUpdateQualificationScoreResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdUpdateQualificationScore
		args     amtgen.TUpdateQualificationScoreRequest
		response amtgen.TxsdUpdateQualificationScoreResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	args.SubjectId = xsdt.String(subjectId)
	args.IntegerValue = xsdt.Int(integerValue)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("UpdateQualificationScore", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 27
0
// NotifyWorkers sends an email to one or more Workers that you specify with
// the Worker ID.
func (client amtClient) NotifyWorkers(subject, messageText string,
	workerIds []string) (amtgen.TxsdNotifyWorkersResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdNotifyWorkers
		args     amtgen.TNotifyWorkersRequest
		response amtgen.TxsdNotifyWorkersResponse
	)
	args.Subject = xsdt.String(subject)
	args.MessageText = xsdt.String(messageText)
	for _, workerId := range workerIds {
		args.WorkerIds = append(args.WorkerIds, xsdt.String(workerId))
	}
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("NotifyWorkers", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 28
0
// GetBonusPayments retrieves the amounts of bonuses you have paid to Workers
// for a given HIT or assignment.
func (client amtClient) GetBonusPayments(hitId, assignmentId string,
	pageSize, pageNumber int) (
	amtgen.TxsdGetBonusPaymentsResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetBonusPayments
		args     amtgen.TGetBonusPaymentsRequest
		response amtgen.TxsdGetBonusPaymentsResponse
	)
	args.HITId = xsdt.String(hitId)
	args.AssignmentId = xsdt.String(assignmentId)
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetBonusPayments", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 29
0
// AssignQualification gives a Worker a Qualification.
func (client amtClient) AssignQualification(qualificationTypeId,
	workerId string, integerValue int, sendNotification bool) (
	amtgen.TxsdAssignQualificationResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdAssignQualification
		args     amtgen.TAssignQualificationRequest
		response amtgen.TxsdAssignQualificationResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	args.WorkerId = xsdt.String(workerId)
	args.IntegerValue = xsdt.Int(integerValue)
	args.SendNotification = xsdt.Boolean(sendNotification)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("AssignQualification", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
Exemplo n.º 30
0
// ExtendHIT increases the maximum number of assignments, or extends the
// expiration date, of an existing HIT.
func (client amtClient) ExtendHIT(hitId string,
	maxAssignmentsIncrement, expirationIncrementInSeconds int,
	uniqueRequestToken string) (
	amtgen.TxsdExtendHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdExtendHIT
		args     amtgen.TExtendHITRequest
		response amtgen.TxsdExtendHITResponse
	)
	args.HITId = xsdt.String(hitId)
	args.MaxAssignmentsIncrement = xsdt.Int(maxAssignmentsIncrement)
	args.ExpirationIncrementInSeconds = xsdt.Long(expirationIncrementInSeconds)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("ExtendHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}