Documentation ¶
Index ¶
- Constants
- func RespondWithJSON(w http.ResponseWriter, r *http.Request, msg string, err string)
- func RespondWithTokenJSON(w http.ResponseWriter, r *http.Request, msg string, err string)
- func ValidateRestaurant(restaurant *Restaurant) []error
- func ValidateScore(score float64) error
- type Cart
- type CustomResponse
- type Menu
- type Order
- type OrderIDRequest
- type OrderStatus
- type PaginatedData
- type PaginatedResponse
- type QuantityItemRequest
- type Restaurant
- type TokenData
- type User
Constants ¶
const ( DefaultAPIVersion = "1.0" DefaultStartIndex = 1 )
Variables ¶
This section is empty.
Functions ¶
func RespondWithJSON ¶
RespondWithJSON message into JSON as http response
func RespondWithTokenJSON ¶
func ValidateRestaurant ¶
func ValidateRestaurant(restaurant *Restaurant) []error
ValidateRestaurant Validates such restaurant fields as ID, Score, Category and Price Range
func ValidateScore ¶
ValidateScore Validates if score for the restaurant is in a valid range
Types ¶
type Cart ¶
type Cart struct { UserID string `dynamo:"user_id"` ItemID string `dynamo:"product_id"` Item Menu `dynamo:"item"` Quantity int64 `dynamo:"quantity"` PricePerUnit float64 `dynamo:"price"` TotalPrice float64 `dynamo:"total_price"` AddedAt time.Time `dynamo:"added_at"` }
Cart is a struct for user's cart management, which entity values stored in dynamoDB table
type CustomResponse ¶
type Menu ¶
type Menu struct { ID string `gorm:"primaryKey;autoIncrement:true"` RestaurantID int `json:"restaurant_id" gorm:"index:idx_restaurant_id"` Category string `json:"category"` Name string `json:"name"` Description string `json:"description"` Price string `json:"price"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
A Menu represents menu entity which is a menu of the restaurant
type Order ¶
type Order struct { OrderID string `json:"order_id" dynamo:"order_id"` UserID string `dynamo:"user_id"` Items []Cart `dynamo:"cart"` TotalOrderPrice float64 `dynamo:"total_price"` AddedAt time.Time `dynamo:"added_at"` Status OrderStatus `dynamo:"status"` }
Order struct is takes items from user's cart and transforms to order
type OrderIDRequest ¶
type OrderIDRequest struct {
OrderID string `json:"order_id"`
}
OrderIDRequest struct for deserialization json body of order ID
type OrderStatus ¶
type OrderStatus int
OrderStatus numerical value of order status
const ( InProcess OrderStatus = iota + 1 Shipped Delivered )
OrderStatus is enum representing actual status of order
func (OrderStatus) EnumIndex ¶
func (status OrderStatus) EnumIndex() int
EnumIndex returns numerical value of order status
func (OrderStatus) String ¶
func (status OrderStatus) String() string
String returns string value of order status
type PaginatedData ¶
type PaginatedResponse ¶
type PaginatedResponse struct { APIVersion string `json:"apiVersion"` Data PaginatedData `json:"data,omitempty"` }
func NewPaginatedResponse ¶
func NewPaginatedResponse(pagination *utils.Pagination) *PaginatedResponse
type QuantityItemRequest ¶
type QuantityItemRequest struct {
Quantity int64 `json:"quantity"`
}
QuantityItemRequest struct for deserialization json body of quantity
type Restaurant ¶
type Restaurant struct { ID int64 `json:"id"` Position int64 `json:"position"` Name string `json:"name"` Score float64 `json:"score"` Ratings int64 `json:"ratings"` Category string `json:"category"` PriceRange string `json:"price_range"` FullAddress string `json:"full_address"` //TODO: Add additional validation for the zip range ZipCode string `json:"zip_code"` // TODO: add validation Lat string `json:"lat"` // TODO: add validation Lng string `json:"lng"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
Restaurant represents information about the restaurant entity
type User ¶
type User struct { UserID string `json:"user_id" gorm:"type:uuid;default:uuid_generate_v4();primaryKey"` Email string `json:"email"` Password string `json:"password"` Role string `json:"role"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
User represents a user entity/