client

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRecordLimit = 200

DefaultRecordLimit defines how many records to return by default.

View Source
const DefaultRecordOffset = 0

DefaultRecordOffset defines how many records we should offset to start with.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetMe() (*MeResponse, error)

	CreateStudy(model.CreateStudy) (*model.Study, error)
	DuplicateStudy(ID string) (*model.Study, error)
	GetEligibilityRequirements() (*ListRequirementsResponse, error)
	GetStudies(status, projectID string) (*ListStudiesResponse, error)
	GetStudy(ID string) (*model.Study, error)
	GetSubmissions(ID string, limit, offset int) (*ListSubmissionsResponse, error)
	TransitionStudy(ID, action string) (*TransitionStudyResponse, error)
	UpdateStudy(ID string, study model.UpdateStudy) (*model.Study, error)

	GetCampaigns(workspaceID string, limit, offset int) (*ListCampaignsResponse, error)

	GetHooks(workspaceID string, enabled bool, limit, offset int) (*ListHooksResponse, error)
	GetHookEventTypes() (*ListHookEventTypesResponse, error)
	GetHookSecrets(workspaceID string) (*ListSecretsResponse, error)
	GetEvents(subscriptionID string, limit, offset int) (*ListHookEventsResponse, error)

	GetWorkspaces(limit, offset int) (*ListWorkspacesResponse, error)
	CreateWorkspace(workspace model.Workspace) (*CreateWorkspacesResponse, error)

	GetProjects(workspaceID string, limit, offset int) (*ListProjectsResponse, error)
	CreateProject(workspaceID string, project model.Project) (*CreateProjectResponse, error)
	GetProject(ID string) (*model.Project, error)

	GetParticipantGroups(projectID string, limit, offset int) (*ListParticipantGroupsResponse, error)
	GetParticipantGroup(groupID string) (*ViewParticipantGroupResponse, error)

	GetFilters() (*ListFiltersResponse, error)

	GetFilterSets(workspaceID string, limit, offset int) (*ListFilterSetsResponse, error)
	GetFilterSet(ID string) (*model.FilterSet, error)

	GetMessages(userID *string, createdAfter *string) (*ListMessagesResponse, error)
	SendMessage(body, recipientID, studyID string) error
	GetUnreadMessages() (*ListUnreadMessagesResponse, error)

	GetAITaskBuilderBatch(batchID string) (*GetAITaskBuilderBatchResponse, error)
	GetAITaskBuilderBatchStatus(batchID string) (*GetAITaskBuilderBatchStatusResponse, error)
	GetAITaskBuilderBatches(workspaceID string) (*GetAITaskBuilderBatchesResponse, error)
	GetAITaskBuilderResponses(batchID string) (*GetAITaskBuilderResponsesResponse, error)
	GetAITaskBuilderDatasetStatus(datasetID string) (*GetAITaskBuilderDatasetStatusResponse, error)
}

API represents what is allowed to be called on the Prolific client.

type Client

type Client struct {
	Client  *http.Client
	BaseURL string
	Token   string
	Debug   bool
}

Client is responsible for interacting with the Prolific API.

func New

func New() Client

New will return a new Prolific client.

func (*Client) CreateProject

func (c *Client) CreateProject(workspaceID string, project model.Project) (*CreateProjectResponse, error)

CreateProject will create you a project

func (*Client) CreateStudy

func (c *Client) CreateStudy(study model.CreateStudy) (*model.Study, error)

CreateStudy is responsible for hitting the Prolific API to create a study.

func (*Client) CreateWorkspace

func (c *Client) CreateWorkspace(workspace model.Workspace) (*CreateWorkspacesResponse, error)

CreateWorkspace will create you a workspace

func (*Client) DuplicateStudy

func (c *Client) DuplicateStudy(ID string) (*model.Study, error)

DuplicateStudy will duplicate an existing study.

func (*Client) Execute

func (c *Client) Execute(method, url string, body any, response any) (*http.Response, error)

Execute runs an HTTP request.

func (*Client) GetAITaskBuilderBatch

func (c *Client) GetAITaskBuilderBatch(batchID string) (*GetAITaskBuilderBatchResponse, error)

