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, options={"default": "707660405753664"})
  19.      */
  20.     private string $phoneNumberId// the WHATSAPP_PHONE_NUMBER_ID that sends the message
  21.     /**
  22.      * @ORM\Column(type="string", length=255, nullable=false)
  23.      */
  24.     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.
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable=false)
  27.      */
  28.     private string $phone// Recipient phone number. Whatsapp order webhook return phones with prefix but without plus sign
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable=false)
  31.      */
  32.     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.
  33.     /**
  34.      * @ORM\Column(type="string", length=511, nullable=false)
  35.      */
  36.     private string $catalogId;
  37.     /**
  38.      * @ORM\Column(type="string", length=1023, nullable=true)
  39.      */
  40.     private ?string $text null;
  41.     /**
  42.      * @ORM\Column(type="datetime")
  43.      */
  44.     private DateTimeInterface $date;
  45.     
  46.     /**
  47.      * @ORM\OneToMany(targetEntity="WhatsappOrderProduct", mappedBy="whatsappOrder", cascade={"persist", "remove"}, orphanRemoval=true)
  48.      */
  49.     private ?Collection $products null;
  50.     public function __construct()
  51.     {
  52.         $this->products = new ArrayCollection();
  53.     }
  54.     public function getPhoneNumberId(): string
  55.     {
  56.         return $this->phoneNumberId;
  57.     }
  58.     public function setPhoneNumberId(string $phoneNumberId): self
  59.     {
  60.         $this->phoneNumberId $phoneNumberId;
  61.         return $this;
  62.     }
  63.     public function getWamId(): string
  64.     {
  65.         return $this->wamId;
  66.     }
  67.     public function setWamId(string $wamId): self
  68.     {
  69.         $this->wamId $wamId;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return string
  74.      * Recipient phone number. Note that Whatsapp order webhook return phones with prefix but without plus sign
  75.      */
  76.     public function getPhone(): string
  77.     {
  78.         return $this->phone;
  79.     }
  80.     /**
  81.      * Set the recipient phone number. Is returned by the API as "input" in the Response object after sending a message to the customer.
  82.      *
  83.      * @param string $phone
  84.      * @return $this
  85.      */
  86.     public function setPhone(string $phone): self
  87.     {
  88.         $this->phone $phone;
  89.         return $this;
  90.     }
  91.     public function getWaId(): string
  92.     {
  93.         return $this->waId;
  94.     }
  95.     public function setWaId(string $waId): self
  96.     {
  97.         $this->waId $waId;
  98.         return $this;
  99.     }
  100.     public function getCatalogId(): string
  101.     {
  102.         return $this->catalogId;
  103.     }
  104.     public function setCatalogId(string $catalogId): self
  105.     {
  106.         $this->catalogId $catalogId;
  107.         return $this;
  108.     }
  109.     public function getText(): ?string
  110.     {
  111.         return $this->text;
  112.     }
  113.     public function setText(?string $text): self
  114.     {
  115.         $this->text $text;
  116.         return $this;
  117.     }
  118.     public function getDate(): DateTimeInterface
  119.     {
  120.         return $this->date;
  121.     }
  122.     public function setDate(DateTimeInterface $date): self
  123.     {
  124.         $this->date $date;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection<WhatsappOrderProduct>|null
  129.      */
  130.     public function getProducts(): ?Collection
  131.     {
  132.         return $this->products;
  133.     }
  134.     public function setProducts(?Collection $products): self
  135.     {
  136.         $this->products $products;
  137.         return $this;
  138.     }
  139.     public function addProduct(WhatsappOrderProduct $product): self
  140.     {
  141.         if (!$this->getProducts()->contains($product)) {
  142.             $product->setWhatsappOrder($this);
  143.             $this->products->add($product);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeProduct(WhatsappOrderProduct $product): self
  148.     {
  149.         if ($this->getProducts()->contains($product)) {
  150.             $this->products->removeElement($product);
  151.         }
  152.         return $this;
  153.     }
  154. }