api

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageAPI

type MessageAPI struct {
	DB       MessageDatabase
	Notifier Notifier
}

The MessageAPI provides handlers for managing messages.

func (*MessageAPI) CreateMessage

func (a *MessageAPI) CreateMessage(ctx *gin.Context)

CreateMessage creates a message, authentication via application-token is required.

func (*MessageAPI) DeleteMessage

func (a *MessageAPI) DeleteMessage(ctx *gin.Context)

DeleteMessage deletes a message with an id.

func (*MessageAPI) DeleteMessageWithApplication

func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context)

DeleteMessageWithApplication deletes all messages from a specific application.

func (*MessageAPI) DeleteMessages

func (a *MessageAPI) DeleteMessages(ctx *gin.Context)

DeleteMessages delete all messages from a user.

func (*MessageAPI) GetMessages

func (a *MessageAPI) GetMessages(ctx *gin.Context)

GetMessages returns all messages from a user.

func (*MessageAPI) GetMessagesWithApplication

func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context)

GetMessagesWithApplication returns all messages from a specific application.

type MessageDatabase

type MessageDatabase interface {
	GetMessagesByApplication(id uint) []*model.Message
	GetApplicationByID(id uint) *model.Application
	GetMessagesByUser(userID uint) []*model.Message
	DeleteMessageByID(id uint) error
	GetMessageByID(id uint) *model.Message
	DeleteMessagesByUser(userID uint) error
	DeleteMessagesByApplication(applicationID uint) error
	CreateMessage(message *model.Message) error
	GetApplicationByToken(token string) *model.Application
}

The MessageDatabase interface for encapsulating database access.

type Notifier

type Notifier interface {
	Notify(userID uint, message *model.Message)
}

Notifier notifies when a new message was created.

type TokenAPI

type TokenAPI struct {
	DB TokenDatabase
}

The TokenAPI provides handlers for managing clients and applications.

func (*TokenAPI) CreateApplication

func (a *TokenAPI) CreateApplication(ctx *gin.Context)

CreateApplication creates an application and returns the access token.

func (*TokenAPI) CreateClient

func (a *TokenAPI) CreateClient(ctx *gin.Context)

CreateClient creates a client and returns the access token.

func (*TokenAPI) DeleteApplication

func (a *TokenAPI) DeleteApplication(ctx *gin.Context)

DeleteApplication deletes an application by its id.

func (*TokenAPI) DeleteClient

func (a *TokenAPI) DeleteClient(ctx *gin.Context)

DeleteClient deletes a client by its id.

func (*TokenAPI) GetApplications

func (a *TokenAPI) GetApplications(ctx *gin.Context)

GetApplications returns all applications a user has.

func (*TokenAPI) GetClients

func (a *TokenAPI) GetClients(ctx *gin.Context)

GetClients returns all clients a user has.

type TokenDatabase

type TokenDatabase interface {
	CreateApplication(application *model.Application) error
	GetApplicationByToken(token string) *model.Application
	GetApplicationByID(id uint) *model.Application
	GetApplicationsByUser(userID uint) []*model.Application
	DeleteApplicationByID(id uint) error

	CreateClient(client *model.Client) error
	GetClientByToken(token string) *model.Client
	GetClientByID(id uint) *model.Client
	GetClientsByUser(userID uint) []*model.Client
	DeleteClientByID(id uint) error
}

The TokenDatabase interface for encapsulating database access.

type UserAPI

type UserAPI struct {
	DB               UserDatabase
	PasswordStrength int
}

The UserAPI provides handlers for managing users.

func (*UserAPI) ChangePassword

func (a *UserAPI) ChangePassword(ctx *gin.Context)

ChangePassword changes the password from the current user

func (*UserAPI) CreateUser

func (a *UserAPI) CreateUser(ctx *gin.Context)

CreateUser creates a user

func (*UserAPI) DeleteUserByID

func (a *UserAPI) DeleteUserByID(ctx *gin.Context)

DeleteUserByID deletes the user by id

func (*UserAPI) GetCurrentUser

func (a *UserAPI) GetCurrentUser(ctx *gin.Context)

GetCurrentUser returns the current user

func (*UserAPI) GetUserByID

func (a *UserAPI) GetUserByID(ctx *gin.Context)

GetUserByID returns the user by id

func (*UserAPI) GetUsers

func (a *UserAPI) GetUsers(ctx *gin.Context)

GetUsers returns all the users

func (*UserAPI) UpdateUserByID

func (a *UserAPI) UpdateUserByID(ctx *gin.Context)

UpdateUserByID updates and user by id

type UserDatabase

type UserDatabase interface {
	GetUsers() []*model.User
	GetUserByID(id uint) *model.User
	GetUserByName(name string) *model.User
	DeleteUserByID(id uint) error
	UpdateUser(user *model.User)
	CreateUser(user *model.User) error
}

The UserDatabase interface for encapsulating database access.

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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