GetAITaskBuilderBatch will return details of an AI Task Builder batch.

func (*Client) GetAITaskBuilderBatchStatus

func (c *Client) GetAITaskBuilderBatchStatus(batchID string) (*GetAITaskBuilderBatchStatusResponse, error)

GetAITaskBuilderBatchStatus will return the status of an AI Task Builder batch.

func (*Client) GetAITaskBuilderBatches

func (c *Client) GetAITaskBuilderBatches(workspaceID string) (*GetAITaskBuilderBatchesResponse, error)

GetAITaskBuilderBatches will return the batches for a given workspace.

func (*Client) GetAITaskBuilderDatasetStatus

func (c *Client) GetAITaskBuilderDatasetStatus(datasetID string) (*GetAITaskBuilderDatasetStatusResponse, error)

GetAITaskBuilderDatasetStatus will return the status of an AI Task Builder dataset.

func (*Client) GetAITaskBuilderResponses

func (c *Client) GetAITaskBuilderResponses(batchID string) (*GetAITaskBuilderResponsesResponse, error)

GetAITaskBuilderResponses will return the responses for an AI Task Builder batch.

func (*Client) GetCampaigns

func (c *Client) GetCampaigns(workspaceID string, limit, offset int) (*ListCampaignsResponse, error)

GetCampaigns will return you a list of Campaign objects.

func (*Client) GetEligibilityRequirements

func (c *Client) GetEligibilityRequirements() (*ListRequirementsResponse, error)

GetEligibilityRequirements will return requirement data.

func (*Client) GetEvents

func (c *Client) GetEvents(subscriptionID string, limit, offset int) (*ListHookEventsResponse, error)

GetEvents will return events created for a subscription

func (*Client) GetFilterSet

func (c *Client) GetFilterSet(ID string) (*model.FilterSet, error)

GetFilterSet will return the filter set for the given filter set ID

func (*Client) GetFilterSets

func (c *Client) GetFilterSets(workspaceID string, limit, offset int) (*ListFilterSetsResponse, error)

GetFilterSets will return the filter sets in a workspace

func (*Client) GetFilters

func (c *Client) GetFilters() (*ListFiltersResponse, error)

func (*Client) GetHookEventTypes

func (c *Client) GetHookEventTypes() (*ListHookEventTypesResponse, error)

GetHookEventTypes will return all of the event types you can subscribe a hook for.

func (*Client) GetHookSecrets

func (c *Client) GetHookSecrets(workspaceID string) (*ListSecretsResponse, error)

GetHookSecrets will return the secrets for a Workspace

func (*Client) GetHooks

func (c *Client) GetHooks(workspaceID string, enabled bool, limit, offset int) (*ListHooksResponse, error)

GetHooks will return the subscriptions to event types for current user.

func (*Client) GetMe

func (c *Client) GetMe() (*MeResponse, error)

GetMe will return your user account details.

func (*Client) GetMessages

func (c *Client) GetMessages(userID *string, createdAfter *string) (*ListMessagesResponse, error)

GetMessages will return the messages for the authenticated user

func (*Client) GetParticipantGroup

func (c *Client) GetParticipantGroup(groupID string) (*ViewParticipantGroupResponse, error)

GetParticipantGroup will return the membership in the group

func (*Client) GetParticipantGroups

func (c *Client) GetParticipantGroups(projectID string, limit, offset int) (*ListParticipantGroupsResponse, error)

GetParticipantGroups will return all the participant groups you have access to for a given ProjectID

func (*Client) GetProject

func (c *Client) GetProject(ID string) (*model.Project, error)

GetProject will return the project for the given project ID

func (*Client) GetProjects

func (c *Client) GetProjects(workspaceID string, limit, offset int) (*ListProjectsResponse, error)

GetProjects will return the projects for the given workspace ID

func (*Client) GetStudies

func (c *Client) GetStudies(status, projectID string) (*ListStudiesResponse, error)

GetStudies will return you a list of Study objects.

func (*Client) GetStudy

func (c *Client) GetStudy(ID string) (*model.Study, error)

GetStudy will return a single study

func (*Client) GetSubmissions

func (c *Client) GetSubmissions(ID string, limit, offset int) (*ListSubmissionsResponse, error)

