"""tixsell URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.tixsell.com/en/4.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.template.defaulttags import url
from django.urls import path, include
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from django.views.generic import TemplateView
from backoffice.views import StripeShifterAccountReturnURLView, StripeShifterAccountURLRefreshView, signup,home,webhookAlchemy,webhookStripe, webhookStripeTest,invoice
from tixsell import settings
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
   openapi.Info(
      title="SellTix API",
      default_version='v1',
      description="SellTix API description",
      terms_of_service="https://www.google.com/policies/terms/",
      contact=openapi.Contact(email="csurbier@selltix.live"),
      license=openapi.License(name="BSD License"),
   ),
   public=False,
   permission_classes=(permissions.AllowAny,),
)

schema_view_partner = get_schema_view(
   openapi.Info(
      title="SellTix Partner API",
      default_version='v1',
      description="""
      <br>
         <img src="https://www.selltix.live/assets/imgs/logo_selltix@3x.png" width="350"><br>
        <h2>SellTix Partner API description</h2>
        <br>
        This documentation is for organizers who want to sell tickets on the SellTix platform but without the complexity of 
        the blockchain. SellTix will manage the blockchain transactions for you.<br><br>
        <b>Note:</b> To use the API, you will require a SellTix account. If you don't have one, please contact us at <a href="mailto:contact@selltix.live">contact@selltix.live</a>.
        We will send you credentials to be able to authenticate with the API and then use the endpoints available in this API.
        <br><br>To receive your payments automatically from your tickets sales, you will need to have a <a href="https://api.selltix.live/partner_api/signup/" target="_blank">Stripe account and link it with the SellTix platform</a>. 
       <br><br>
       
       <h2>How to use the API</h2>
       <br>
       <b>1. Get a JWT Token to be authentified and be able to use the API.</b><br>
        <br>
       To get a JWT Token, you will need to send a POST request with your email and password credentials to the following endpoint: <a href="https://api.selltix.live/redoc_partner_api/#tag/auth/operation/auth_jwt_create_create" target="_blank">/auth/jwt/create/</a>
       <br>
       <pre>
       <code>
            curl --location --request POST 'https://api.selltix.live/auth/jwt/create/' 
            --header 'Content-Type: application/json' 
            --data-raw '{  
                "email":"your_email_credentials", 
                "password":"your_password_credential" 
            }'
       </code>
       </pre>
       <br>You will receive a JWT Token as a response. 
       <br>
       <pre>
       <code>
             {
    "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTczNzY1MzkzMSwianRpIjoiZGE3MjBlMmZlYmE4NGQ5ZTgxZGRkNzI5NDUxOGFkZjMiLCJ1c2VyX2lkIjoiMzgzZmE3MWQtZWJjMi00MjczLWI2NGYtNzEwZTc0NmI0ZjU2In0.2Fx1dn2oeA2IyBm8zDHtF2fig9FZ_UJkYfmw_dzi9fk",
    "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIyMTA5MTMxLCJqdGkiOiJmM2FkNzI2Y2VhZTI0NTJiOGQ2ZmM2ODJhMDhmMDc0NiIsInVzZXJfaWQiOiIzODNmYTcxZC1lYmMyLTQyNzMtYjY0Zi03MTBlNzQ2YjRmNTYifQ.lmvzfxaeQDx-rl__Ddol_TWBFc6I5r6cgcp2bSdcK04"
            }
        </code>
        </pre>
        <br>
        <b>2. Use the JWT Token to access the API endpoints.</b><br>
        <br>
        To use the API endpoints, you will need to send a "Authorization" header with the value "Bearer your_jwt_token". <i>your_jwt_token</i> is the access variable you received in the previous step.
        <br><br><b>Note:</b> The JWT Token will expire after 2 hours. You will need to get a new JWT Token to be able to use the API again or use the refresh token to get a new JWT Token.
        <br><br>
        <b>3. Register as an event organizer</b><br>
         <br>
        To register as an event organizer, you will need to send a POST request to the following endpoint: <a href="https://api.selltix.live/redoc_partner_api/#tag/Events/operation/register" target="_blank">/register/</a>
         and pass your main information
        <br><br>
        <b>4. Create and manage your events</b><br>
        <br>To create, update or get your events, please refer to the <a href="https://api.selltix.live/redoc_partner_api/#tag/Events" target="_blank">Events section</a> of this documentation.
        <br><br><b>Note:</b> You will need to create at least one ticket to be able to <b>publish your event</b>.
        <br><br>
        <b>5. Create and manage your tickets</b><br>
        <br>To manage your tickets, please refer to the <a href="https://api.selltix.live/redoc_partner_api/#tag/Tickets" target="_blank">Tickets section</a> of this documentation.
        <br><br>
        Once you have created your tickets, you will need to <b>publish</b> your event to be able to sell tickets. To publish your event, you need to call the 
        <a href="https://api.selltix.live/redoc_partner_api/#tag/Events/operation/publishEvent" target="_blank">publish</a> endpoint.
        <br>An event can be published only once and cannot be unpublished. It will automatically create on blockchain the event and the tickets.<br>
         <br><br><b>Note:</b><i>The blockchain publication is an asynchronous task. Once done you will be notify on the webhook url you have specified during your registration.</i>
        """,
    #   x_tagGroups=[
    #    {
    #         'name': 'Register',
    #         'tags': ['1. Register'],
    #      },
    #      {
    #         'name': 'Events',
    #         'tags': ['2. Create your event']
    #      },
    #       {
    #         'name': 'Events',
    #         'tags': ['3. Update your event']
    #      },
    #   ],
      terms_of_service="https://www.google.com/policies/terms/",
      contact=openapi.Contact(email="contact@selltix.live"),
      license=openapi.License(name="BSD License"),
   ),
   public=True,
   permission_classes=(permissions.AllowAny,),
   patterns=[
       path('partner_api/', include('api_partner.urls')),
       path('auth/', include('djoser.urls.jwt')),
       ],
   url='https://api.selltix.live',
 
)
urlpatterns = [
    #path('', signup, name='signup'),
    path('webhook/', webhookAlchemy, name='webhookAlchemy'),
    path('home/', home, name='home'),
    path('admin/', admin.site.urls),
    path('auth/', include('djoser.urls')),
    path('auth/', include('djoser.urls.jwt')),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('api/', include('api.urls')),
    #path('swagger_partner_api/', schema_view_partner.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui-partner'),
    path('redoc_partner_api/', schema_view_partner.with_ui('redoc', cache_timeout=0), name='schema-redoc-partner'),
    path('partner_api/', include('api_partner.urls')),
    path('webhookStripeTest/', webhookStripeTest, name='webhookStripeTest'),
    path('webhookStripe/', webhookStripe, name='webhookStripe'),
    path('invoice/<uuid>/', invoice.as_view(), name='invoice'),
    #path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    #path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
   
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

