src/Entity/Whatsapp/WhatsappOrder.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Whatsapp;
  3. use App\Entity\AbstractBase;
  4. use App\Repository\Whatsapp\WhatsappOrderRepository;
  5. use DateTimeInterface;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. /**
  10.  * @ORM\Table(name="vulco_whatsapp_order", indexes={@ORM\Index(name="whatsapp_order_wamid_idx", columns={"wam_id"})})
  11.  * @ORM\Entity(repositoryClass=WhatsappOrderRepository::class)
  12.  *
  13.  * @see \App\Model\Whatsapp\Webhook\Order
  14.  */
  15. class WhatsappOrder extends AbstractBase
  16. {
  17.     /**
  18.      * @ORM\Column(type="string", length=255, nullable=false)
  19.      */
  20.     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.
  21.     /**
  22.      * @ORM\Column(type="string", length=255, nullable=false)
  23.      */
  24.     private string $phone// Recipient phone number. Whatsapp order webhook return phones with prefix but without plus sign
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable=false)
  27.      */
  28.     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.
  29.     /**
  30.      * @ORM\Column(type="string", length=511, nullable=false)
  31.      */
  32.     private string $catalogId;
  33.     /**
  34.      * @ORM\Column(type="string", length=1023, nullable=true)
  35.      */
  36.     private ?string $text null;
  37.     /**
  38.      * @ORM\Column(type="datetime")
  39.      */
  40.     private DateTimeInterface $date;
  41.     
  42.     /**
  43.      * @ORM\OneToMany(targetEntity="WhatsappOrderProduct", mappedBy="whatsappOrder", cascade={"persist", "remove"}, orphanRemoval=true)
  44.      */
  45.     private ?Collection $products null;
  46.     public function __construct()
  47.     {
  48.         $this->products = new ArrayCollection();
  49.     }
  50.     public function getWamId(): string
  51.     {
  52.         return $this->wamId;
  53.     }
  54.     public function setWamId(string $wamId): self
  55.     {
  56.         $this->wamId $wamId;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return string
  61.      * Recipient phone number. Note that Whatsapp order webhook return phones with prefix but without plus sign
  62.      */
  63.     public function getPhone(): string
  64.     {
  65.         return $this->phone;
  66.     }
  67.     /**
  68.      * Set the recipient phone number. Is returned by the API as "input" in the Response object after sending a message to the customer.
  69.      *
  70.      * @param string $phone
  71.      * @return $this
  72.      */
  73.     public function setPhone(string $phone): self
  74.     {
  75.         $this->phone $phone;
  76.         return $this;
  77.     }
  78.     public function getWaId(): string
  79.     {
  80.         return $this->waId;
  81.     }
  82.     public function setWaId(string $waId): self
  83.     {
  84.         $this->waId $waId;
  85.         return $this;
  86.     }
  87.     public function getCatalogId(): string
  88.     {
  89.         return $this->catalogId;
  90.     }
  91.     public function setCatalogId(string $catalogId): self
  92.     {
  93.         $this->catalogId $catalogId;
  94.         return $this;
  95.     }
  96.     public function getText(): ?string
  97.     {
  98.         return $this->text;
  99.     }
  100.     public function setText(?string $text): self
  101.     {
  102.         $this->text $text;
  103.         return $this;
  104.     }
  105.     public function getDate(): DateTimeInterface
  106.     {
  107.         return $this->date;
  108.     }
  109.     public function setDate(DateTimeInterface $date): self
  110.     {
  111.         $this->date $date;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<WhatsappOrderProduct>|null
  116.      */
  117.     public function getProducts(): ?Collection
  118.     {
  119.         return $this->products;
  120.     }
  121.     public function setProducts(?Collection $products): self
  122.     {
  123.         $this->products $products;
  124.         return $this;
  125.     }
  126.     public function addProduct(WhatsappOrderProduct $product): self
  127.     {
  128.         if (!$this->getProducts()->contains($product)) {
  129.             $product->setWhatsappOrder($this);
  130.             $this->products->add($product);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeProduct(WhatsappOrderProduct $product): self
  135.     {
  136.         if ($this->getProducts()->contains($product)) {
  137.             $this->products->removeElement($product);
  138.         }
  139.         return $this;
  140.     }
  141. }