cart

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cart

type Cart struct {
	ItemId         string                    `json:"item_id"`
	Quantity       int                       `json:"quantity"`
	ItemProperties CartItemPreviewProperties `json:"properties"`
}

type CartItemPreviewDetails

type CartItemPreviewDetails struct {
	Status ItemStatus `json:"status"`
}

type CartItemPreviewProperties

type CartItemPreviewProperties struct {
	Name    string                 `json:"name"`
	Price   int                    `json:"price"`
	Details CartItemPreviewDetails `json:"details"`
}

type CartRequestPayload

type CartRequestPayload struct {
	ItemId   string `json:"item_id" binding:"required" `
	Quantity int    `json:"quantity" binding:"required"`
}

type IRepository

type IRepository interface {
	Get(UserId string) ([]InternalCart, error)
	Register(UserId string, c CartRequestPayload) error
	Update(UserId string, c CartRequestPayload) error
	Delete(UserId string, itemId string) error
	DeleteAll(UserId string) error
}

type IRequests

type IRequests interface {
	Get(userId string) ([]Cart, error)
	Register(userId string, cartRequestPayload CartRequestPayload) error
	Delete(userId string, itemId string) error
}

type IUtils

type IUtils interface {
	Inspect([]InternalCart) (map[string]InternalCart, error)
	Convert(map[string]InternalCart) []Cart
	GetTotalAmount(map[string]InternalCart) int
	InspectPayload(c CartRequestPayload, itemStatus items.ItemStatus) (CartRequestPayload, error)
}

type InternalCart

type InternalCart struct {
	Index     int
	Cart      Cart
	Item      InternalItem
	ItemStock int
	Status    items.Status
}

type InternalItem

type InternalItem struct {
	Price                   int      `gorm:"price"`
	Name                    string   `gorm:"name"`
	Description             string   `gorm:"description"`
	Tags                    []string `gorm:"tags"`
	Size                    int      `gorm:"size"`
	ManufacturerUserId      string   `gorm:"manufacturer_user_id"`
	ManufacturerName        string   `gorm:"manufacturer_name"`
	ManufacturerDescription string   `gorm:"manufacturer_description"`
	ManufacturerStripeId    string   `gorm:"manufacturer_stripe_account_id"`
}

type ItemStatus

type ItemStatus string
const (
	Available   ItemStatus = "Available"
	StockOver   ItemStatus = "Stock over"
	NoStock     ItemStatus = "No stock"
	InvalidItem ItemStatus = "Invalid item"
)

type Repository

type Repository struct {
	DB *gorm.DB
}

func (Repository) Delete

func (r Repository) Delete(UserId string, itemId string) error

func (Repository) DeleteAll

func (r Repository) DeleteAll(UserId string) error

func (Repository) Get

func (r Repository) Get(UserId string) (internalCart []InternalCart, err error)

func (Repository) Register

func (r Repository) Register(UserId string, CartRequestPayload CartRequestPayload) error

func (Repository) Update

func (r Repository) Update(UserId string, CartRequestPayload CartRequestPayload) error

type Requests

type Requests struct {
	CartRepository IRepository
	CartUtils      IUtils
	ItemGetStatus  items.IGetStatus
}

func (Requests) Delete

func (r Requests) Delete(userId string, itemId string) error

func (Requests) Get

func (r Requests) Get(userId string) (cart []Cart, err error)

func (Requests) Register

func (r Requests) Register(userId string, cartRequestPayload CartRequestPayload) error

type Utils

type Utils struct {
}

func (Utils) Convert

func (r Utils) Convert(internalCarts map[string]InternalCart) (result []Cart)

func (Utils) GetTotalAmount

func (r Utils) GetTotalAmount(internalCarts map[string]InternalCart) int

func (Utils) Inspect

func (r Utils) Inspect(internalCarts []InternalCart) (result map[string]InternalCart, err error)

func (Utils) InspectPayload

func (r Utils) InspectPayload(CartRequestPayload CartRequestPayload, itemStatus items.ItemStatus) (result CartRequestPayload, err error)

Jump to

Keyboard shortcuts

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