model

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package model defines the data structures representing Prolific domain entities such as studies, submissions, workspaces, projects, and users. These types are used for JSON serialization when communicating with the Prolific API.

Index

Constants

View Source
const (
	// StatusUnpublished is a valid study status
	StatusUnpublished = "unpublished"
	// StatusActive is a valid study status
	StatusActive = "active"
	// StatusScheduled is a valid study status
	StatusScheduled = "scheduled"
	// StatusAwaitingReview is a valid study status
	StatusAwaitingReview = "awaiting review"
	// StatusCompleted is a valid study status
	StatusCompleted = "completed"
	// StatusAll is a mock status that allows us to list all studies.
	StatusAll = "all"
)
View Source
const (
	// TransitionStudyPublish will allow us to publish a study
	TransitionStudyPublish = "PUBLISH"
	// TransitionStudyPause will allow us to pause a study
	TransitionStudyPause = "PAUSE"
	// TransitionStudyStart will allow us to start a study
	TransitionStudyStart = "START"
	// TransitionStudyStop will allow us to stop a study
	TransitionStudyStop = "STOP"
)
View Source
const (
	// DataCollectionMethodAITBCollection is the data collection method for AI Task Builder Collections
	DataCollectionMethodAITBCollection = "AI_TASK_BUILDER_COLLECTION"
)
View Source
const DefaultCurrency string = "GBP"

DefaultCurrency is set to GBP if we cannot figure out what currency to render based on other factors.

Variables

StudyListStatus represents what status we can filter on for the list

StudyStatuses represents the allows statuses for the system

TransitionList is the list of transitions we can use on a Study.

Functions

This section is empty.

Types

type AITaskBuilderAnswerOption

type AITaskBuilderAnswerOption struct {
	// For free_text, free_text_with_unit, multiple_choice, multiple_choice_with_free_text
	Value string `json:"value,omitempty"`
	// For free_text_with_unit
	Unit string `json:"unit,omitempty"`
	// For multiple_choice_with_free_text
	Explanation string `json:"explanation,omitempty"`
	// For file_upload
	FileKey     string  `json:"file_key,omitempty"`
	FileName    string  `json:"file_name,omitempty"`
	FileSizeMB  float64 `json:"file_size_mb,omitempty"`
	ContentType string  `json:"content_type,omitempty"`
}

AITaskBuilderAnswerOption represents an answer option in a response. The fields used depend on the response type: - free_text: value - free_text_with_unit: value, unit - multiple_choice: value - multiple_choice_with_free_text: value, explanation - file_upload: file_key, file_name, file_size_mb, content_type

type AITaskBuilderBatch

type AITaskBuilderBatch struct {
	ID                    string                       `json:"id"`
	CreatedAt             time.Time                    `json:"created_at"`
	CreatedBy             string                       `json:"created_by"`
	Datasets              []Dataset                    `json:"datasets"`
	Name                  string                       `json:"name"`
	Status                AITaskBuilderBatchStatusEnum `json:"status"`
	TasksPerGroup         int                          `json:"tasks_per_group"`
	TotalTaskCount        int                          `json:"total_task_count"`
	TotalInstructionCount int                          `json:"total_instruction_count"`
	WorkspaceID           string                       `json:"workspace_id"`
	SchemaVersion         int                          `json:"schema_version"`
	TaskDetails           TaskDetails                  `json:"task_details"`
}

AITaskBuilderBatch represents an AI Task Builder batch.

type AITaskBuilderBatchStatus

type AITaskBuilderBatchStatus struct {
	Status AITaskBuilderBatchStatusEnum `json:"status"`
}

AITaskBuilderBatchStatus represents the status of an AI Task Builder batch.

type AITaskBuilderBatchStatusEnum

type AITaskBuilderBatchStatusEnum string
const (
	// UNINITIALISED: the batch has been created, but contains no tasks.
	AITaskBuilderBatchStatusUninitialised AITaskBuilderBatchStatusEnum = "UNINITIALISED"
	// PROCESSING: The batch is being processed into tasks.
	AITaskBuilderBatchStatusProcessing AITaskBuilderBatchStatusEnum = "PROCESSING"
	// READY: The batch is processed and ready to be attached to a Prolific study.
	AITaskBuilderBatchStatusReady AITaskBuilderBatchStatusEnum = "READY"
	// ERROR: The batch has encountered an error and the data may not be usable.
	AITaskBuilderBatchStatusError AITaskBuilderBatchStatusEnum = "ERROR"
)

type AITaskBuilderResponse

type AITaskBuilderResponse struct {
	ID            string                    `json:"id"`
	BatchID       string                    `json:"batch_id"`
	ParticipantID string                    `json:"participant_id"`
	TaskID        string                    `json:"task_id"`
	CorrelationID string                    `json:"correlation_id"`
	SubmissionID  string                    `json:"submission_id"`
	Metadata      map[string]string         `json:"metadata"`
	Response      AITaskBuilderResponseData `json:"response"`
	CreatedAt     time.Time                 `json:"created_at"`
	SchemaVersion int                       `json:"schema_version"`
}

AITaskBuilderResponse represents a response from an AI Task Builder batch task.

type AITaskBuilderResponseData

type AITaskBuilderResponseData struct {
	InstructionID string                      `json:"instruction_id"`
	Type          AITaskBuilderResponseType   `json:"type"`
	Answer        []AITaskBuilderAnswerOption `json:"answer"`
}

AITaskBuilderResponseData represents the response data structure. This is a discriminated union based on the Type field. All response types use the Answer array with different object structures.

type AITaskBuilderResponseType

type AITaskBuilderResponseType string

AITaskBuilderResponseType represents the type of response.

