api

package
v0.0.0-...-0716d42 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func (*API) CompleteTask

func (a *API) CompleteTask(ctx context.Context, c echo.Context, accessToken string, id string) (*models.Task, error)

func (*API) CreateTask

func (a *API) CreateTask(ctx context.Context, c echo.Context, accessToken string, task *TaskCreateRequest) (*models.Task, error)

func (*API) GetCurrentUser

func (a *API) GetCurrentUser(ctx context.Context, c echo.Context, accessToken string) (*models.User, error)

func (*API) GetTask

func (a *API) GetTask(ctx context.Context, c echo.Context, accessToken string, id string) (*models.Task, error)

func (*API) GetUser

func (a *API) GetUser(ctx context.Context, c echo.Context, username string) (*models.User, error)

func (*API) ListTasks

func (a *API) ListTasks(ctx context.Context, c echo.Context, accessToken string, params *TasksListParams) (*TasksListResponse, error)

func (*API) Login

func (a *API) Login(ctx context.Context, req AuthLoginRequest) (*AuthLoginResponse, error)

func (*API) Refresh

func (a *API) Refresh(ctx context.Context, c echo.Context) (*AuthRefreshResponse, error)

func (*API) ReopenTask

func (a *API) ReopenTask(ctx context.Context, c echo.Context, accessToken string, id string) (*models.Task, error)

func (*API) Signup

func (a *API) Signup(ctx context.Context, req AuthSignupRequest) (*models.User, error)

func (*API) Token

func (a *API) Token(ctx context.Context, c echo.Context, token string) (*Token, error)

func (*API) TransitionTask

func (a *API) TransitionTask(ctx context.Context, c echo.Context, accessToken string, id string, task *TransitionTask) (*models.Task, error)

func (*API) UpdateCurrentUser

func (a *API) UpdateCurrentUser(ctx context.Context, c echo.Context, accessToken string, user *CurrentUserUpdateRequest) (*models.User, error)

func (*API) UpdateTask

func (a *API) UpdateTask(ctx context.Context, c echo.Context, accessToken string, id string, task *TaskUpdateRequest) (*models.Task, error)

type APIError

type APIError struct {
	Code    int
	Message string   `json:"message"`
	Errors  []string `json:"errors"`
}

func (*APIError) Error

func (ae *APIError) Error() string

func (*APIError) Response

func (ae *APIError) Response(c echo.Context, session *models.Session) error

type AuthLoginRequest

type AuthLoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type AuthLoginResponse

type AuthLoginResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
}

type AuthRefreshRequest

type AuthRefreshRequest struct {
	RefreshToken string `json:"refresh_token"`
}

type AuthRefreshResponse

type AuthRefreshResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
}

type AuthSignupRequest

type AuthSignupRequest struct {
	Email    string `json:"email"`
	Username string `json:"username"`
	Name     string `json:"name"`
	Password string `json:"password"`
}

type CurrentUserUpdateRequest

type CurrentUserUpdateRequest struct {
	Name string `json:"name" form:"name"`
	Bio  string `json:"bio" form:"bio"`
}

type IAPI

type IAPI interface {
	Login(ctx context.Context, req AuthLoginRequest) (*AuthLoginResponse, error)
	Signup(ctx context.Context, req AuthSignupRequest) (*models.User, error)
	Refresh(ctx context.Context, c echo.Context) (*AuthRefreshResponse, error)
	Token(ctx context.Context, c echo.Context, accessToken string) (*Token, error)

	GetCurrentUser(ctx context.Context, c echo.Context, accessToken string) (*models.User, error)
	UpdateCurrentUser(ctx context.Context, c echo.Context, accessToken string, user *CurrentUserUpdateRequest) (*models.User, error)

	CreateTask(ctx context.Context, c echo.Context, accessToken string, task *TaskCreateRequest) (*models.Task, error)
	GetTask(ctx context.Context, c echo.Context, accessToken string, id string) (*models.Task, error)
	UpdateTask(ctx context.Context, c echo.Context, accessToken string, id string, task *TaskUpdateRequest) (*models.Task, error)
	TransitionTask(ctx context.Context, c echo.Context, accessToken string, id string, task *TransitionTask) (*models.Task, error)
	CompleteTask(ctx context.Context, c echo.Context, accessToken string, id string) (*models.Task, error)
	ReopenTask(ctx context.Context, c echo.Context, accessToken string, id string) (*models.Task, error)

	ListTasks(ctx context.Context, c echo.Context, accessToken string, params *TasksListParams) (*TasksListResponse, error)

	GetUser(ctx context.Context, c echo.Context, username string) (*models.User, error)
}

func NewAPI

func NewAPI(db *redis.Client) IAPI

type Pagination

type Pagination struct {
	Page       int
	PerPage    int
	Total      int
	TotalPages int
	NextPage   *int
	PrevPage   *int
}

type TaskCreateRequest

type TaskCreateRequest struct {
	Title string `json:"title" form:"title"`
}

type TaskUpdateRequest

type TaskUpdateRequest struct {
	Title string `json:"title" form:"title"`
}

type TasksListParams

type TasksListParams struct {
	Completed []string
	CreatedBy string
	Page      string
	PerPage   string
	Query     string
}

type TasksListResponse

type TasksListResponse struct {
	Pagination *Pagination
	Tasks      []models.Task `json:"tasks"`
}

type Token

type Token struct {
	Exp   *time.Time `json:"exp"`
	Iat   *time.Time `json:"iat"`
	Iss   string     `json:"iss"`
	Nbf   *time.Time `json:"nbf"`
	Roles []string   `json:"roles"`
	Sub   string     `json:"sub"`
	Type  string     `json:"type"`
}

type TransitionTask

type TransitionTask struct {
	Completed bool `json:"completed"`
}

Jump to

Keyboard shortcuts

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