Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArePollDataEquals ¶
ArePollDataEquals check whether the first and second pointers to a PollData object represents the same poll or not.
Types ¶
type AnswerID ¶
type AnswerID uint64
AnswerID represents a unique answer id
func ParseAnswerID ¶
ParseAnswerID returns the AnswerID represented inside the provided value, or an error if no id could be parsed properly
func (AnswerID) MarshalJSON ¶
MarshalJSON implements Marshaler
func (*AnswerID) UnmarshalJSON ¶
UnmarshalJSON implements Unmarshaler
type PollAnswer ¶
type PollAnswer struct { ID AnswerID `json:"id" yaml:"id"` // Unique id inside the post, serialized as a string for Javascript compatibility Text string `json:"text" yaml:"text"` // Text of the answer }
PollAnswer contains the data of a single poll answer inserted by the creator
func NewPollAnswer ¶
func NewPollAnswer(id AnswerID, text string) PollAnswer
NewPollAnswer returns a new PollAnswer object
func (PollAnswer) Equals ¶
func (pa PollAnswer) Equals(other PollAnswer) bool
Equals allows to check whether the contents of p are the same of other
type PollAnswers ¶
type PollAnswers []PollAnswer
PollAnswers represents a slice of poll answers
func NewPollAnswers ¶
func NewPollAnswers(answers ...PollAnswer) PollAnswers
NewPollAnswers builds a new PollAnswers object starting from the given answers
func (PollAnswers) AppendIfMissing ¶
func (answers PollAnswers) AppendIfMissing(newAnswer PollAnswer) PollAnswers
AppendIfMissing appends the given answer to the answers slice if it does not exist inside it yet. It returns a new slice of PollAnswers containing such PollAnswer.
func (PollAnswers) Equals ¶
func (answers PollAnswers) Equals(other PollAnswers) bool
Equals returns true iff the answers slice contains the same data in the same order of the other slice
func (PollAnswers) ExtractAnswersIDs ¶
func (answers PollAnswers) ExtractAnswersIDs() (answersIDs []AnswerID)
ExtractAnswersIDs appends every answer ID to a slice of IDs. It returns a slice of answers IDs.
func (PollAnswers) String ¶
func (answers PollAnswers) String() string
Strings implements fmt.Stringer
func (PollAnswers) Validate ¶
func (answers PollAnswers) Validate() error
Validate implements validator
type PollData ¶
type PollData struct { Question string `json:"question" yaml:"question"` // Describes what poll is about ProvidedAnswers PollAnswers `json:"provided_answers" yaml:"provided_answers"` // Lists of answers provided by the creator EndDate time.Time `json:"end_date" yaml:"end_date"` // RFC3339 date at which the poll will no longer accept new answers AllowsMultipleAnswers bool `json:"allows_multiple_answers" yaml:"allows_multiple_answers"` // Tells if the poll is a single or multiple answers one AllowsAnswerEdits bool `json:"allows_answer_edits" yaml:"allows_answer_edits"` // Tells if the poll allows answer edits }
PollData contains the information of a poll that is associated to a post
func NewPollData ¶
func NewPollData(question string, endDate time.Time, providedAnswers PollAnswers, allowMultipleAnswers, allowsAnswerEdits bool) PollData
NewPollData returns a new PollData object pointer containing the given data
type UserAnswer ¶
type UserAnswer struct { Answers []AnswerID `json:"answers" yaml:"answers"` User sdk.AccAddress `json:"user" yaml:"user"` }
UserAnswer contains the data of a user's answer submission
func NewUserAnswer ¶
func NewUserAnswer(answers []AnswerID, user sdk.AccAddress) UserAnswer
NewUserAnswer returns a new AnswerDetails object containing the given data
func (UserAnswer) Equals ¶
func (userAnswers UserAnswer) Equals(other UserAnswer) bool
Equals returns true iff the userPollAnswers contains the same data of the other userPollAnswers
func (UserAnswer) String ¶
func (userAnswers UserAnswer) String() string
Strings implements fmt.Stringer
func (UserAnswer) Validate ¶
func (userAnswers UserAnswer) Validate() error
Validate implements validator
type UserAnswers ¶
type UserAnswers []UserAnswer
func NewUserAnswers ¶
func NewUserAnswers(answers ...UserAnswer) UserAnswers
NewUserAnswers allows to create a new UserAnswers object from the given answers
func (UserAnswers) AppendIfMissingOrIfUsersEquals ¶
func (ua UserAnswers) AppendIfMissingOrIfUsersEquals(answer UserAnswer) (UserAnswers, bool)
AppendIfMissingOrIfUserEquals appends the given answer to the user's answers slice if it does not exist inside it yet or if the user of the answer details is the same. It returns a new slice of containing such answer and a boolean indicating if the slice has been modified or not.