const (
	AITaskBuilderResponseTypeFreeText                   AITaskBuilderResponseType = "free_text"
	AITaskBuilderResponseTypeMultipleChoice             AITaskBuilderResponseType = "multiple_choice"
	AITaskBuilderResponseTypeMultipleChoiceWithFreeText AITaskBuilderResponseType = "multiple_choice_with_free_text"
	AITaskBuilderResponseTypeFreeTextWithUnit           AITaskBuilderResponseType = "free_text_with_unit"
	AITaskBuilderResponseTypeFileUpload                 AITaskBuilderResponseType = "file_upload"
)

type AccessDetail added in v0.0.65

type AccessDetail struct {
	ExternalURL     string  `json:"external_url" mapstructure:"external_url"`
	TotalAllocation float64 `json:"total_allocation" mapstructure:"total_allocation"`
}

AccessDetail represents a taskflow access URL with its participant allocation.

type BaseEntity added in v0.0.58

type BaseEntity struct {
	ID             string     `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	CreatedBy      string     `json:"created_by,omitempty" yaml:"created_by,omitempty" mapstructure:"created_by"`
	CreatedAt      *time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty" mapstructure:"created_at"`
	SchemaVersion  int        `json:"schema_version,omitempty" yaml:"schema_version,omitempty" mapstructure:"schema_version"`
	LastModifiedAt *time.Time `json:"last_modified_at,omitempty" yaml:"last_modified_at,omitempty" mapstructure:"last_modified_at"`
	LastModifiedBy string     `json:"last_modified_by,omitempty" yaml:"last_modified_by,omitempty" mapstructure:"last_modified_by"`
}

BaseEntity contains common fields for all collection entities

type Campaign

type Campaign struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	SignupLink string `json:"sign_up_link"`
}

type Collection added in v0.0.58

type Collection struct {
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	CreatedAt   time.Time    `json:"created_at"`
	CreatedBy   string       `json:"created_by"`
	ItemCount   int          `json:"item_count"`
	TaskDetails *TaskDetails `json:"task_details,omitempty"`
}

Collection represents a Prolific Collection

func (Collection) Description added in v0.0.58

func (c Collection) Description() string

Description will set the secondary string for the view.

func (Collection) FilterValue added in v0.0.58

func (c Collection) FilterValue() string

FilterValue will help the bubbletea views run

func (Collection) Title added in v0.0.58

func (c Collection) Title() string

Title will set the main string for the view.

type CollectionInstruction added in v0.0.58

type CollectionInstruction = CollectionPageItem

CollectionInstruction is an alias for CollectionPageItem for backward compatibility. Deprecated: Use CollectionPageItem instead.

type CollectionPage added in v0.0.58

type CollectionPage struct {
	Order     int                     `json:"order" mapstructure:"order"`
	PageItems []CollectionInstruction `json:"page_items" mapstructure:"page_items"`
}

CollectionPage represents a page in a collection containing instructions.

type CollectionPageItem added in v0.0.58

type CollectionPageItem struct {
	Order int    `json:"order" mapstructure:"order"`
	Type  string `json:"type" mapstructure:"type"`

	// Instruction fields (for free_text, multiple_choice, multiple_choice_with_free_text, free_text_with_unit, file_upload)
	Description          string              `json:"description,omitempty" mapstructure:"description"`
	Options              []InstructionOption `json:"options,omitempty" mapstructure:"options"`
	AnswerLimit          *int                `json:"answer_limit,omitempty" mapstructure:"answer_limit"`
	PlaceholderTextInput string              `json:"placeholder_text_input,omitempty" mapstructure:"placeholder_text_input"`
	DisableDropdown      *bool               `json:"disable_dropdown,omitempty" mapstructure:"disable_dropdown"`
	HelperText           string              `json:"helper_text,omitempty" mapstructure:"helper_text"`
	Validation           *ValidationRule     `json:"validation,omitempty" mapstructure:"validation"`

	// Unit fields (for free_text_with_unit)
	UnitOptions  []UnitOption `json:"unit_options,omitempty" mapstructure:"unit_options"`
	DefaultUnit  string       `json:"default_unit,omitempty" mapstructure:"default_unit"`
	UnitPosition UnitPosition `json:"unit_position,omitempty" mapstructure:"unit_position"`

	// File upload fields (for file_upload)
	AcceptedFileTypes []string `json:"accepted_file_types,omitempty" mapstructure:"accepted_file_types"`
	MaxFileSizeMB     *float64 `json:"max_file_size_mb,omitempty" mapstructure:"max_file_size_mb"`
	MinFileCount      *int     `json:"min_file_count,omitempty" mapstructure:"min_file_count"`
	MaxFileCount      *int     `json:"max_file_count,omitempty" mapstructure:"max_file_count"`

	// Content block fields (for rich_text)
	Content       string        `json:"content,omitempty" mapstructure:"content"`
	ContentFormat ContentFormat `json:"content_format,omitempty" mapstructure:"content_format"`

	// Content block fields (for image)
	URL     string `json:"url,omitempty" mapstructure:"url"`
	AltText string `json:"alt_text,omitempty" mapstructure:"alt_text"`
	Caption string `json:"caption,omitempty" mapstructure:"caption"`
}

CollectionPageItem represents an item within a collection page. This can be either an instruction (interactive) or a content block (non-interactive). The Type field determines which other fields are relevant. Use InstructionType constants from collection.go for the Type field.

type CompletionCode added in v0.0.58

type CompletionCode struct {
	Code     string           `json:"code" mapstructure:"code"`
	CodeType string           `json:"code_type" mapstructure:"code_type"`
	Actions  []map[string]any `json:"actions" mapstructure:"actions"`
}

CompletionCode represents a study completion code with its type and actions.

type ContentFormat added in v0.0.59

type ContentFormat string

ContentFormat represents the format of rich text content

