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.
118 lines
3.5 KiB
Python
118 lines
3.5 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
from drf_spectacular.utils import extend_schema
|
|
from rest_framework import status
|
|
|
|
from engine.core.docs.drf import BASE_ERRORS
|
|
from engine.vibes_auth.serializers import (
|
|
ActivateEmailSerializer,
|
|
ConfirmPasswordResetSerializer,
|
|
MergeRecentlyViewedSerializer,
|
|
ResetPasswordSerializer,
|
|
UserSerializer,
|
|
)
|
|
|
|
USER_SCHEMA = {
|
|
"create": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("create a new user"),
|
|
request=UserSerializer,
|
|
responses={status.HTTP_201_CREATED: UserSerializer, **BASE_ERRORS},
|
|
),
|
|
"retrieve": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("retrieve a user's details"),
|
|
responses={status.HTTP_200_OK: UserSerializer, **BASE_ERRORS},
|
|
),
|
|
"update": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("update a user's details"),
|
|
request=UserSerializer,
|
|
responses={status.HTTP_200_OK: UserSerializer, **BASE_ERRORS},
|
|
),
|
|
"partial_update": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("partially update a user's details"),
|
|
request=UserSerializer,
|
|
responses={status.HTTP_200_OK: UserSerializer, **BASE_ERRORS},
|
|
),
|
|
"destroy": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("delete a user"),
|
|
responses={status.HTTP_204_NO_CONTENT: {}, **BASE_ERRORS},
|
|
),
|
|
"reset_password": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("reset a user's password by sending a reset password email"),
|
|
request=ResetPasswordSerializer,
|
|
responses={status.HTTP_200_OK: {}, **BASE_ERRORS},
|
|
),
|
|
"upload_avatar": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("handle avatar upload for a user"),
|
|
request={
|
|
"multipart/form-data": {
|
|
"type": "object",
|
|
"properties": {"avatar": {"type": "string", "format": "binary"}},
|
|
},
|
|
},
|
|
responses={
|
|
status.HTTP_200_OK: UserSerializer,
|
|
status.HTTP_400_BAD_REQUEST: {"description": "Invalid Request"},
|
|
status.HTTP_403_FORBIDDEN: {"description": "Bad credentials"},
|
|
**BASE_ERRORS,
|
|
},
|
|
),
|
|
"confirm_password_reset": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("confirm a user's password reset"),
|
|
request=ConfirmPasswordResetSerializer,
|
|
responses={
|
|
status.HTTP_200_OK: {"description": "Password reset successfully"},
|
|
status.HTTP_400_BAD_REQUEST: {"description": _("passwords do not match")},
|
|
**BASE_ERRORS,
|
|
},
|
|
),
|
|
"activate": extend_schema(
|
|
tags=[
|
|
"Auth",
|
|
],
|
|
summary=_("activate a user's account"),
|
|
request=ActivateEmailSerializer,
|
|
responses={
|
|
status.HTTP_200_OK: UserSerializer,
|
|
status.HTTP_400_BAD_REQUEST: {
|
|
"description": _(
|
|
"activation link is invalid or account already activated"
|
|
)
|
|
},
|
|
**BASE_ERRORS,
|
|
},
|
|
),
|
|
"merge_recently_viewed": extend_schema(
|
|
tags=[
|
|
"misc",
|
|
],
|
|
summary=_("merge client-stored recently viewed products"),
|
|
request=MergeRecentlyViewedSerializer,
|
|
responses={
|
|
status.HTTP_202_ACCEPTED: UserSerializer,
|
|
**BASE_ERRORS,
|
|
},
|
|
),
|
|
}
|