from django.db import models
from coresite.mixin import AbstractTimeStampModel
from apps.companies.models import Company
from apps.core.models import User

class Customer(AbstractTimeStampModel):
    """Call object."""
    
    name = models.CharField(max_length=255)
    name_extracted = models.CharField(max_length=255, null=True, blank=True)
    phone = models.CharField(max_length=255)
    company = models.ForeignKey(Company, on_delete=models.SET_NULL, null=True, blank=True)
    last_call_at = models.DateTimeField(null=True, blank=True)
    last_call_id = models.CharField(max_length=255)
    
    def __str__(self):
        return self.name
    
    class Meta:
        unique_together = ('phone', 'company')