<?php
namespace App\Entity;
use App\Service\Helper\DateTimeHelper;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Exception;
/**
* Class Call
* @ORM\Table(name="mango__calls",
* indexes={
* @ORM\Index(columns={"created_at"}),
* @ORM\Index(columns={"phone"}),
* @ORM\Index(columns={"status"}),
* @ORM\Index(columns={"direction"}),
* @ORM\Index(columns={"missed_status"}),
* })
* @ORM\Entity(repositoryClass="App\Repository\MangoCallRepository")
*/
class MangoCall
{
const DIRECTION_INCOMING = 'incoming';
const DIRECTION_OUTGOING = 'outgoing';
const DIRECTION_INNER = 'inner';
const DIRECTIONS = [
self::DIRECTION_INCOMING => 'входящий',
self::DIRECTION_OUTGOING => 'исходящий',
self::DIRECTION_INNER => 'внутренний',
];
const STATUS_ANSWERED = 'ANSWERED';
const STATUS_NO_ANSWER = 'NO ANSWER';
const STATUS_FAILED = 'FAILED';
const STATUS_BUSY = 'BUSY';
const MISSED_STATUS_MISSED = 'missed';
const MISSED_STATUS_RECALL = 'recall';
use IdTrait;
use UpdatedAtTrait;
/**
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private DateTime $createdAt;
/**
* @ORM\ManyToOne(targetEntity="Manager")
* @ORM\JoinColumn(name="manager_id", referencedColumnName="id", nullable=true)
*/
private ?Manager $manager = null;
/**
* @ORM\Column(name="phone", type="string", nullable=false)
*/
private string $phone;
/**
* @ORM\Column(name="sip_id", type="string", unique=true, nullable=false)
*/
private string $sipId;
/**
* @ORM\Column(name="recording_id", type="string", nullable=true)
*/
private ?string $recordingId = null;
/**
* @ORM\Column(name="status", type="string", nullable=true)
*/
private ?string $status = null;
/**
* @ORM\Column(name="duration", type="integer")
*/
private int $duration = 0;
/**
* @ORM\Column(name="direction", nullable=false, type="string")
*/
private string $direction;
/**
* @ORM\Column(name="missed_status", nullable=true, type="string")
*/
private ?string $missedStatus = null;
/**
* @ORM\ManyToOne(targetEntity="Customer")
* @ORM\JoinColumn(name="customer_id", nullable=true, referencedColumnName="id")
*/
private ?Customer $customer = null;
/**
* @ORM\OneToOne(targetEntity="Lead", mappedBy="mangoCall")
*/
private ?Lead $lead = null;
/**
* @throws Exception
*/
public function __construct(string $phone, string $sipId, string $direction)
{
$this->phone = $phone;
$this->sipId = $sipId;
$this->direction = $direction;
$this->createdAt = DateTimeHelper::getNowDateTime();
}
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
public function getPhone(): string
{
return $this->phone;
}
public function getSipId(): string
{
return $this->sipId;
}
public function getManager(): ?Manager
{
return $this->manager;
}
public function setManager(?Manager $manager): void
{
$this->manager = $manager;
}
public function getDirection(): string
{
return $this->direction;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): MangoCall
{
$this->status = $status;
return $this;
}
public function getDuration(): int
{
return $this->duration;
}
public function setDuration(int $duration): MangoCall
{
$this->duration = $duration;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function getRecordingId(): ?string
{
return $this->recordingId;
}
public function setRecordingId(?string $recordingId): MangoCall
{
$this->recordingId = $recordingId;
return $this;
}
public function getMissedStatus(): ?string
{
return $this->missedStatus;
}
public function setMissedStatus(?string $missedStatus): MangoCall
{
$this->missedStatus = $missedStatus;
return $this;
}
public function setCustomer(?Customer $customer): MangoCall
{
$this->customer = $customer;
return $this;
}
public function getLead(): ?Lead
{
return $this->lead;
}
public function setLead(?Lead $lead): MangoCall
{
$this->lead = $lead;
return $this;
}
}