package http

import (
	"chonho/config"
	"chonho/docs"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func (h *Handler) InitRoute() {

	docs.SwaggerInfo.Title = "API Documentations"
	docs.SwaggerInfo.Version = "1.0"
	docs.SwaggerInfo.Host = config.Domain
	docs.SwaggerInfo.BasePath = "/v1"
	docs.SwaggerInfo.Description = `
		Authorizations: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoie1wiaWRcIjoxLFwicGhvbmVcIjpcIjA4NTIyMjIxMTZcIixcInN0YXR1c1wiOjJ9IiwiZXhwIjoxNjM1NTczOTE5fQ.qXdLss2uqA-p_dcq-eFEwD7IP6O3F_k8l-RoY1mW5yk
		X-Api-Version: 1
		X-App-Version: 1
		X-App-Platform: web`
	docs.SwaggerInfo.Schemes = []string{"https", "http"}

	// public
	h.ginApp.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	h.ginApp.GET("/v1/apartment", h.ApartmentController.ListApartment)
	h.ginApp.GET("/v1/apartment/:id", h.ApartmentController.GetApartment)
	h.ginApp.GET("/v1/category", h.CategoryController.ListCategory)
	h.ginApp.GET("/v1/store", h.StoreController.ListStore)
	h.ginApp.GET("/v1/store/payment", h.StoreController.ListStorePayment)
	h.ginApp.GET("/v1/store/:id", h.StoreController.GetStore)
	h.ginApp.GET("/v1/product", h.ProductController.ListProduct)
	h.ginApp.GET("/v1/product/:id", h.ProductController.GetProduct)

	h.ginApp.POST("/v1/register-by-device", h.AuthController.RegisterByDevice)
	h.ginApp.POST("/v1/register", h.AuthController.Register)
	h.ginApp.POST("/v1/login", h.AuthController.Login)
	h.ginApp.POST("/v1/login-by-token", h.AuthController.LoginWithFireBaseToken)
	h.ginApp.POST("/v1/upload", h.UploadController.Upload)
	h.ginApp.GET("/v1/check", h.AuthController.PhoneCheck)
	h.ginApp.GET("/v1/check/:phone", h.AuthController.PhoneCheck)

	// private
	// account
	h.ginApp.POST("/v1/user/password", h.Authorise, h.UserController.ChangePassword)
	h.ginApp.POST("/v1/user/address", h.Authorise, h.UserController.UpdateAddress)
	h.ginApp.POST("/v1/user/fcm-registration-token", h.Authorise, h.UserController.SaveToken)

	// buyer
	h.ginApp.POST("/v1/store/:id/rate", h.Authorise, h.StoreController.RateStore)
	h.ginApp.POST("/v1/order", h.Authorise, h.OrderController.CreateOrder)

	h.ginApp.POST("/v1/order/:id/payment-proof", h.Authorise, h.OrderController.ProvePayment)
	h.ginApp.POST("/v1/order/:id/cancel", h.Authorise, h.OrderController.RequestCancelOrder)
	h.ginApp.POST("/v1/order/:id/confirm-received", h.Authorise, h.OrderController.ConfirmReceived)
	h.ginApp.GET("/v1/order/:id", h.Authorise, h.OrderController.GetOrder)
	h.ginApp.GET("/v1/order", h.Authorise, h.OrderController.GetOrders)

	// seller
	h.ginApp.POST("/v1/seller/store", h.Authorise, h.SellerStoreController.CreateStore)
	h.ginApp.POST("/v1/seller/store/:id", h.Authorise, h.SellerStoreController.UpdateStore)
	h.ginApp.GET("/v1/seller/store", h.Authorise, h.SellerStoreController.ListStore)
	h.ginApp.GET("/v1/seller/store/:id", h.Authorise, h.SellerStoreController.GetStore)

	h.ginApp.POST("/v1/seller/product", h.Authorise, h.SellerProductController.AddProduct)
	h.ginApp.POST("/v1/seller/product/:id", h.Authorise, h.SellerProductController.UpdateProduct)
	h.ginApp.DELETE("/v1/seller/product/:id", h.Authorise, h.SellerProductController.DeleteProduct)
	h.ginApp.GET("/v1/seller/product/:id", h.Authorise, h.SellerProductController.GetProduct)
	h.ginApp.GET("/v1/seller/product", h.Authorise, h.SellerProductController.GetProducts)

	h.ginApp.POST("/v1/seller/order/:id/cancel", h.Authorise, h.SellerOrderController.CancelOrder)
	h.ginApp.POST("/v1/seller/order/:id/confirm", h.Authorise, h.SellerOrderController.ConfirmOrders)
	h.ginApp.POST("/v1/seller/order/:id/confirm-payment", h.Authorise, h.SellerOrderController.ConfirmOrdersPayment)
	h.ginApp.POST("/v1/seller/order/:id/delivered", h.Authorise, h.SellerOrderController.ConfirmDelivered)
	h.ginApp.GET("/v1/seller/order", h.Authorise, h.SellerOrderController.ListSellerOrder)
	h.ginApp.GET("/v1/seller/order/:id", h.Authorise, h.SellerOrderController.SellerOrderDetail)

}
