__author__ = "Florian Kaiser"
__copyright__ = "Copyright 2022, Project Aktienbot"
__credits__ = ["Florian Kaiser", "Florian Kellermann", "Linus Eickhof", "Kevin Pauer"]
__license__ = "GPL 3.0"
__version__ = "1.0.1"

from apiflask import Schema
from apiflask.fields import Integer, String, Boolean, Field, Float
from marshmallow import validate
from marshmallow.fields import Email


class BaseResponseSchema(Schema):
    text = String()
    status = Integer()
    data = Field()


class UsersSchema(Schema):
    admin = Boolean()
    password = String()
    username = String()
    telegram_user_id = String()
    email = Email()
    cron = String()


class AdminDataSchema(Schema):
    email = Email()
    admin = Boolean()


class CronDataSchema(Schema):
    cron = String()


class TokenSchema(Schema):
    token = String()


class LoginDataSchema(Schema):
    email = Email()
    password = String()


class RegisterDataSchema(Schema):
    email = Email()
    username = String()
    password = String()


class UpdateUserDataSchema(Schema):
    username = String(required=False)
    password = String(required=False)


class DeleteUserSchema(Schema):
    email = Email()


class ChangePasswordSchema(Schema):
    old_password = String()
    new_password = String()


class ChangeUsernameSchema(Schema):
    new_username = String()


class KeywordSchema(Schema):
    keyword = String()


class SymbolSchema(Schema):
    isin = String()
    comment = String()


class SymbolRemoveSchema(Schema):
    isin = String()


class TransactionSchema(Schema):
    isin = String()
    comment = String()
    time = String(validate=validate.Regexp(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z"))
    count = Integer()
    price = Float()


class SymbolPriceSchema(Schema):
    isin = String()
    time = String(validate=validate.Regexp(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z"))
    price = Float()


class TelegramIdSchema(Schema):
    telegram_user_id = String()


class DeleteSuccessfulSchema(Schema):
    pass


class KeywordResponseSchema(Schema):
    keyword = String()
    s_id = Integer()
    email = Email()


class SymbolResponseSchema(Schema):
    isin = String()
    comment = String()
    s_id = Integer()
    email = Email()


class PortfolioShareResponseSchema(Schema):
    count = Integer()
    last_transaction = String()


class TransactionResponseSchema(Schema):
    email = Email()
    isin = String()
    comment = String()
    time = String()
    count = Integer()
    price = Float()


class PortfolioResponseSchema(Schema):
    isin = String()
    comment = String()
    last_transaction = String()
    count = Integer()
    # price = Float()