const (
	// ContentFormatHTML means the content is HTML
	ContentFormatHTML ContentFormat = "html"
	// ContentFormatMarkdown means the content is Markdown, converted to HTML server-side
	ContentFormatMarkdown ContentFormat = "markdown"
)

type CreateAITaskBuilderCollection added in v0.0.58

type CreateAITaskBuilderCollection struct {
	WorkspaceID     string           `json:"workspace_id" mapstructure:"workspace_id"`
	Name            string           `json:"name" mapstructure:"name"`
	TaskDetails     *TaskDetails     `json:"task_details,omitempty" mapstructure:"task_details"`
	CollectionItems []CollectionPage `json:"collection_items" mapstructure:"collection_items"`
}

CreateAITaskBuilderCollection represents the payload for creating a collection.

type CreateFilterSet added in v1.0.0

type CreateFilterSet struct {
	Name           string   `json:"name,omitempty" mapstructure:"name"`
	WorkspaceID    string   `json:"workspace_id,omitempty" mapstructure:"workspace_id"`
	OrganisationID string   `json:"organisation_id,omitempty" mapstructure:"organisation_id"`
	Filters        []Filter `json:"filters,omitempty" mapstructure:"filters"`
}

CreateFilterSet holds the fields needed to create a new filter set.

type CreateInvitation added in v1.0.0

type CreateInvitation struct {
	Association string   `json:"association"`
	Emails      []string `json:"emails"`
	Role        string   `json:"role"`
}

CreateInvitation is the request body for creating invitations.

type CreateParticipantGroup added in v1.0.0

type CreateParticipantGroup struct {
	Name           string   `json:"name"`
	WorkspaceID    string   `json:"workspace_id,omitempty"`
	Description    string   `json:"description,omitempty"`
	ParticipantIDs []string `json:"participant_ids,omitempty"`
}

CreateParticipantGroup is the payload to create a new participant group

type CreateStudy

type CreateStudy struct {
	Name             string `json:"name" mapstructure:"name"`
	InternalName     string `json:"internal_name" mapstructure:"internal_name"`
	Description      string `json:"description" mapstructure:"description"`
	ExternalStudyURL string `json:"external_study_url,omitempty" mapstructure:"external_study_url"`
	// Enum "question", "url_parameters" (Recommended), "not_required"
	ProlificIDOption string `json:"prolific_id_option" mapstructure:"prolific_id_option"`
	CompletionCode   string `json:"completion_code,omitempty" mapstructure:"completion_code"`
	// Enum: "url", "code"
	CompletionOption     string           `json:"completion_option,omitempty" mapstructure:"completion_option"`
	CompletionCodes      []CompletionCode `json:"completion_codes,omitempty" mapstructure:"completion_codes"`
	TotalAvailablePlaces int              `json:"total_available_places" mapstructure:"total_available_places"`
	// Minutes
	EstimatedCompletionTime int     `json:"estimated_completion_time" mapstructure:"estimated_completion_time"`
	MaximumAllowedTime      int     `json:"maximum_allowed_time,omitempty" mapstructure:"maximum_allowed_time"`
	Reward                  float64 `json:"reward" mapstructure:"reward"`
	// Enum: "desktop", "tablet", "mobile"
	DeviceCompatibility []string `json:"device_compatibility" mapstructure:"device_compatibility"`
	// Enum: "SINGLE", "QUOTA" (required for weighted filters)
	StudyType string `json:"study_type,omitempty" mapstructure:"study_type"`
	// Enum: "audio", "camera", "download", "microphone"
	PeripheralRequirements []string `json:"peripheral_requirements,omitempty" mapstructure:"peripheral_requirements"`
	// Study labels for categorization (e.g., "ai_annotation")
	StudyLabels []string `json:"study_labels,omitempty" mapstructure:"study_labels"`
	// Access details collection ID: ID of the collection to attach to the study (for Taskflow studies)
	AccessDetailsCollectionID string `json:"access_details_collection_id,omitempty" mapstructure:"access_details_collection_id"`
	// Data collection method: "AI_TASK_BUILDER", "DC_TOOL", or "HUMAN_SIGNAL"
	DataCollectionMethod string `json:"data_collection_method,omitempty" mapstructure:"data_collection_method"`
	// Data collection ID: Project/collection/batch ID for data collection
	DataCollectionID string `json:"data_collection_id,omitempty" mapstructure:"data_collection_id"`
	// Data collection metadata: Configuration parameters (optional dict)
	DataCollectionMetadata map[string]any `json:"data_collection_metadata,omitempty" mapstructure:"data_collection_metadata"`
	SubmissionsConfig      struct {
		MaxSubmissionsPerParticipant int      `json:"max_submissions_per_participant,omitempty" mapstructure:"max_submissions_per_participant"`
		MaxConcurrentSubmissions     int      `json:"max_concurrent_submissions,omitempty" mapstructure:"max_concurrent_submissions"`
		AutoRejectionCategories      []string `json:"auto_rejection_categories,omitempty" mapstructure:"auto_rejection_categories"`
	} `json:"submissions_config" mapstructure:"submissions_config"`
	EligibilityRequirements []struct {
		Attributes []struct {
			ID    string `json:"id" mapstructure:"id"`
			Index any    `json:"index,omitempty" mapstructure:"index,omitempty"`
			Value any    `json:"value" mapstructure:"value"`
		} `json:"attributes" mapstructure:"attributes"`
		Query struct {
			ID string `json:"id" mapstructure:"id"`
		} `json:"query" mapstructure:"query"`
		Cls string `json:"_cls" mapstructure:"_cls"`
	} `json:"eligibility_requirements,omitempty" mapstructure:"eligibility_requirements"`
	Filters          []Filter       `json:"filters,omitempty" mapstructure:"filters"`
	FilterSetID      string         `json:"filter_set_id,omitempty" mapstructure:"filter_set_id"`
	AccessDetails    []AccessDetail `json:"access_details,omitempty" mapstructure:"access_details"`
	Project          string         `json:"project,omitempty" mapstructure:"project"`
	CredentialPoolID string         `json:"credential_pool_id,omitempty" mapstructure:"credential_pool_id"`
}

