from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
from src.apps.base.schemas.common import BaseSchema
from src.core.utils.enums import PaymentMethodScopes, PaymentMethodTypes


class MerchantPaymentMethodBase(BaseSchema):
    method: Optional[str] = Field(description="Method of the payment e.g. card/ach")
    is_connected: Optional[bool] = Field(
        description="Is this payment method connected to customer?"
    )
    in_use: Optional[bool] = Field(
        description="Is this payment method in use for a payment request?"
    )
    card_details_id: Optional[int] = Field(description="Unique ID of the card details")
    ach_details_id: Optional[int] = Field(description="Unique ID of the ACH details")
    billing_address_id: Optional[int] = Field(
        description="Unique ID of the billing address"
    )
    merchant_id: Optional[int] = Field(description="Unique ID of the Merchant")
    created_at: Optional[datetime] = Field(
        description="Created date and time as unix timestamp"
    )
    updated_at: Optional[datetime] = Field(
        description="Updated date and time as unix timestamp"
    )
    deleted_at: Optional[datetime] = Field(
        description="Deleted date and time as unix timestamp"
    )


class MerchantPaymentMethodSchema(MerchantPaymentMethodBase):
    id: Optional[int] = Field(description="ID of the PaymentMethod resource")


class MerchantPaymentMethodCreateSchema(MerchantPaymentMethodBase):
    payment_method: PaymentMethodTypes = Field(
        description="Preferred payment method, (Card/ACH/Cash/Cheque)"
    )
    payment_method_token: Optional[str] = Field(
        description="Payment method token of the card"
    )


class MerchantPaymentMethodUpdateSchema(MerchantPaymentMethodBase):
    pass
