types

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Theme_Default = "default"
	Theme_Custom  = "custom"
)
View Source
const (
	SurveyParseStatus_Success = "success"
	SurveyParseStatus_Error   = "error"
	SurveyParseStatus_Deleted = "deleted"
)
View Source
const (
	SurveyDeliveryStatus_Launched = "launched"
	SurveyDeliveryStatus_Stopped  = "stopped"
)
View Source
const (
	SurveySessionStatus_InProgress = "in_progress"
	SurveySessionStatus_Completed  = "completed"
)
View Source
const DATE_FORMAT = "2006-01-02"

Variables

View Source
var SupportedThemes = map[string]bool{
	Theme_Default: true,
	Theme_Custom:  true,
}

Functions

This section is empty.

Types

type Answer

type Answer interface {
	Validate(q Question) error
	Value() (driver.Value, error)
}

type BoolAnswer

type BoolAnswer struct {
	AnswerValue bool `json:"value"`
}

func (*BoolAnswer) Validate

func (a *BoolAnswer) Validate(q Question) error

func (BoolAnswer) Value

func (a BoolAnswer) Value() (driver.Value, error)

type DateAnswer

type DateAnswer struct {
	AnswerValue string `json:"value"`
}

func (*DateAnswer) Validate

func (a *DateAnswer) Validate(q Question) error

func (DateAnswer) Value

func (a DateAnswer) Value() (driver.Value, error)

type DuplicateProtectionType

type DuplicateProtectionType string
const (
	DuplicateProtectionType_Cookie DuplicateProtectionType = "cookie"
	DuplicateProtectionType_Ip     DuplicateProtectionType = "ip"
)

type MultiOptionsAnswer

type MultiOptionsAnswer struct {
	AnswerValue []string `json:"value"`
}

func (*MultiOptionsAnswer) Validate

func (a *MultiOptionsAnswer) Validate(q Question) error

func (MultiOptionsAnswer) Value

func (a MultiOptionsAnswer) Value() (driver.Value, error)

type NumberAnswer

type NumberAnswer struct {
	AnswerValue int64 `json:"value"`
}

func (*NumberAnswer) Validate

func (a *NumberAnswer) Validate(q Question) error

func (NumberAnswer) Value

func (a NumberAnswer) Value() (driver.Value, error)

type Question

type Question struct {
	Type                QuestionType        `json:"type" yaml:"type"`
	Label               string              `json:"label" yaml:"label"`
	ID                  string              `json:"id" yaml:"id"`
	Description         string              `json:"description" yaml:"description"`
	Min                 *int                `json:"min,omitempty" yaml:"min,omitempty"`
	Max                 *int                `json:"max,omitempty" yaml:"max,omitempty"`
	OptionsFromVariable *string             `json:"-" yaml:"optionsFromVariable,omitempty"`
	Options             []string            `json:"options,omitempty" yaml:"options,omitempty"`
	UUID                string              `json:"uuid" yaml:"-"`
	Validation          *QuestionValidation `json:"validation,omitempty" yaml:"validation,omitempty"`
}

func (Question) GenerateHash

func (q Question) GenerateHash() string

func (Question) GetAnswerType

func (q Question) GetAnswerType() (Answer, error)

func (Question) ValidateAnswer

func (q Question) ValidateAnswer(answer interface{}) error

func (Question) ValidateMinMax

func (q Question) ValidateMinMax() error

func (Question) ValidateOptions

func (q Question) ValidateOptions() error

type QuestionAnswer

type QuestionAnswer struct {
	QuestionID   string `json:"question_id"`
	QuestionUUID string `json:"question_uuid"`
	AnswerBytes  []byte `json:"answer_bytes"`
	Answer       Answer `json:"answer"`
}

type QuestionType

type QuestionType string
const (
	QuestionType_DropdownSingle   QuestionType = "single-choice"
	QuestionType_DropdownMultiple QuestionType = "multiple-choice"
	QuestionType_ShortText        QuestionType = "short-text"
	QuestionType_LongText         QuestionType = "long-text"
	QuestionType_Date             QuestionType = "date"
	QuestionType_Rating           QuestionType = "rating"
	QuestionType_Ranking          QuestionType = "ranking"
	QuestionType_YesNo            QuestionType = "yes-no"
)

type QuestionValidation

type QuestionValidation struct {
	Min *int `json:"min,omitempty" yaml:"min,omitempty"`
	Max *int `json:"max,omitempty" yaml:"max,omitempty"`
}

func (QuestionValidation) Validate

func (v QuestionValidation) Validate() error

type Questions

type Questions struct {
	Questions []Question `json:"questions" yaml:"questions"`
}

func (*Questions) Validate

func (s *Questions) Validate() error

type Security

type Security struct {
	DuplicateProtection DuplicateProtectionType `json:"duplicateProtection" yaml:"duplicateProtection"`
}