CreateStudy is responsible for capturing what fields we need to send to Prolific to create a study. The `mapstructure` is so we can take a viper configuration file.

type CreateSurvey added in v1.0.0

type CreateSurvey struct {
	ResearcherID string           `json:"researcher_id,omitempty" mapstructure:"researcher_id"`
	Title        string           `json:"title" mapstructure:"title"`
	Sections     []SurveySection  `json:"sections,omitempty" mapstructure:"sections"`
	Questions    []SurveyQuestion `json:"questions,omitempty" mapstructure:"questions"`
}

CreateSurvey is the request model for creating a survey.

type CreateSurveyResponseRequest added in v1.0.0

type CreateSurveyResponseRequest struct {
	ParticipantID string                   `json:"participant_id" mapstructure:"participant_id"`
	SubmissionID  string                   `json:"submission_id" mapstructure:"submission_id"`
	Sections      []SurveyResponseSection  `json:"sections,omitempty" mapstructure:"sections"`
	Questions     []SurveyQuestionResponse `json:"questions,omitempty" mapstructure:"questions"`
}

CreateSurveyResponseRequest is the request model for creating a survey response.

type Dataset

type Dataset struct {
	ID                  string        `json:"id"`
	Name                string        `json:"name"`
	CreatedAt           string        `json:"created_at"`
	CreatedBy           string        `json:"created_by"`
	Status              DatasetStatus `json:"status"`
	TotalDatapointCount int           `json:"total_datapoint_count"`
	WorkspaceID         string        `json:"workspace_id"`
}

Dataset represents a dataset in a batch.

type DatasetStatus added in v0.0.57

type DatasetStatus string

DatasetStatus represents the status of a dataset.

const (
	// DatasetStatusUninitialised means the dataset has been created but no data has been uploaded.
	DatasetStatusUninitialised DatasetStatus = "UNINITIALISED"
	// DatasetStatusProcessing means the dataset is being processed into datapoints.
	DatasetStatusProcessing DatasetStatus = "PROCESSING"
	// DatasetStatusReady means the dataset is ready to be used within a batch.
	DatasetStatusReady DatasetStatus = "READY"
	// DatasetStatusError means something went wrong during processing.
	DatasetStatusError DatasetStatus = "ERROR"
)

type Filter

type Filter struct {
	ID                string            `json:"id,omitempty" mapstructure:"id"`
	FilterID          string            `json:"filter_id" mapstructure:"filter_id"`
	FilterTitle       string            `json:"title,omitempty" mapstructure:"title"`
	FilterDescription string            `json:"description,omitempty" mapstructure:"description"`
	Question          string            `json:"question,omitempty" mapstructure:"question"`
	Type              string            `json:"type,omitempty" mapstructure:"type"`
	DataType          string            `json:"data_type,omitempty" mapstructure:"data_type"`
	Min               any               `json:"min,omitempty" mapstructure:"min"`
	Max               any               `json:"max,omitempty" mapstructure:"max"`
	Choices           map[string]string `json:"choices,omitempty" mapstructure:"choices"`
	SelectedValues    []string          `json:"selected_values,omitempty" mapstructure:"selected_values"`
	SelectedRange     *FilterRange      `json:"selected_range,omitempty" mapstructure:"selected_range"`
	Weightings        map[string]any    `json:"weightings,omitempty" mapstructure:"weightings"`
}

Filter holds information about the filter that makes up a filter set

func (Filter) Description

func (f Filter) Description() string

Description will return the description of the filter

func (Filter) FilterValue

func (f Filter) FilterValue() string

FilterValue will help the bubbletea views run

func (Filter) Title

func (f Filter) Title() string

Title will return the title of the filter

type FilterRange

type FilterRange struct {
	Lower any `json:"lower,omitempty" mapstructure:"lower"`
	Upper any `json:"upper,omitempty" mapstructure:"upper"`
}

FilterRange holds the lower and upper bounds of a filter

type FilterSet

type FilterSet struct {
	ID                       string   `json:"id" mapstructure:"id"`
	Name                     string   `json:"name" mapstructure:"name"`
	OrganisationID           string   `json:"organisation_id" mapstructure:"organisation_id"`
	WorkspaceID              string   `json:"workspace_id" mapstructure:"workspace_id"`
	Version                  int      `json:"version" mapstructure:"version"`
	IsDeleted                bool     `json:"is_deleted" mapstructure:"is_deleted"`
	IsLocked                 bool     `json:"is_locked" mapstructure:"is_locked"`
	EligibleParticipantCount int      `json:"eligible_participant_count" mapstructure:"eligible_participant_count"`
	Filters                  []Filter `json:"filters" mapstructure:"filters"`
}

FilterSet holds information about the filter

type Hook

type Hook struct {
	ID          string `json:"id"`
	EventType   string `json:"event_type"`
	TargetURL   string `json:"target_url"`
	IsEnabled   bool   `json:"is_enabled"`
	WorkspaceID string `json:"workspace_id"`
}

Hook represents a subscription to an event

type HookEvent

type HookEvent struct {
	ID          string    `json:"id"`
	DateCreated time.Time `json:"datetime_created"`
	DateUpdated time.Time `json:"datetime_updated"`
	EventType   string    `json:"event_type"`
	ResourceID  string    `json:"resource_id"`
	Status      string    `json:"status"`
	TargetURL   string    `json:"target_url"`
}

HookEvent represents a point when Prolific notified the target URL of the event that the user has subscribed to.

