package services

import (
	"nearle/models"
	"nearle/repositories"
)

type PartnerService interface {
	GetActiveRiders(partnerid, aid, uid, tid int) ([]models.RiderInfo, error)
	GetPartners(aid, pid, uid int) ([]models.Partnerinfo, error)
	GetRiderShifts(aid int) ([]models.Ridershifts, error)
	GetLocationConfig(uid, cid int) ([]models.Locationconfigs, error)
	GetRiderLogs(pid, aid int, fdate, tdate string) ([]models.RiderlogDetails, error)
	GetRiderInfo(userid int) (models.RiderInfo, error)
	GetFleetSummary(aid, tid int, fdate, tdate string) (models.FleetSummary, error)
}

type partnerService struct {
	repo repositories.PartnerRepository
}

func NewPartnerService(repo repositories.PartnerRepository) PartnerService {
	return &partnerService{repo: repo}
}

func (s *partnerService) GetActiveRiders(partnerid, aid, uid, tid int) ([]models.RiderInfo, error) {
	return s.repo.GetActiveRiders(partnerid, aid, uid, tid)
}

func (s *partnerService) GetPartners(aid, pid, uid int) ([]models.Partnerinfo, error) {
	result, err := s.repo.GetPartners(aid, pid, uid)

	if err != nil {
		return nil, err
	}

	return result, nil
}

func (s *partnerService) GetRiderShifts(aid int) ([]models.Ridershifts, error) {

	return s.repo.GetRiderShifts(aid)
}

func (s *partnerService) GetLocationConfig(uid, cid int) ([]models.Locationconfigs, error) {

	return s.repo.GetLocationConfig(uid, cid)
}

func (s *partnerService) GetRiderLogs(pid, aid int, fdate, tdate string) ([]models.RiderlogDetails, error) {
	return s.repo.GetRiderLogs(pid, aid, fdate, tdate)
}

func (s *partnerService) GetRiderInfo(userid int) (models.RiderInfo, error) {
	return s.repo.GetRiderInfo(userid)
}

func (s *partnerService) GetFleetSummary(aid, tid int, fdate, tdate string) (models.FleetSummary, error) {
	return s.repo.GetFleetSummary(aid, tid, fdate, tdate)
}
