Includes detailed OpenAPI schemas for unsubscribe (GET and POST) and tracking pixel (GET) endpoints, supporting email compatibility and event tracking. Added support for RFC 8058-compliant one-click unsubscribe functionality and transparent image-based email tracking.
79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
from drf_spectacular.utils import extend_schema, inline_serializer
|
|
from rest_framework import serializers, status
|
|
|
|
from engine.core.docs.drf import error
|
|
from engine.vibes_auth.serializers import (
|
|
TokenObtainPairSerializer,
|
|
TokenRefreshSerializer,
|
|
TokenVerifySerializer,
|
|
UserSerializer,
|
|
)
|
|
|
|
TOKEN_OBTAIN_SCHEMA = {
|
|
"post": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("obtain a token pair"),
|
|
description=_("obtain a token pair (refresh and access) for authentication."),
|
|
request=TokenObtainPairSerializer,
|
|
responses={
|
|
status.HTTP_200_OK: inline_serializer(
|
|
"TokenObtain",
|
|
fields={
|
|
"refresh": serializers.CharField(),
|
|
"access": serializers.CharField(),
|
|
"user": UserSerializer(),
|
|
},
|
|
),
|
|
status.HTTP_400_BAD_REQUEST: error,
|
|
status.HTTP_401_UNAUTHORIZED: error,
|
|
},
|
|
)
|
|
}
|
|
|
|
TOKEN_REFRESH_SCHEMA = {
|
|
"post": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("refresh a token pair"),
|
|
description=_("refresh a token pair (refresh and access)."),
|
|
request=TokenRefreshSerializer,
|
|
responses={
|
|
status.HTTP_200_OK: inline_serializer(
|
|
"TokenRefreshResponse",
|
|
fields={
|
|
"refresh": serializers.CharField(),
|
|
"access": serializers.CharField(),
|
|
"user": UserSerializer(),
|
|
},
|
|
),
|
|
status.HTTP_400_BAD_REQUEST: error,
|
|
status.HTTP_401_UNAUTHORIZED: error,
|
|
},
|
|
)
|
|
}
|
|
|
|
TOKEN_VERIFY_SCHEMA = {
|
|
"post": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("verify a token"),
|
|
description=_("Verify a token (refresh or access)."),
|
|
request=TokenVerifySerializer,
|
|
responses={
|
|
status.HTTP_200_OK: inline_serializer(
|
|
"TokenVerifyResponse",
|
|
fields={
|
|
"token": serializers.CharField(default=_("the token is valid")),
|
|
"user": UserSerializer(),
|
|
},
|
|
),
|
|
status.HTTP_400_BAD_REQUEST: error,
|
|
status.HTTP_401_UNAUTHORIZED: error,
|
|
},
|
|
)
|
|
}
|