type HookEventType

type HookEventType struct {
	EventType   string `json:"event_type"`
	Description string `json:"description"`
}

HookEventType represents event types that are available to register on the webhook subscription

type Instruction added in v0.0.57

type Instruction struct {
	ID                   string              `json:"id"`
	Type                 string              `json:"type"`
	BatchID              string              `json:"batch_id"`
	CreatedBy            string              `json:"created_by"`
	CreatedAt            string              `json:"created_at"`
	Description          string              `json:"description"`
	Options              []InstructionOption `json:"options,omitempty"`
	UnitOptions          []UnitOption        `json:"unit_options,omitempty"`
	DefaultUnit          string              `json:"default_unit,omitempty"`
	UnitPosition         UnitPosition        `json:"unit_position,omitempty"`
	HelperText           string              `json:"helper_text,omitempty"`
	PlaceholderTextInput string              `json:"placeholder_text_input,omitempty"`
	Validation           *ValidationRule     `json:"validation,omitempty"`
	AcceptedFileTypes    []string            `json:"accepted_file_types,omitempty"`
	MaxFileSizeMB        *float64            `json:"max_file_size_mb,omitempty"`
	MinFileCount         *int                `json:"min_file_count,omitempty"`
	MaxFileCount         *int                `json:"max_file_count,omitempty"`
}

Instruction represents an instruction in a batch.

type InstructionOption added in v0.0.57

type InstructionOption struct {
	Label     string `json:"label"`
	Value     string `json:"value"`
	Heading   string `json:"heading,omitempty"`
	Exclusive bool   `json:"exclusive,omitempty"`
}

InstructionOption represents an option for multiple choice instructions.

type InstructionType added in v0.0.58

type InstructionType string

InstructionType represents the type of instruction

const (
	// Instruction types (interactive - participants respond to these)
	InstructionTypeFreeText                   InstructionType = "free_text"
	InstructionTypeMultipleChoice             InstructionType = "multiple_choice"
	InstructionTypeMultipleChoiceWithFreeText InstructionType = "multiple_choice_with_free_text"
	InstructionTypeFreeTextWithUnit           InstructionType = "free_text_with_unit"
	InstructionTypeFileUpload                 InstructionType = "file_upload"

	// Content block types (non-interactive - for context or guidance)
	ContentBlockTypeRichText InstructionType = "rich_text"
	ContentBlockTypeImage    InstructionType = "image"
)

type Invitation added in v1.0.0

type Invitation struct {
	Association string  `json:"association"`
	Invitee     Invitee `json:"invitee"`
	InvitedBy   string  `json:"invited_by"`
	Status      string  `json:"status"`
	InviteLink  string  `json:"invite_link"`
	Role        string  `json:"role"`
}

Invitation represents an invitation to collaborate on a workspace.

type Invitee added in v1.0.0

type Invitee struct {
	ID    *string `json:"id"`
	Name  *string `json:"name"`
	Email string  `json:"email"`
}

Invitee represents the user being invited.

type Message

type Message struct {
	ID              string       `json:"id"`
	SenderID        string       `json:"sender_id,omitempty"`
	Sender          string       `json:"sender,omitempty"`
	Body            string       `json:"body"`
	DatetimeCreated time.Time    `json:"datetime_created"`
	Type            string       `json:"type,omitempty"`
	ChannelID       string       `json:"channel_id"`
	Data            *MessageData `json:"data,omitempty"`
}

Message represents a message on the Prolific platform. The regular messages endpoint returns "sender_id" while the unread endpoint returns "sender", so both fields are present.

func (Message) GetSenderID added in v0.0.58

func (m Message) GetSenderID() string

GetSenderID returns the sender identifier regardless of which API endpoint populated the message. The regular messages endpoint uses "sender_id" while the unread endpoint uses "sender".

type MessageData added in v0.0.58

type MessageData struct {
	StudyID  string `json:"study_id,omitempty"`
	Category string `json:"category,omitempty"`
}

MessageData contains metadata associated with a message.

type MultipleChoiceOption added in v0.0.58

type MultipleChoiceOption struct {
	Label     string `json:"label" yaml:"label" mapstructure:"label"`
	Value     string `json:"value" yaml:"value" mapstructure:"value"`
	Heading   string `json:"heading,omitempty" yaml:"heading,omitempty" mapstructure:"heading"` // Required for multiple_choice_with_free_text
	Exclusive bool   `json:"exclusive,omitempty" yaml:"exclusive,omitempty" mapstructure:"exclusive"`
}

MultipleChoiceOption represents an option for multiple choice instructions

type Page added in v0.0.58

type Page struct {
	BaseEntity `yaml:",inline" mapstructure:",squash"`
	Order      int               `json:"order" yaml:"order" mapstructure:"order"`
	PageItems  []PageInstruction `json:"page_items" yaml:"page_items" mapstructure:"page_items"`
}

Page represents a single page within a collection.

type PageInstruction added in v0.0.58