GetSubmissions will return submission data for a given study.

func (*Client) GetUnreadMessages

func (c *Client) GetUnreadMessages() (*ListUnreadMessagesResponse, error)

GetMessages will return the unread messages for the authenticated user

func (*Client) GetWorkspaces

func (c *Client) GetWorkspaces(limit, offset int) (*ListWorkspacesResponse, error)

GetWorkspaces will return you the workspaces you can see

func (*Client) SendMessage

func (c *Client) SendMessage(body string, recipientID string, studyID string) error

SendMessage will send a message

func (*Client) TransitionStudy

func (c *Client) TransitionStudy(ID, action string) (*TransitionStudyResponse, error)

TransitionStudy will move the study status to a desired state.

func (*Client) UpdateStudy

func (c *Client) UpdateStudy(ID string, study model.UpdateStudy) (*model.Study, error)

UpdateStudy is responsible for updating the Study with a PATCH request.

type CreateProjectResponse

type CreateProjectResponse struct {
	model.Project
}

CreateProjectResponse is the response for creating a project.

type CreateWorkspacesResponse

type CreateWorkspacesResponse struct {
	model.Workspace
}

CreateWorkspacesResponse is the response for creating a workspace.

type GetAITaskBuilderBatchResponse

type GetAITaskBuilderBatchResponse struct {
	model.AITaskBuilderBatch
}

GetAITaskBuilderBatchResponse is the response for the get AI Task Builder get batch endpoint.

type GetAITaskBuilderBatchStatusResponse

type GetAITaskBuilderBatchStatusResponse struct {
	model.AITaskBuilderBatchStatus
}

GetAITaskBuilderBatchStatusResponse is the response for the get AI Task Builder get batch status endpoint.

type GetAITaskBuilderBatchesResponse

type GetAITaskBuilderBatchesResponse struct {
	Results []model.AITaskBuilderBatch `json:"results"`
}

GetAITaskBuilderBatchesResponse is the response for the get AI Task Builder get batches by workspace endpoint.

type GetAITaskBuilderDatasetStatusResponse

type GetAITaskBuilderDatasetStatusResponse struct {
	Status string `json:"status"`
}

GetAITaskBuilderDatasetStatusResponse is the response for the get AI Task Builder dataset status endpoint.

type GetAITaskBuilderResponsesResponse

type GetAITaskBuilderResponsesResponse struct {
	Results []model.AITaskBuilderResponse `json:"results"`
	Meta    ResponseMeta                  `json:"meta"`
}

GetAITaskBuilderResponsesResponse is the response for the get AI Task Builder responses endpoint.

type JSONAPIError

type JSONAPIError struct {
	Error struct {
		Status                int    `json:"status"`
		Title                 string `json:"title"`
		ErrorCode             int    `json:"error_code"`
		Detail                any    `json:"detail"`
		AdditionalInformation string `json:"additional_information"`
	} `json:"error"`
}
type JSONAPILinks struct {
	Links struct {
		Self struct {
			Href  string `json:"href"`
			Title string `json:"title"`
		} `json:"self"`
		Next struct {
			Href  any    `json:"href"`
			Title string `json:"title"`
		} `json:"next"`
		Previous struct {
			Href  any    `json:"href"`
			Title string `json:"title"`
		} `json:"previous"`
		Last struct {
			Href  string `json:"href"`
			Title string `json:"title"`
		} `json:"last"`
	} `json:"_links"`
}

JSONAPILinks is the standard pagination data structure.

type JSONAPIMeta

type JSONAPIMeta struct {
	Meta struct {
		Count int `json:"count"`
	} `json:"meta"`
}

JSONAPIMeta is the standard meta data structure.

type ListCampaignsResponse

