Documentation ¶
Index ¶
- func GetJWTKey() string
- type AuthService
- type CrowdSourcedUserService
- func (c *CrowdSourcedUserService) CreateCrowdSourcedUser(crowdSourcedUser models.CrowdSourcedUser) models.HTTPStatus
- func (c *CrowdSourcedUserService) GetCrowdSourcedUserByCrowdSourcedUserAndStudyId(crowdSourcedUserId string, studyId string) (models.CrowdSourcedUser, models.HTTPStatus)
- func (c *CrowdSourcedUserService) GetCrowdSourcedUsersByStudyId(studyId string) ([]models.CrowdSourcedUser, models.HTTPStatus)
- func (c *CrowdSourcedUserService) HandleSetComplete(crowdSourcedUserId string, studyId string) (models.CrowdSourcedUser, models.HTTPStatus)
- type OrganizationService
- type ParticipantDataService
- type StudyService
- func (s *StudyService) ArchiveStudyById(studyId string, loggedInUserId string, loggedInUserRole string) models.HTTPStatus
- func (s *StudyService) CreateStudy(study *models.Study) models.HTTPStatus
- func (s *StudyService) GetStudiesByOrganizationId(organizationId string, userId string) ([]models.Study, models.HTTPStatus)
- func (s *StudyService) GetStudyById(studyId string) (models.Study, models.HTTPStatus)
- func (s *StudyService) SnapshotStudyByStudyId(studyId string) models.HTTPStatus
- func (s *StudyService) UpdateStudy(userId string, studyId string, shouldUpdateTasks string, study *models.Study) (models.Study, models.HTTPStatus)
- type StudyUserService
- func (s *StudyUserService) CreateStudyUser(studyUser *models.StudyUser) models.HTTPStatus
- func (s *StudyUserService) GetAllStudyUsersByStudyId(studyId string) ([]models.StudyUser, models.HTTPStatus)
- func (s *StudyUserService) GetAllStudyUsersByUserId(userId string) ([]models.StudyUser, models.HTTPStatus)
- func (s *StudyUserService) GetStudyUserSummary() ([]models.StudyUserSummary, models.HTTPStatus)
- func (s *StudyUserService) UpdateStudyUser(userId string, studyId string, studyUser *models.StudyUser) (models.StudyUser, models.HTTPStatus)
- type TaskService
- type TokenService
- type UserService
- func (u *UserService) CreateUser(loggedInUserRole string, user *models.User) models.HTTPStatus
- func (u *UserService) DeleteUserByID(userId string) models.HTTPStatus
- func (u *UserService) GetUserByEmail(email string) (models.User, models.HTTPStatus)
- func (u *UserService) GetUserById(id string) (models.User, models.HTTPStatus)
- func (u *UserService) GetUsersByOrganizationId(organizationId string, userId string) ([]models.User, models.HTTPStatus)
- func (u *UserService) HandleForgotPassword(email string) models.HTTPStatus
- func (u *UserService) UpdateUser(userId string, receivedUser *models.User) (models.User, models.HTTPStatus)
- func (u *UserService) UpdateUserPassword(email string, passwordAttempt string, newPassword string) models.HTTPStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthService ¶
type AuthService struct{}
func (*AuthService) ValidateCredentialsAndGetUser ¶
func (l *AuthService) ValidateCredentialsAndGetUser(email string, password string) (models.User, models.HTTPStatus)
ValidateCredentialsAndGetUser checks to see if the email and password match by querying the db for the correct email and then comparing
type CrowdSourcedUserService ¶
type CrowdSourcedUserService struct{}
func (*CrowdSourcedUserService) CreateCrowdSourcedUser ¶
func (c *CrowdSourcedUserService) CreateCrowdSourcedUser(crowdSourcedUser models.CrowdSourcedUser) models.HTTPStatus
CreateCrowdSourcedUser creates a crowdsourced user in the database. It returns a 201, 400, 409, or 500 status code
func (*CrowdSourcedUserService) GetCrowdSourcedUserByCrowdSourcedUserAndStudyId ¶
func (c *CrowdSourcedUserService) GetCrowdSourcedUserByCrowdSourcedUserAndStudyId(crowdSourcedUserId string, studyId string) (models.CrowdSourcedUser, models.HTTPStatus)
GetCrowdSourcedUserByCrowdSourcedUserAndStudyId gets a crowdSourcedUser by the given ID. It returns a 200, 404, or 500 status code
func (*CrowdSourcedUserService) GetCrowdSourcedUsersByStudyId ¶
func (c *CrowdSourcedUserService) GetCrowdSourcedUsersByStudyId(studyId string) ([]models.CrowdSourcedUser, models.HTTPStatus)
GetCrowdSourcedUsersByStudyId gets all crowdsourced users for a given study id. It returns a 200 or 500 status code.
func (*CrowdSourcedUserService) HandleSetComplete ¶
func (c *CrowdSourcedUserService) HandleSetComplete(crowdSourcedUserId string, studyId string) (models.CrowdSourcedUser, models.HTTPStatus)
HandleSetComplete sets a string as the completion code. It returns a 200, 404, or 500 status code.
type OrganizationService ¶
type OrganizationService struct{}
func (*OrganizationService) GetOrganizationById ¶
func (o *OrganizationService) GetOrganizationById(organizationId uint) (models.Organization, models.HTTPStatus)
GetOrganizationById gets the organization by the given id
type ParticipantDataService ¶
type ParticipantDataService struct{}
func (*ParticipantDataService) CreateParticipantData ¶
func (s *ParticipantDataService) CreateParticipantData(participantData models.ParticipantData) models.HTTPStatus
CreateParticipantData saves the given experiment data into a table. It returns a 200 or 500 status code.
func (*ParticipantDataService) GetParticipantDataByStudyIdAndTaskOrder ¶
func (s *ParticipantDataService) GetParticipantDataByStudyIdAndTaskOrder(studyIdFromPath string, taskOrderFromPath string, userId string) ([]models.ParticipantData, models.HTTPStatus)
GetParticipantDataByStudyIdAndTaskOrder gets task data given a study id and task order. It returns a 200, or 500
type StudyService ¶
type StudyService struct{}
func (*StudyService) ArchiveStudyById ¶
func (s *StudyService) ArchiveStudyById(studyId string, loggedInUserId string, loggedInUserRole string) models.HTTPStatus
ArchiveStudyById archives a study by the given id. It returns a 200, 404, or 500 status code
func (*StudyService) CreateStudy ¶
func (s *StudyService) CreateStudy(study *models.Study) models.HTTPStatus
CreateStudy creates a study. It returns a 201 or 500 status code.
func (*StudyService) GetStudiesByOrganizationId ¶
func (s *StudyService) GetStudiesByOrganizationId(organizationId string, userId string) ([]models.Study, models.HTTPStatus)
GetStudiesByOrganizationId gets all the studies for a given organization It returns a 200, 404, or 500 status code.
func (*StudyService) GetStudyById ¶
func (s *StudyService) GetStudyById(studyId string) (models.Study, models.HTTPStatus)
GetStudyById retrieves the study by the given id. It returns a 200, 404, or 500 status code.
func (*StudyService) SnapshotStudyByStudyId ¶
func (s *StudyService) SnapshotStudyByStudyId(studyId string) models.HTTPStatus
func (*StudyService) UpdateStudy ¶
func (s *StudyService) UpdateStudy(userId string, studyId string, shouldUpdateTasks string, study *models.Study) (models.Study, models.HTTPStatus)
UpdateStudy updates the study. The study object and the study id given in the URL must be the same. It returns a 200, 404, or 500 status code.
type StudyUserService ¶
type StudyUserService struct{}
func (*StudyUserService) CreateStudyUser ¶
func (s *StudyUserService) CreateStudyUser(studyUser *models.StudyUser) models.HTTPStatus
CreateStudyUser creates the given study user in the database. It returns a 201, 409, or 500 status code
func (*StudyUserService) GetAllStudyUsersByStudyId ¶
func (s *StudyUserService) GetAllStudyUsersByStudyId(studyId string) ([]models.StudyUser, models.HTTPStatus)
GetAllStudyUsersByStudyId retrieves all study users for the given user id. It returns a 200, 404, or 500 status code.
func (*StudyUserService) GetAllStudyUsersByUserId ¶
func (s *StudyUserService) GetAllStudyUsersByUserId(userId string) ([]models.StudyUser, models.HTTPStatus)
GetAllStudyUsersByUserId retrieves all study users for the given user id. It returns a 200, 404, or 500 status code.
func (*StudyUserService) GetStudyUserSummary ¶
func (s *StudyUserService) GetStudyUserSummary() ([]models.StudyUserSummary, models.HTTPStatus)
GetStudyUserSummary returns a summary of all users and the studies that they are currently registered for. This includes users that have a currentTaskIndex of 0. It returns a 200, or 500 status code
func (*StudyUserService) UpdateStudyUser ¶
func (s *StudyUserService) UpdateStudyUser(userId string, studyId string, studyUser *models.StudyUser) (models.StudyUser, models.HTTPStatus)
UpdateStudyUser updates a studyuser. It returns a 200, 404, or 500 status code
type TaskService ¶
type TaskService struct{}
func (*TaskService) GetAllTasks ¶
func (t *TaskService) GetAllTasks() ([]models.Task, models.HTTPStatus)
GetAllTasks returns all tasks It returns a 200 or 500 status code.
func (*TaskService) GetAllTasksByStudyId ¶
func (t *TaskService) GetAllTasksByStudyId(studyId string) ([]models.Task, models.HTTPStatus)
GetAllTasksByStudyId gets all tasks for a given study id. It returns a 200 or 500
func (*TaskService) GetTaskById ¶
func (t *TaskService) GetTaskById(taskId string) (models.Task, models.HTTPStatus)
GetTaskById returns a task with the given id It returns a 200, 404, or 500
type TokenService ¶
type TokenService struct{}
func (*TokenService) CreateToken ¶
CreateToken returns the token and error after signing with HS256
func (*TokenService) ValidateToken ¶
func (t *TokenService) ValidateToken(tokenString string) (*models.Claims, error)
ValidateToken makes sure a given token is valid (acceptable, can be parsed, not expired)
type UserService ¶
type UserService struct{}
func (*UserService) CreateUser ¶
func (u *UserService) CreateUser(loggedInUserRole string, user *models.User) models.HTTPStatus
CreateUser saves the user in the db
func (*UserService) DeleteUserByID ¶
func (u *UserService) DeleteUserByID(userId string) models.HTTPStatus
DeleteUserByID deletes the user with the given ID. It returns a 200, 400, 500 status code.
func (*UserService) GetUserByEmail ¶
func (u *UserService) GetUserByEmail(email string) (models.User, models.HTTPStatus)
GetUserByEmail retrieves the user by the given email. It returns a 200, 404, or 500 status code.
func (*UserService) GetUserById ¶
func (u *UserService) GetUserById(id string) (models.User, models.HTTPStatus)
GetUserById retrieves the user by the given ID. It returns a 200, 404, or 500 status code.
func (*UserService) GetUsersByOrganizationId ¶
func (u *UserService) GetUsersByOrganizationId(organizationId string, userId string) ([]models.User, models.HTTPStatus)
GetUsersByOrganizationId gets all members and guests for a given organization. It returns a 200, 403, 404 or 500 status code.
func (*UserService) HandleForgotPassword ¶
func (u *UserService) HandleForgotPassword(email string) models.HTTPStatus
HandleForgotPassword generates a random password, and triggers an email dispatch with that random password. The ChangePasswordRequired flag is set to true. It returns a 200, 404, or 500 status code
func (*UserService) UpdateUser ¶
func (u *UserService) UpdateUser(userId string, receivedUser *models.User) (models.User, models.HTTPStatus)
UpdateUser updates the given user but not the password It returns a 200, 403, 404, or 500 status code
func (*UserService) UpdateUserPassword ¶
func (u *UserService) UpdateUserPassword(email string, passwordAttempt string, newPassword string) models.HTTPStatus
UpdateUserPassword updates the user password with a new salted and hashed password. It returns a 200, 400, 401, 404, or 500 status code.