type PageInstruction struct {
	BaseEntity `yaml:",inline" mapstructure:",squash"`

	// Required fields
	Type  InstructionType `json:"type" yaml:"type" mapstructure:"type"`
	Order int             `json:"order" yaml:"order" mapstructure:"order"`

	// Required for instruction types (free_text, multiple_choice, multiple_choice_with_free_text, free_text_with_unit, file_upload)
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description"`

	// Optional - for free_text and free_text_with_unit types
	PlaceholderTextInput string          `json:"placeholder_text_input,omitempty" yaml:"placeholder_text_input,omitempty" mapstructure:"placeholder_text_input"`
	HelperText           string          `json:"helper_text,omitempty" yaml:"helper_text,omitempty" mapstructure:"helper_text"`
	Validation           *ValidationRule `json:"validation,omitempty" yaml:"validation,omitempty" mapstructure:"validation"`

	// Optional - for multiple_choice and multiple_choice_with_free_text types
	AnswerLimit     int                    `json:"answer_limit,omitempty" yaml:"answer_limit,omitempty" mapstructure:"answer_limit"`
	Options         []MultipleChoiceOption `json:"options,omitempty" yaml:"options,omitempty" mapstructure:"options"`
	DisableDropdown *bool                  `json:"disable_dropdown,omitempty" yaml:"disable_dropdown,omitempty" mapstructure:"disable_dropdown"`

	// Optional - for free_text_with_unit type
	UnitOptions  []UnitOption `json:"unit_options,omitempty" yaml:"unit_options,omitempty" mapstructure:"unit_options"`
	DefaultUnit  string       `json:"default_unit,omitempty" yaml:"default_unit,omitempty" mapstructure:"default_unit"`
	UnitPosition UnitPosition `json:"unit_position,omitempty" yaml:"unit_position,omitempty" mapstructure:"unit_position"`

	// Optional - for file_upload type
	AcceptedFileTypes []string `json:"accepted_file_types,omitempty" yaml:"accepted_file_types,omitempty" mapstructure:"accepted_file_types"`
	MaxFileSizeMB     *float64 `json:"max_file_size_mb,omitempty" yaml:"max_file_size_mb,omitempty" mapstructure:"max_file_size_mb"`
	MinFileCount      *int     `json:"min_file_count,omitempty" yaml:"min_file_count,omitempty" mapstructure:"min_file_count"`
	MaxFileCount      *int     `json:"max_file_count,omitempty" yaml:"max_file_count,omitempty" mapstructure:"max_file_count"`

	// Content block fields - for rich_text type
	Content       string        `json:"content,omitempty" yaml:"content,omitempty" mapstructure:"content"`
	ContentFormat ContentFormat `json:"content_format,omitempty" yaml:"content_format,omitempty" mapstructure:"content_format"`

	// Content block fields - for image type
	URL     string `json:"url,omitempty" yaml:"url,omitempty" mapstructure:"url"`
	AltText string `json:"alt_text,omitempty" yaml:"alt_text,omitempty" mapstructure:"alt_text"`
	Caption string `json:"caption,omitempty" yaml:"caption,omitempty" mapstructure:"caption"`
}

PageInstruction represents a single page item within a collection page. This can be either an instruction (interactive) or a content block (non-interactive).

type ParticipantGroup

type ParticipantGroup struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	ProjectID        string `json:"project_id"`
	WorkspaceID      string `json:"workspace_id"`
	Description      string `json:"description"`
	ParticipantCount int    `json:"participant_count"`
}

ParticipantGroup holds information about the group

type ParticipantGroupMembership

type ParticipantGroupMembership struct {
	ParticipantID   string    `json:"participant_id"`
	DatetimeCreated time.Time `json:"datetime_created"`
}

ParticipantGroupMembership holds information about a member in a group

type Project

type Project struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Workspace   string `json:"workspace"`
	Owner       string `json:"owner"`
	Users       []User `json:"users"`
}

Project represents the project model

type Secret

type Secret struct {
	ID          string `json:"id"`
	Value       string `json:"value"`
	WorkspaceID string `json:"workspace_id"`
}

Secret represents the secrets passed back from Prolific.

type Study

type Study struct {
	ID                      string    `json:"id"`
	Name                    string    `json:"name"`
	InternalName            string    `json:"internal_name"`
	DateCreated             time.Time `json:"date_created"`
	TotalAvailablePlaces    int       `json:"total_available_places"`
	Reward                  float64   `json:"reward"`
	CanAutoReview           bool      `json:"can_auto_review"`
	EligibilityRequirements []struct {
		ID       string `json:"id"`
		Question struct {
			ID    string `json:"id"`
			Title string `json:"title"`
		} `json:"question"`
		DisplayDetails string `json:"details_display"`
	} `json:"eligibility_requirements"`
	Filters                 []Filter `json:"filters"`
	Desc                    string   `json:"description"`
	EstimatedCompletionTime int      `json:"estimated_completion_time"`
	MaximumAllowedTime      int      `json:"maximum_allowed_time"`
	CompletionURL           string   `json:"completion_url"`
	ExternalStudyURL        string   `json:"external_study_url"`
	PublishedAt             any      `json:"published_at"`
	StartedPublishingAt     any      `json:"started_publishing_at"`
	AwardPoints             int      `json:"award_points"`
	PresentmentCurrencyCode string   `json:"presentment_currency_code"`
	CurrencyCode            string   `json:"currency_code"`
	Researcher              struct {
		ID          string `json:"id"`
		Name        string `json:"name"`
		Email       string `json:"email"`
		Country     string `json:"country"`
		Institution struct {
			Name any    `json:"name"`
			Logo any    `json:"logo"`
			Link string `json:"link"`
		} `json:"institution"`
	} `json:"researcher"`
	Status                 string            `json:"status"`
	AverageRewardPerHour   float64           `json:"average_reward_per_hour"`
	DeviceCompatibility    []string          `json:"device_compatibility"`
	PeripheralRequirements []any             `json:"peripheral_requirements"`
	PlacesTaken            int               `json:"places_taken"`
	EstimatedRewardPerHour float64           `json:"estimated_reward_per_hour"`
	Ref                    any               `json:"_ref"`
	StudyType              string            `json:"study_type"`
	TotalCost              float64           `json:"total_cost"`
	PublishAt              any               `json:"publish_at"`
	IsPilot                bool              `json:"is_pilot"`
	IsUnderpaying          any               `json:"is_underpaying"`
	SubmissionsConfig      SubmissionsConfig `json:"submissions_config"`
	CredentialPoolID       string            `json:"credential_pool_id"`
}