type ListCampaignsResponse struct {
	Results []model.Campaign `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListCampaignsResponse is the response for the campaigns request.

type ListFilterSetsResponse

type ListFilterSetsResponse struct {
	Results []model.FilterSet `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

type ListFiltersResponse

type ListFiltersResponse struct {
	Results []model.Filter `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

type ListHookEventTypesResponse

type ListHookEventTypesResponse struct {
	Results []model.HookEventType `json:"results"`
}

ListHookEventTypesResponse is the response for the event types hook API.

type ListHookEventsResponse

type ListHookEventsResponse struct {
	Results []model.HookEvent `json:"results"`
	*JSONAPIMeta
}

ListHookEventsResponse is the response for the hook events API.

type ListHooksResponse

type ListHooksResponse struct {
	Results []model.Hook `json:"results"`
	*JSONAPIMeta
}

ListHooksResponse is the response for the hook subscriptions.

type ListMessagesResponse

type ListMessagesResponse struct {
	Results []model.Message `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListMessagesResponse is the response for the list messages endpoint.

type ListParticipantGroupsResponse

type ListParticipantGroupsResponse struct {
	Results []model.ParticipantGroup `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListParticipantGroupsResponse is the list of participant groups response.

type ListProjectsResponse

type ListProjectsResponse struct {
	Results []model.Project `json:"results"`
	*JSONAPIMeta
}

ListProjectsResponse is the response for the list projects endpoint.

type ListRequirementsResponse

type ListRequirementsResponse struct {
	Results []model.Requirement `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListRequirementsResponse is the response for the requirements request.

type ListSecretsResponse

type ListSecretsResponse struct {
	Results []model.Secret `json:"results"`
}

ListSecretsResponse is the list secrets response.

type ListStudiesResponse

type ListStudiesResponse struct {
	Results []model.Study `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListStudiesResponse is the response for the /studies API response.

type ListSubmissionsResponse

type ListSubmissionsResponse struct {
	Results []model.Submission `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListSubmissionsResponse is the response for the submissions request.

type ListUnreadMessagesResponse

type ListUnreadMessagesResponse struct {
	Results []model.UnreadMessage `json:"results"`
	*JSONAPILinks
	*JSONAPIMeta
}

ListUnreadMessagesResponse is the response for the unread messages endpoint.

type ListWorkspacesResponse

type ListWorkspacesResponse struct {
	Results []model.Workspace `json:"results"`
	*JSONAPIMeta
}

ListWorkspacesResponse is the response for the list workspaces endpoint.

type MeResponse

type MeResponse struct {
	ID               string `json:"id"`
	Email            string `json:"email"`
	FirstName        string `json:"first_name"`
	LastName         string `json:"last_name"`
	Name             string `json:"name"`
	Username         string `json:"username"`
	UserType         string `json:"user_type"`
	CurrencyCode     string `json:"currency_code"`
	Balance          int    `json:"balance"`
	AvailableBalance int    `json:"available_balance"`
}

MeResponse is a struct that represents your account.

type ResponseMeta

type ResponseMeta struct {
	Count int `json:"count"`
}

ResponseMeta contains metadata about the response.

type SendMessagePayload

type SendMessagePayload struct {
	RecipientID string `json:"recipient_id"`
	StudyID     string `json:"study_id"`
	Body        string `json:"body"`
}

MessagePayload represents the JSON payload for sending a message

type TransitionStudyResponse

type TransitionStudyResponse struct {
	ID                      string   `json:"id"`
	Name                    string   `json:"name"`
	InternalName            string   `json:"internal_name"`
	Description             string   `json:"description"`
	ExternalStudyURL        string   `json:"external_study_url"`
	ProlificIDOption        string   `json:"prolific_id_option"`
	CompletionCode          string   `json:"completion_code"`
	CompletionOption        string   `json:"completion_option"`
	TotalAvailablePlaces    int      `json:"total_available_places"`
	EstimatedCompletionTime int      `json:"estimated_completion_time"`
	MaximumAllowedTime      int      `json:"maximum_allowed_time"`
	Reward                  int      `json:"reward"`
	DeviceCompatibility     []string `json:"device_compatibility"`
	PeripheralRequirements  []any    `json:"peripheral_requirements"`
	EligibilityRequirements []any    `json:"eligibility_requirements"`
	Status                  string   `json:"status"`
}

TransitionStudyResponse is the response for transitioning a study to another status.

type ViewParticipantGroupResponse

type ViewParticipantGroupResponse struct {
	Results []model.ParticipantGroupMembership `json:"results"`
}

ViewParticipantGroupResponse is the list of members in a group.

Jump to

Keyboard shortcuts

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