<filename>src/oauth/serializer.py
from rest_framework import serializers
from . import models


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.AuthUser
        fields = ("email", "avatar", "country", "city", "bio", "display_name")


class SocialLinkSerializer(serializers.ModelSerializer):
    id = (
        serializers.IntegerField()
    )  # read_only=True для id не обязательно добавлять readonly (как пример для других полей)

    class Meta:
        model = models.SocialLink
        fields = ("id", "link")


class AuthorSerializer(serializers.ModelSerializer):
    social_links = SocialLinkSerializer(many=True)

    class Meta:
        model = models.AuthUser
        fields = (
            "id",
            "avatar",
            "country",
            "city",
            "bio",
            "display_name",
            "social_links",
        )


class GoogleAuth(serializers.Serializer):
    """Сериализация данных от Google"""

    email = serializers.EmailField()
    token = serializers.CharField()