func (*Security) Validate

func (s *Security) Validate() error

type SingleOptionAnswer

type SingleOptionAnswer struct {
	AnswerValue string `json:"value"`
}

func (*SingleOptionAnswer) Validate

func (a *SingleOptionAnswer) Validate(q Question) error

func (SingleOptionAnswer) Value

func (a SingleOptionAnswer) Value() (driver.Value, error)

type Survey

type Survey struct {
	ID             int64                `json:"-"`
	UUID           string               `json:"uuid"`
	CreatedAt      time.Time            `json:"created_at"`
	ParseStatus    SurveyParseStatus    `json:"parse_status"`
	DeliveryStatus SurveyDeliveryStatus `json:"delivery_status"`
	ErrorLog       string               `json:"error_log"`
	Name           string               `json:"name"`
	URLSlug        string               `json:"url_slug"`
	URL            string               `json:"url"`

	Config *SurveyConfig `json:"config"`
	Stats  SurveyStats   `json:"stats"`
}

type SurveyConfig

type SurveyConfig struct {
	Title string `json:"title" yaml:"title"`
	Intro string `json:"intro" yaml:"intro"`
	Outro string `json:"outro" yaml:"outro"`
	Theme string `json:"theme" yaml:"theme"`

	Hash      string     `json:"hash" yaml:"-"`
	Questions *Questions `json:"questions" yaml:"-"`
	Variables *Variables `json:"variables" yaml:"-"`
	Security  *Security  `json:"security" yaml:"-"`
}

func (*SurveyConfig) FindQuestionByUUID

func (s *SurveyConfig) FindQuestionByUUID(questionUUID string) (*Question, error)

func (*SurveyConfig) GenerateHash

func (s *SurveyConfig) GenerateHash()

func (*SurveyConfig) Normalize

func (s *SurveyConfig) Normalize()

func (*SurveyConfig) Scan

func (a *SurveyConfig) Scan(value interface{}) error

func (*SurveyConfig) SetOptionsFromVariables

func (s *SurveyConfig) SetOptionsFromVariables() error

func (*SurveyConfig) Validate

func (s *SurveyConfig) Validate() error

func (SurveyConfig) Value

func (a SurveyConfig) Value() (driver.Value, error)

type SurveyDeliveryStatus

type SurveyDeliveryStatus string

type SurveyParseError

type SurveyParseError struct {
	Name      string `json:"name" yaml:"name"`
	Err       error  `json:"-" yaml:"-"`
	ErrString string `json:"error" yaml:"error"`
}

type SurveyParseStatus

type SurveyParseStatus string

type SurveySession

type SurveySession struct {
	ID              int64               `json:"-"`
	UUID            string              `json:"uuid"`
	CreatedAt       time.Time           `json:"created_at"`
	CompletedAt     *time.Time          `json:"completed_at"`
	Status          SurveySessionStatus `json:"status"`
	SurveyUUID      string              `json:"survey_uuid"`
	IPAddr          string              `json:"ip_addr"`
	QuestionAnswers []QuestionAnswer    `json:"question_answers"`
}

type SurveySessionStatus

type SurveySessionStatus string

type SurveySessionsFilter

type SurveySessionsFilter struct {
	Limit  int    `query:"limit"`
	Offset int    `query:"offset"`
	SortBy string `query:"sort_by"`
	Order  string `query:"order"`
}

func (*SurveySessionsFilter) ToString

func (v *SurveySessionsFilter) ToString() string

func (*SurveySessionsFilter) Validate

func (v *SurveySessionsFilter) Validate() error

type SurveyStats

type SurveyStats struct {
	SessionsCountInProgess int `json:"sessions_count_in_progress"`
	SessionsCountCompleted int `json:"sessions_count_completed"`
	CompletionRate         int `json:"completion_rate"`
}

type SurveysSyncResult

type SurveysSyncResult struct {
	Surveys []*Survey          `json:"surveys"`
	Errors  []SurveyParseError `json:"errors"`
}

type TextAnswer

type TextAnswer struct {
	AnswerValue string `json:"value"`
}

func (*TextAnswer) Validate

func (a *TextAnswer) Validate(q Question) error

func (TextAnswer) Value

func (a TextAnswer) Value() (driver.Value, error)

type Variable

type Variable struct {
	ID      string       `json:"id" yaml:"id"`
	Type    VariableType `json:"type" yaml:"type"`
	Options []string     `json:"options,omitempty" yaml:"options,omitempty"`
}

type VariableType

type VariableType string
const (
	VariableType_List VariableType = "list"
)

type Variables

type Variables struct {
	Variables []Variable `json:"variables" yaml:"variables"`
}

func (*Variables) Validate

func (v *Variables) Validate() error

Jump to

Keyboard shortcuts

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