Study represents a Prolific Study

func (Study) Description

func (s Study) Description() string

Description will set the secondary string the view.

func (Study) FilterValue

func (s Study) FilterValue() string

FilterValue will help the bubbletea views run

func (Study) GetCurrencyCode

func (s Study) GetCurrencyCode() string

GetCurrencyCode handles the logic about which internal fields to use to decide which currency to display. Defaults to GBP.

func (Study) Title

func (s Study) Title() string

Title will set the main string for the view.

type Submission

type Submission struct {
	ID            string    `json:"id"`
	ParticipantID string    `json:"participant_id"`
	StartedAt     time.Time `json:"started_at"`
	CompletedAt   time.Time `json:"completed_at"`
	IsComplete    bool      `json:"is_complete"`
	TimeTaken     int       `json:"time_taken"`
	Reward        int       `json:"reward"`
	Status        string    `json:"status"`
	Strata        struct {
		DateOfBirth         string `json:"date of birth"`
		EthnicitySimplified string `json:"ethnicity (simplified)"`
		Sex                 string `json:"sex"`
	} `json:"strata"`
	StudyCode     string `json:"study_code"`
	StarAwarded   bool   `json:"star_awarded"`
	BonusPayments []any  `json:"bonus_payments"`
	IP            string `json:"ip"`
}

Submission represents a submission to a study from a participant.

func (Submission) Description added in v1.0.0

func (s Submission) Description() string

Description implements list.Item for bubbletea.

func (Submission) FilterValue added in v1.0.0

func (s Submission) FilterValue() string

FilterValue enables filtering in the Bubbletea list view.

func (Submission) Title added in v1.0.0

func (s Submission) Title() string

Title is the primary display string in the Bubbletea list view.

type SubmissionCountItem added in v1.0.0

type SubmissionCountItem struct {
	StatusLabel string
	StatusKey   string
	Count       int
}

SubmissionCountItem represents a single status-count pair for use in interactive lists.

func (SubmissionCountItem) Description added in v1.0.0

func (i SubmissionCountItem) Description() string

Description implements list.Item for bubbletea.

func (SubmissionCountItem) FilterValue added in v1.0.0

func (i SubmissionCountItem) FilterValue() string

FilterValue implements list.Item for bubbletea.

func (SubmissionCountItem) Title added in v1.0.0

func (i SubmissionCountItem) Title() string

Title implements list.Item for bubbletea.

type SubmissionCounts added in v1.0.0

type SubmissionCounts struct {
	Active            int `json:"ACTIVE"`
	Approved          int `json:"APPROVED"`
	AwaitingReview    int `json:"AWAITING REVIEW"`
	Rejected          int `json:"REJECTED"`
	Reserved          int `json:"RESERVED"`
	Returned          int `json:"RETURNED"`
	TimedOut          int `json:"TIMED-OUT"`
	PartiallyApproved int `json:"PARTIALLY APPROVED"`
	ScreenedOut       int `json:"SCREENED OUT"`
	Total             int `json:"TOTAL"`
}

SubmissionCounts represents the count of submissions grouped by status for a study.

func (*SubmissionCounts) ToItems added in v1.0.0

func (sc *SubmissionCounts) ToItems() []SubmissionCountItem

ToItems converts SubmissionCounts into a slice of SubmissionCountItem, excluding zero-count statuses and the Total row.

type SubmissionsConfig

type SubmissionsConfig struct {
	MaxSubmissionsPerParticipant int `json:"max_submissions_per_participant"`
	MaxConcurrentSubmissions     int `json:"max_concurrent_submissions"`
}

SubmissionsConfig represents configuration around submission gathering

type Survey added in v1.0.0

type Survey struct {
	ID           string           `json:"_id"`
	ResearcherID string           `json:"researcher_id"`
	Title        string           `json:"title"`
	DateCreated  time.Time        `json:"date_created"`
	DateModified time.Time        `json:"date_modified"`
	Sections     []SurveySection  `json:"sections,omitempty"`
	Questions    []SurveyQuestion `json:"questions,omitempty"`
}

Survey represents a survey resource from the Prolific API.

type SurveyAnswerOption added in v1.0.0

type SurveyAnswerOption struct {
	ID    string `json:"id,omitempty" mapstructure:"id"`
	Value string `json:"value" mapstructure:"value"`
}

SurveyAnswerOption represents an answer option for a survey question.

type SurveyListItem added in v1.0.0

type SurveyListItem struct {
	Survey
}

SurveyListItem wraps a Survey to satisfy the bubbletea list.DefaultItem interface without conflicting with the Survey.Title field.

func (SurveyListItem) Description added in v1.0.0

func (s SurveyListItem) Description() string

Description implements the bubbletea list.DefaultItem interface.

func (SurveyListItem) FilterValue added in v1.0.0

func (s SurveyListItem) FilterValue() string

FilterValue implements the bubbletea list.Item interface.

func (SurveyListItem) Title added in v1.0.0

func (s SurveyListItem) Title() string

Title implements the bubbletea list.DefaultItem interface.

type SurveyQuestion added in v1.0.0

type SurveyQuestion struct {
	ID      string               `json:"id,omitempty" mapstructure:"id"`
	Title   string               `json:"title" mapstructure:"title"`
	Type    string               `json:"type" mapstructure:"type"`
	Answers []SurveyAnswerOption `json:"answers" mapstructure:"answers"`
}

SurveyQuestion represents a question within a survey.

type SurveyQuestionResponse added in v1.0.0

type SurveyQuestionResponse struct {
	QuestionID    string                 `json:"question_id" mapstructure:"question_id"`
	QuestionTitle string                 `json:"question_title" mapstructure:"question_title"`
	Answers       []SurveyResponseAnswer `json:"answers" mapstructure:"answers"`
}

