from django.urls import path, include
from rest_framework.routers import DefaultRouter
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework.permissions import AllowAny
from .views import (
    PriceTypeViewSet, PriceListViewSet, DiscountViewSet,
    PriceChangeHistoryViewSet, PriceTagViewSet, DiscountHistoryViewSet, PriceListWithDiscountViewSet
)

# Create the router for pricing-related views
router_pricing = DefaultRouter()
router_pricing.register(r'price-types', PriceTypeViewSet)
router_pricing.register(r'price-lists', PriceListViewSet)
router_pricing.register(r'discounts', DiscountViewSet)
router_pricing.register(r'price-change-history', PriceChangeHistoryViewSet)
router_pricing.register(r'price-tags', PriceTagViewSet)
router_pricing.register(r'discount-history', DiscountHistoryViewSet)
router_pricing.register(r'price-lists-with-discounts', PriceListWithDiscountViewSet)

# Swagger schema view for pricing
schema_view_pricing = get_schema_view(
    openapi.Info(
        title="Store Management API - Pricing",
        default_version='v1',
        description="API for managing pricing in the franchise store",
        terms_of_service="https://www.example.com/terms/",
        contact=openapi.Contact(email="support@example.com"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(AllowAny,),
)

urlpatterns = [
    path('', include(router_pricing.urls)),
    path('swagger/', schema_view_pricing.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui-pricing'),
    path('redoc/', schema_view_pricing.with_ui('redoc', cache_timeout=0), name='schema-redoc-pricing'),
]
