Documentation
¶
Index ¶
- Variables
- type CalculateOrderEstimateRequest
- type CalculateOrderEstimateResponse
- type CalculatedEstimate
- type CalculatedEstimateMerchants
- type CreateOrderRequest
- type CreateOrderResponse
- type Handler
- type Item
- type Items
- type Order
- type OrderItem
- type OrderItemRequest
- type OrderRequest
- type Repository
- type SearchOrderDetailItemResponse
- type SearchOrderDetailResponse
- type SearchOrderPayload
- type SearchOrderResponse
- type Service
- type UserLocationRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrValidationFailed = errors.New("validation failed") ErrStartingPointInvalid = errors.New("starting point must be exactly 1") ErrSomeMerchantNotFound = errors.New("some merchants are not found") ErrSomeItemNotFound = errors.New("some items are not found") ErrDistanceTooFar = errors.New("distance too far") ErrCalculatedEstimateNotFound = errors.New("calculated estimate not found") )
Functions ¶
This section is empty.
Types ¶
type CalculateOrderEstimateRequest ¶
type CalculateOrderEstimateRequest struct {
UserLocation UserLocationRequest `json:"userLocation"`
Orders []OrderRequest `json:"orders"`
}
func (CalculateOrderEstimateRequest) Validate ¶
func (p CalculateOrderEstimateRequest) Validate() error
type CalculatedEstimate ¶
type CalculatedEstimateMerchants ¶
type CalculatedEstimateMerchants []string
func (*CalculatedEstimateMerchants) Scan ¶
func (a *CalculatedEstimateMerchants) Scan(value interface{}) error
Make the Attrs struct implement the sql.Scanner interface. This method simply decodes a JSON-encoded value into the struct fields.
type CreateOrderRequest ¶
type CreateOrderRequest struct {
CalculatedEstimateID string `json:"calculatedEstimateId"`
}
func (CreateOrderRequest) Validate ¶
func (p CreateOrderRequest) Validate() error
type CreateOrderResponse ¶
type CreateOrderResponse struct {
OrderID string `json:"orderId"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) CalculateEstimate ¶
func (h *Handler) CalculateEstimate(w http.ResponseWriter, r *http.Request)
func (*Handler) CreateOrder ¶
func (h *Handler) CreateOrder(w http.ResponseWriter, r *http.Request)
func (*Handler) SearchOrders ¶
func (h *Handler) SearchOrders(w http.ResponseWriter, r *http.Request)
type Items ¶
type Items []Item
type OrderItemRequest ¶
func (OrderItemRequest) Validate ¶
func (p OrderItemRequest) Validate() error
type OrderRequest ¶
type OrderRequest struct {
MerchantID string `json:"merchantId"`
IsStartingPoint *bool `json:"isStartingPoint"`
Items []OrderItemRequest `json:"items"`
}
func (OrderRequest) Validate ¶
func (p OrderRequest) Validate() error
type Repository ¶
type Repository interface {
InsertCalculatedEstimate(ctx context.Context, calculatedEstimate *CalculatedEstimate) error
GetCalculatedEstimate(ctx context.Context, id string) (*CalculatedEstimate, error)
InsertOrder(ctx context.Context, order *Order) error
InsertOrderItem(ctx context.Context, orderItem *OrderItem) error
ListOrdersByUserID(ctx context.Context, userID string) (*Order, error)
ListOrderItemsByOrderID(ctx context.Context, orderID string) ([]*OrderItem, error)
SearchOrderItemMerchants(ctx context.Context, req SearchOrderPayload, userID string) ([]*searchOrderItemMerchantsQueryResult, error)
}
func NewRepository ¶
func NewRepository(db *db.DB) Repository
type SearchOrderDetailItemResponse ¶
type SearchOrderDetailItemResponse struct {
merchantitems.MerchantItemResponse
Quantity int `json:"quantity"`
}
type SearchOrderDetailResponse ¶
type SearchOrderDetailResponse struct {
Merchant merchants.MerchantsResponse `json:"merchant"`
Items []SearchOrderDetailItemResponse `json:"items"`
}
type SearchOrderPayload ¶
type SearchOrderPayload struct {
MerchantID string `schema:"merchantId" binding:"omitempty"`
Name string `schema:"name" binding:"omitempty"`
MerchantCategory string `schema:"merchantCategory" binding:"omitempty"`
Limit int `schema:"limit" binding:"omitempty"`
Offset int `schema:"offset" binding:"omitempty"`
}
type SearchOrderResponse ¶
type SearchOrderResponse struct {
OrderID string `json:"orderId"`
Orders []SearchOrderDetailResponse `json:"orders"`
}
type Service ¶
type Service interface {
CalculateEstimate(ctx context.Context, req CalculateOrderEstimateRequest, userID string) (*CalculateOrderEstimateResponse, error)
CreateOrder(ctx context.Context, req CreateOrderRequest, userID string) (*CreateOrderResponse, error)
SearchOrders(ctx context.Context, req SearchOrderPayload, userID string) ([]*SearchOrderResponse, error)
}
func NewService ¶
func NewService(repository Repository, merchantRepository merchants.Repository, merchantItemsRepository merchantitems.Repository) Service
type UserLocationRequest ¶
func (UserLocationRequest) Validate ¶
func (p UserLocationRequest) Validate() error
Click to show internal directories.
Click to hide internal directories.