SurveyQuestionResponse represents an answered question in a survey response.

type SurveyResponse added in v1.0.0

type SurveyResponse struct {
	ID            string                   `json:"_id"`
	ParticipantID string                   `json:"participant_id"`
	SubmissionID  string                   `json:"submission_id"`
	DateCreated   time.Time                `json:"date_created"`
	DateModified  time.Time                `json:"date_modified"`
	Sections      []SurveyResponseSection  `json:"sections,omitempty"`
	Questions     []SurveyQuestionResponse `json:"questions,omitempty"`
}

SurveyResponse represents a participant's response to a survey.

type SurveyResponseAnswer added in v1.0.0

type SurveyResponseAnswer struct {
	AnswerID string `json:"answer_id" mapstructure:"answer_id"`
	Value    string `json:"value" mapstructure:"value"`
}

SurveyResponseAnswer represents an answer within a survey response.

type SurveyResponseListItem added in v1.0.0

type SurveyResponseListItem struct {
	SurveyResponse
}

SurveyResponseListItem wraps a SurveyResponse to satisfy the bubbletea list.DefaultItem interface.

func (SurveyResponseListItem) Description added in v1.0.0

func (s SurveyResponseListItem) Description() string

Description implements the bubbletea list.DefaultItem interface.

func (SurveyResponseListItem) FilterValue added in v1.0.0

func (s SurveyResponseListItem) FilterValue() string

FilterValue implements the bubbletea list.Item interface.

func (SurveyResponseListItem) Title added in v1.0.0

func (s SurveyResponseListItem) Title() string

Title implements the bubbletea list.DefaultItem interface.

type SurveyResponseSection added in v1.0.0

type SurveyResponseSection struct {
	SectionID string                   `json:"section_id" mapstructure:"section_id"`
	Questions []SurveyQuestionResponse `json:"questions" mapstructure:"questions"`
}

SurveyResponseSection represents a section within a survey response.

type SurveySection added in v1.0.0

type SurveySection struct {
	ID        string           `json:"id,omitempty" mapstructure:"id"`
	Title     string           `json:"title" mapstructure:"title"`
	Questions []SurveyQuestion `json:"questions" mapstructure:"questions"`
}

SurveySection represents a section within a survey.

type SurveySummary added in v1.0.0

type SurveySummary struct {
	SurveyID  string                  `json:"survey_id"`
	Questions []SurveySummaryQuestion `json:"questions"`
}

SurveySummary represents the aggregated summary of survey responses.

type SurveySummaryAnswer added in v1.0.0

type SurveySummaryAnswer struct {
	AnswerID string `json:"answer_id"`
	Answer   string `json:"answer"`
	Count    int    `json:"count"`
}

SurveySummaryAnswer represents an answer option's count in the summary.

type SurveySummaryQuestion added in v1.0.0

type SurveySummaryQuestion struct {
	QuestionID   string                `json:"question_id"`
	Question     string                `json:"question"`
	TotalAnswers int                   `json:"total_answers"`
	Answers      []SurveySummaryAnswer `json:"answers"`
}

SurveySummaryQuestion represents a question's aggregated response data.

type TaskDetails

type TaskDetails struct {
	TaskName         string `json:"task_name" mapstructure:"task_name"`
	TaskIntroduction string `json:"task_introduction" mapstructure:"task_introduction"`
	TaskSteps        string `json:"task_steps" mapstructure:"task_steps"`
}

TaskDetails represents the task configuration details.

type UnitOption added in v0.0.58

type UnitOption struct {
	Label      string          `json:"label" yaml:"label" mapstructure:"label"`
	Value      string          `json:"value" yaml:"value" mapstructure:"value"`
	Validation *ValidationRule `json:"validation,omitempty" yaml:"validation,omitempty" mapstructure:"validation"`
}

UnitOption represents a unit option for free_text_with_unit instructions

type UnitPosition added in v0.0.58

type UnitPosition string

UnitPosition represents the position of the unit relative to the text input.

const (
	// UnitPositionPrefix means the unit appears before the text input.
	UnitPositionPrefix UnitPosition = "prefix"
	// UnitPositionSuffix means the unit appears after the text input.
	UnitPositionSuffix UnitPosition = "suffix"
)

type UpdateCollection added in v0.0.58

type UpdateCollection struct {
	BaseEntity      `yaml:",inline" mapstructure:",squash"`
	Name            string       `json:"name" yaml:"name" mapstructure:"name"`
	Description     string       `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description"`
	WorkspaceID     string       `json:"workspace_id,omitempty" yaml:"workspace_id,omitempty" mapstructure:"workspace_id"`
	TaskDetails     *TaskDetails `json:"task_details,omitempty" yaml:"task_details,omitempty" mapstructure:"task_details"`
	CollectionItems []Page       `json:"collection_items" yaml:"collection_items" mapstructure:"collection_items"`
}

UpdateCollection represents the payload for updating a collection.

type UpdateStudy

type UpdateStudy struct {
	TotalAvailablePlaces int    `json:"total_available_places,omitempty"`
	CredentialPoolID     string `json:"credential_pool_id,omitempty"`
}

UpdateStudy represents the model we will send back to Prolific to update the study.

type User

type User struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Email string   `json:"email"`
	Roles []string `json:"roles"`
}

User represents a user in the system

type ValidationRule added in v0.0.62

type ValidationRule struct {
	Type string   `json:"type" yaml:"type" mapstructure:"type"`
	Min  *float64 `json:"min" yaml:"min" mapstructure:"min"`
	Max  *float64 `json:"max" yaml:"max" mapstructure:"max"`
}

ValidationRule represents min/max validation for free_text and free_text_with_unit instructions.

type Workspace

type Workspace struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Users       []User `json:"users"`
}

Workspace represents the workspace model

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL