package tncroute

import (
	"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
	"bitbucket.org/nemt/nemt-portal-api/application/notificationservice"
	"bitbucket.org/nemt/nemt-portal-api/application/tncservice"
	"bitbucket.org/nemt/nemt-portal-api/infra/config"
	"github.com/labstack/echo"
)

const (
	rootRoute          = ""
	rideRoute          = "/:ride_uuid"
	rawRideRoute       = "/:ride_uuid/raw"
	cancelRoute        = "/:ride_uuid/cancel"
	shareRoute         = "/:ride_uuid/share"
	readyRoute         = "/:ride_uuid/ready"
	etaDetailsRoute    = "/:ride_uuid/eta"
	etaRoute           = "/eta/:lat/:log/:destlat/:destlong"
	ridersRoute        = "/drivers/:lat/:log"
	typesRoute         = "/types/:lat/:log"
	messageRoute       = "/:ride_uuid/message"
	messageDriverRoute = "/:ride_uuid/message/driver"
	wsRoute            = "/ws"
)

// Register authenticate route
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service, tnc *tncservice.Service, notification *notificationservice.Service) {

	ctrl := controllerInstance(cfg, svc, tnc, notification)

	r.GET(rootRoute, ctrl.handleList)
	r.POST(rootRoute, ctrl.handle)
	r.GET(rideRoute, ctrl.handleRide)
	
	r.POST(cancelRoute, ctrl.handleCancel)
	r.POST(readyRoute, ctrl.handleReady)
	r.POST(messageRoute, ctrl.handleMessage)
	r.POST(shareRoute, ctrl.handleShare)
	r.POST(messageDriverRoute, ctrl.handleMessageDriver)

	r.GET(etaRoute, ctrl.handleETA)
	r.GET(etaDetailsRoute, ctrl.handleRideETA)
	r.GET(ridersRoute, ctrl.handleDrivers)
	r.GET(typesRoute, ctrl.handleTypes)
	r.GET(wsRoute, ctrl.handleSocket)

	if cfg.App.Debug {
		r.GET(rawRideRoute, ctrl.handleRawLyft)
	}

}
