from django.urls import include, path
from rest_framework import routers
from rest_framework.authtoken.views import obtain_auth_token

from . import views
from sync.views import SynchronizationApi, UserDataAccessApi, DataAccessViewSet
from authentication.views import CustomAuthToken, Logout, ChangePasswordView

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'user-agents', views.ShortUserViewSet)
router.register(r'clubs', views.ClubViewSet)
router.register(r'tournaments', views.TournamentViewSet)
router.register(r'tournament-summaries', views.TournamentSummaryViewSet)
router.register(r'images', views.ImageViewSet)
router.register(r'events', views.EventViewSet)
router.register(r'rounds', views.RoundViewSet)
router.register(r'group-stages', views.GroupStageViewSet)
router.register(r'matches', views.MatchViewSet)
router.register(r'team-scores', views.TeamScoreViewSet)
router.register(r'team-registrations', views.TeamRegistrationViewSet)
router.register(r'player-registrations', views.PlayerRegistrationViewSet)
router.register(r'purchases', views.PurchaseViewSet)
router.register(r'courts', views.CourtViewSet)
router.register(r'date-intervals', views.DateIntervalViewSet)
router.register(r'draw-logs', views.DrawLogViewSet)
router.register(r'failed-api-calls', views.FailedApiCallViewSet)
router.register(r'logs', views.LogViewSet)
router.register(r'device-token', views.DeviceTokenViewSet)
router.register(r'data-access', DataAccessViewSet)
router.register(r'unregistered-teams', views.UnregisteredTeamViewSet)
router.register(r'unregistered-players', views.UnregisteredPlayerViewSet)
### biz
router.register(r'crm-prospects', views.CRMProspectViewSet)
router.register(r'crm-entities', views.CRMEntityViewSet)
router.register(r'crm-activities', views.CRMActivityViewSet)

urlpatterns = [
    path('', include(router.urls)),

    path('sync-data/', SynchronizationApi.as_view(), name="data"),
    path('data-access-content/', UserDataAccessApi.as_view(), name="data-access-content"),
    path("is_granted_unlimited_access/", views.is_granted_unlimited_access, name="is-granted-unlimited-access"),

    path('api-token-auth/', obtain_auth_token, name='api_token_auth'),
    path("user-by-token/", views.user_by_token, name="user_by_token"),
    path('refund-tournament/<str:team_registration_id>/', views.process_refund, name='process-refund'),
    path('validate-stripe-account/', views.validate_stripe_account, name='validate_stripe_account'),
    path('xls-to-csv/', views.xls_to_csv, name='xls-to-csv'),
    path('config/tournament/', views.get_tournament_config, name='tournament-config'),
    path('config/payment/', views.get_payment_config, name='payment-config'),
    path('fft/club-tournaments/', views.get_fft_club_tournaments, name='get-fft-club-tournaments'),
    path('fft/all-tournaments/', views.get_fft_all_tournaments, name='get-fft-all-tournaments'),
    path('fft/umpire/<str:tournament_id>/', views.get_fft_umpire_data, name='get-fft-umpire-data'),
    path('fft/federal-clubs/', views.get_fft_federal_clubs, name='get-fft-federal-clubs'),

    # authentication
    path("change-password/", ChangePasswordView.as_view(), name="change_password"),
    path('token-auth/', CustomAuthToken.as_view()),
    path('api-token-logout/', Logout.as_view()),

    # forgotten password
    path('dj-rest-auth/', include('dj_rest_auth.urls')),
    path('stripe/create-account/', views.create_stripe_connect_account, name='create_stripe_account'),
    path('stripe/create-account-link/', views.create_stripe_account_link, name='create_account_link'),

]
