<?php
namespace App\Entity\Whatsapp;
use App\Entity\AbstractBase;
use App\Repository\Whatsapp\WhatsappOrderRepository;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Table(name="vulco_whatsapp_order", indexes={@ORM\Index(name="whatsapp_order_wamid_idx", columns={"wam_id"})})
* @ORM\Entity(repositoryClass=WhatsappOrderRepository::class)
*
* @see \App\Model\Whatsapp\Webhook\Order
*/
class WhatsappOrder extends AbstractBase
{
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $wamId; // wam_id or wamid (WhatsApp message ID). Messages are identified by a unique ID (WAMID). You can track message in the Webhooks through its WAMID. Is returned by the API as "id" in the Response object after sending a message to the customer.
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $phone; // Recipient phone number. Whatsapp order webhook return phones with prefix but without plus sign
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $waId; // wa_id: The customer's WhatsApp ID. A business can respond to a customer using this ID. This ID may not match the customer's phone number, which is returned by the API as "input" in the Response object after sending a message to the customer.
/**
* @ORM\Column(type="string", length=511, nullable=false)
*/
private string $catalogId;
/**
* @ORM\Column(type="string", length=1023, nullable=true)
*/
private ?string $text = null;
/**
* @ORM\Column(type="datetime")
*/
private DateTimeInterface $date;
/**
* @ORM\OneToMany(targetEntity="WhatsappOrderProduct", mappedBy="whatsappOrder", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private ?Collection $products = null;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getWamId(): string
{
return $this->wamId;
}
public function setWamId(string $wamId): self
{
$this->wamId = $wamId;
return $this;
}
/**
* @return string
* Recipient phone number. Note that Whatsapp order webhook return phones with prefix but without plus sign
*/
public function getPhone(): string
{
return $this->phone;
}
/**
* Set the recipient phone number. Is returned by the API as "input" in the Response object after sending a message to the customer.
*
* @param string $phone
* @return $this
*/
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getWaId(): string
{
return $this->waId;
}
public function setWaId(string $waId): self
{
$this->waId = $waId;
return $this;
}
public function getCatalogId(): string
{
return $this->catalogId;
}
public function setCatalogId(string $catalogId): self
{
$this->catalogId = $catalogId;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(?string $text): self
{
$this->text = $text;
return $this;
}
public function getDate(): DateTimeInterface
{
return $this->date;
}
public function setDate(DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
/**
* @return Collection<WhatsappOrderProduct>|null
*/
public function getProducts(): ?Collection
{
return $this->products;
}
public function setProducts(?Collection $products): self
{
$this->products = $products;
return $this;
}
public function addProduct(WhatsappOrderProduct $product): self
{
if (!$this->getProducts()->contains($product)) {
$product->setWhatsappOrder($this);
$this->products->add($product);
}
return $this;
}
public function removeProduct(WhatsappOrderProduct $product): self
{
if ($this->getProducts()->contains($product)) {
$this->products->removeElement($product);
}
return $this;
}
}