package service

import (
	"context"
	"github.com/UpmeshLTD/urus-aio/paid-order/config"
	"github.com/UpmeshLTD/urus-aio/paid-order/domain/delivery_address"
	"github.com/UpmeshLTD/urus-aio/paid-order/domain/delivery_address_log"
	"github.com/UpmeshLTD/urus-aio/paid-order/domain/fulfillment"
	"github.com/UpmeshLTD/urus-aio/paid-order/domain/paid_order"
	"github.com/UpmeshLTD/urus-aio/paid-order/external/cart"
	"github.com/UpmeshLTD/urus-aio/paid-order/external/mdm"
	"github.com/gin-gonic/gin"
)

//go:generate mockery --name=Service --case=snake
type Service interface {
	iHealthCheck
	iFulfillment
	iDeliveryAddress
	iPaidOrder
	iGRPC
}

type serviceImpl struct {
	config                   config.Config
	fulfillmentDomain        fulfillment.Service
	paidOrderDomain          paid_order.Service
	deliveryAddressDomain    delivery_address.Service
	deliveryAddressLogDomain delivery_address_log.Service
	mdmClient                mdm.Service
	cartService              cart.Service
}

func NewService(
	config config.Config,
	fulfillmentDomain fulfillment.Service,
	paidOrderDomain paid_order.Service,
	deliveryAddress delivery_address.Service,
	deliveryAddressLog delivery_address_log.Service,
	mdmClient mdm.Service,
	cartService cart.Service,
) Service {
	return &serviceImpl{
		config:                   config,
		fulfillmentDomain:        fulfillmentDomain,
		paidOrderDomain:          paidOrderDomain,
		deliveryAddressDomain:    deliveryAddress,
		deliveryAddressLogDomain: deliveryAddressLog,
		mdmClient:                mdmClient,
		cartService:              cartService,
	}
}

func getCtx(c *gin.Context) context.Context {
	return c.Request.Context()
}
