api

package
v0.0.0-...-05ef5cd Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = errors.New("unauthorized")
	ErrNotFound     = errors.New("user not found")
)

Functions

This section is empty.

Types

type Address

type Address struct {
	ID       uuid.UUID `json:"id"`
	Street   string    `json:"street"`
	Number   string    `json:"number"`
	Country  string    `json:"country"`
	City     string    `json:"city"`
	PostCode string    `json:"postcode"`
	Links    Links     `json:"_links"`
}

type Card

type Card struct {
	ID      uuid.UUID `json:"id"`
	LongNum string    `json:"longNum"`
	Expires string    `json:"expires"`
	CCV     string    `json:"ccv"`
	Links   Links     `json:"_links"`
}

func (*Card) MaskCC

func (c *Card) MaskCC()

type CatalogueService

type CatalogueService interface {
	ListSocks(ctx context.Context, req *ListSockParams) (*ListSockResponse, error)
}

type CountTagsResponse

type CountTagsResponse struct {
	Size int `json:"size"`
}

type CreateResponse

type CreateResponse struct {
	ID uuid.UUID `json:"id"`
}

type Health

type Health struct {
	Service string `json:"service"`
	Status  string `json:"status"`
	Time    string `json:"time"`
	Details any    `json:"details,omitempty"`
}

Health describes the health of a service

type HealthChecker

type HealthChecker interface {
	CheckHealth(ctx context.Context) ([]Health, error)
}

type HealthCheckerFunc

type HealthCheckerFunc func(ctx context.Context) ([]Health, error)

func (HealthCheckerFunc) CheckHealth

func (h HealthCheckerFunc) CheckHealth(ctx context.Context) ([]Health, error)

type HealthResponse

type HealthResponse struct {
	Healths []Health `json:"healths"`
}

type Href

type Href struct {
	Href string `json:"href"`
}
type Links map[string]Href
func NewAddressLinks(domain string, id string) Links
func NewCardLinks(domain string, id string) Links
func NewCustomerLinks(domain string, id string) Links

type ListSockParams

type ListSockParams struct {
	Tags     []string
	Order    string
	PageNum  int
	PageSize int
}

type ListSockResponse

type ListSockResponse struct {
	Socks []Sock `json:"sock"`
}

type Server

type Server struct {
	Addr          string
	Logger        *zap.Logger
	HealthChecker HealthChecker
	Router        router.Router
	// contains filtered or unexported fields
}

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

func (*Server) Stop

func (s *Server) Stop() error

type Sock

type Sock struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	ImageURL    []string  `json:"imageUrl"`
	Price       float64   `json:"price"`
	Count       int       `json:"count"`
	Tags        []string  `json:"tag"`
}

type TagsResponse

type TagsResponse struct {
	Tags []string `json:"tags"`
}

type User

type User struct {
	FirstName string    `json:"firstName"`
	LastName  string    `json:"lastName"`
	Username  string    `json:"username"`
	Password  string    `json:"password,omitempty"`
	Email     string    `json:"email"`
	ID        uuid.UUID `json:"id"`
	Links     Links     `json:"_links"`
}

type UserAdressesResponse

type UserAdressesResponse struct {
	Addresses []Address `json:"addresses"`
}

type UserCardsResponse

type UserCardsResponse struct {
	Cards []Card `json:"cards"`
}

type UserService

type UserService interface {
	Login(ctx context.Context, username, password string) (*User, error)
	Register(ctx context.Context, user User) (uuid.UUID, error)
	GetUser(ctx context.Context, id string) (*User, error)
	GetCard(ctx context.Context, id string) (*Card, error)
	GetUserCards(ctx context.Context, userID string) ([]Card, error)
	GetUserAddresses(ctx context.Context, userID string) ([]Address, error)
	GetAddresses(ctx context.Context, id string) (*Address, error)
	CreateCard(ctx context.Context, card Card, userID string) (uuid.UUID, error)
	CreateAddress(ctx context.Context, addr Address, userID string) (uuid.UUID, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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