Documentation ¶
Index ¶
- type Api
- type CreatePostParams
- type CreatePostReactionParams
- type CreatePostReactionReturn
- type CreatePostReturn
- type CreateUserParams
- type CreateUserReturn
- type EditPostParams
- type GetPostParams
- type GetPostReactionParams
- type GetPostsParams
- type GetReactionsOfPostParams
- type GetUserParams
- type Identifier
- type LoginParams
- type Method
- type Post
- type PostReaction
- type PostReactionType
- type RemovePostParams
- type RemovePostReactionParams
- type User
- type UserType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api interface { // Login signs the client into either an administrator or a user account // creating a session Login( ctx context.Context, params LoginParams, ) error // Logout signs the client out making him a guest Logout( ctx context.Context, ) error // CreateUser creates a new user account CreateUser( ctx context.Context, params CreateUserParams, ) (Identifier, error) // GetUser finds and returns the user associated with the given identifier GetUser( ctx context.Context, params GetUserParams, ) (*User, error) // GetPost finds a specific post by the given identifier GetPost( ctx context.Context, params GetPostParams, ) (*Post, error) // GetPostReaction finds a specific post reaction by `params.ReactionIdent` GetPostReaction( ctx context.Context, params GetPostReactionParams, ) (*PostReaction, error) // GetReactionsOfPost returns the reactions to a specific post GetReactionsOfPost( ctx context.Context, params GetReactionsOfPostParams, ) ([]*PostReaction, error) // GetPosts looks for n posts (n = 'limit') after // the post identified by the given identifier. // After is set to the latest post if not explicitly specified GetPosts( ctx context.Context, params GetPostsParams, ) ([]*Post, error) // CreatePost creates a new post. // Requires CreatePost( ctx context.Context, params CreatePostParams, ) (Identifier, error) // EditPost permanently changes the contents of a post. // Requires post author permissions EditPost( ctx context.Context, params EditPostParams, ) error // RemovePost removes a post. // Requires either post author or administrator permissions RemovePost( ctx context.Context, params RemovePostParams, ) error // CreatePostReaction creates a new reaction on the post CreatePostReaction( ctx context.Context, params CreatePostReactionParams, ) (Identifier, error) // RemovePostReaction removes a post reaction. // Requires either reaction author or administrator permissions RemovePostReaction( ctx context.Context, params RemovePostReactionParams, ) error }
Api defines the interface of the messenger API
type CreatePostParams ¶
type CreatePostParams struct {
Contents string `json:"contents"`
}
CreatePostParams defines the parameters required by api.CreatePost
type CreatePostReactionParams ¶
type CreatePostReactionParams struct { PostIdent Identifier `json:"postId"` Type PostReactionType `json:"type"` Description string `json:"description"` }
CreatePostReactionParams defines the parameters required by api.CreatePostReaction
type CreatePostReactionReturn ¶
type CreatePostReactionReturn struct {
PostReactionIdent Identifier `json:"id"`
}
CreatePostReactionReturn represents the return type of api.CreatePostReaction
type CreatePostReturn ¶
type CreatePostReturn struct {
PostIdent Identifier `json:"id"`
}
CreatePostReturn represents the return type of api.CreatePost
type CreateUserParams ¶
type CreateUserParams struct { FirstName string `json:"firstName"` LastName string `json:"lastName"` Username string `json:"username"` Password string `json:"password"` Type UserType `json:"type"` }
CreateUserParams defines the parameters required by the CreateUser mutation
type CreateUserReturn ¶
type CreateUserReturn struct {
UserIdent Identifier `json:"id"`
}
CreateUserReturn represents the return type of the CreateUser method
type EditPostParams ¶
type EditPostParams struct { PostIdent Identifier `json:"postId"` NewContents string `json:"newContents"` }
EditPostParams defines the parameters required by api.EditPost
type GetPostParams ¶
type GetPostParams struct {
Ident Identifier `json:"id"`
}
GetPostParams defines the parameters required by api.GetPost
type GetPostReactionParams ¶
type GetPostReactionParams struct {
ReactionIdent Identifier `json:"reactionId"`
}
GetPostReactionParams defines the parameters required by api.GetPostReaction
type GetPostsParams ¶
type GetPostsParams struct { After *Identifier `json:"after"` Limit uint32 `json:"limit"` }
GetPostsParams defines the parameters required by api.GetPosts
type GetReactionsOfPostParams ¶
type GetReactionsOfPostParams struct {
PostIdent Identifier `json:"postId"`
}
GetReactionsOfPostParams defines the parameters required by api.GetReactionsOfPost
type GetUserParams ¶
type GetUserParams struct {
Ident Identifier `json:"id"`
}
GetUserParams defines the parameters required by api.GetUser
type Identifier ¶
type Identifier struct {
// contains filtered or unexported fields
}
Identifier represents a 16 byte universally unique identifier
func NewIdentifier ¶
func NewIdentifier() (id Identifier)
NewIdentifier creates a new universally unique identifier
func (*Identifier) FromString ¶
func (id *Identifier) FromString(str string) (err error)
FromString parses the identifier from a hex encoded 32 char string
func (*Identifier) IsNull ¶
func (id *Identifier) IsNull() bool
IsNull return true if the identifier is nulled
func (Identifier) MarshalJSON ¶
func (id Identifier) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (*Identifier) String ¶
func (id *Identifier) String() string
String returns the textual representation of the identifier
func (*Identifier) UnmarshalJSON ¶
func (id *Identifier) UnmarshalJSON(bytes []byte) (err error)
UnmarshalJSON implements the json.Unmarshaler interface
type LoginParams ¶
LoginParams defines the parameters required by the login mutation
type Method ¶
type Method string
Method represents an API method name
const ( // Login represents an API method Login Method = "Login" // Logout represents an API method Logout Method = "Logout" // CreateUser represents an API method CreateUser Method = "CreateUser" // GetUser represents an API method GetUser Method = "GetUser" // GetPost represents an API method GetPost Method = "GetPost" // GetPosts represents an API method GetPosts Method = "GetPosts" // GetPostReaction represents an API method GetPostReaction = "GetPostReaction" // GetReactionsOfPost represents an API method GetReactionsOfPost = "GetReactionsOfPost" // CreatePost represents an API method CreatePost Method = "CreatePost" // EditPost represents an API method EditPost Method = "EditPost" // RemovePost represents an API method RemovePost Method = "RemovePost" // RemovePostReaction represents an API method RemovePostReaction Method = "RemovePostReaction" // CreatePostReaction represents an API method CreatePostReaction Method = "CreatePostReaction" )
type Post ¶
type Post struct { Ident Identifier `json:"id"` Author Identifier `json:"author"` Publication time.Time `json:"publication"` Contents string `json:"contents"` LastEdit *time.Time `json:"lastEdit"` }
Post defines the structure of a post entity
type PostReaction ¶
type PostReaction struct { Ident Identifier `json:"id"` Author Identifier `json:"author"` Type PostReactionType `json:"type"` Description string `json:"description"` Creation time.Time `json:"creation"` }
PostReaction represents a reaction to a post
type PostReactionType ¶
type PostReactionType int
PostReactionType represents a post reaction type
const ( // Celebration represents a reaction emotion Celebration PostReactionType = iota // Love represents a reaction emotion Love // Anger represents a reaction emotion Anger // Approval represents a reaction emotion Approval // Confusion represents a reaction emotion Confusion // Fear represents a reaction emotion Fear // Thinking represents a reaction emotion Thinking // Dislike represents a reaction emotion Dislike // Cry represents a reaction emotion Cry // Shock represents a reaction emotion Shock )
func (*PostReactionType) FromString ¶
func (rt *PostReactionType) FromString(str string) error
FromString parses the value from a string
func (PostReactionType) String ¶
func (rt PostReactionType) String() string
String stringifies the value
func (PostReactionType) Utf8Symbol ¶
func (rt PostReactionType) Utf8Symbol() rune
Utf8Symbol returns the UTF8 symbol corresponding to the reaction
type RemovePostParams ¶
type RemovePostParams struct {
PostIdent Identifier `json:"postId"`
}
RemovePostParams defines the parameters required by api.RemovePost
type RemovePostReactionParams ¶
type RemovePostReactionParams struct {
ReactionIdent Identifier `json:"reactionId"`
}
RemovePostReactionParams defines the parameters required by api.RemovePostReaction
type User ¶
type User struct { Identifier Identifier `json:"id"` FirstName string `json:"firstName"` LastName string `json:"lastName"` // Username uniquely identifies the user in the system, // it's also used as the login username Username string `json:"Username"` // Registration defines when this account was created Registration time.Time `json:"registration"` // Reputation defines the amount of upvotes // on posts and reactions by this user Reputation float64 `json:"reputation"` // Type defines whether this user is an admin, a regular user or a guest Type UserType `json:"type"` }
User defines the structure of a user profile
type UserType ¶
type UserType int
UserType represents the role of a user
func (*UserType) FromString ¶
FromString parses the client type from string
func (UserType) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*UserType) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface