src/V4/Model/Customer/Customer.php line 41

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Customer;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Enum\LanguageEnum;
  6. use App\Model\CustomerFile\CustomerFile;
  7. use App\Model\IriNormalizableInterface;
  8. use App\Model\Module\Module;
  9. use App\Model\NormalizeAsIRITrait;
  10. use App\Model\Security\UserInfo;
  11. use App\Model\Traits\ImportableObjectTrait;
  12. use App\V4\Model\OutlookSubscriptionConfiguration\OutlookSubscriptionConfiguration;
  13. use DateTime;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. /**
  19.  * @ApiResource(
  20.  *     shortName="V4/Customer",
  21.  *     collectionOperations={
  22.  *         "get_deleted": {
  23.  *             "method": "GET",
  24.  *             "path": "/V4/customers/deleted-customers",
  25.  *             "controller": "App\V4\Action\Customer\GetDeletedCustomersAction",
  26.  *         }
  27.  *     },
  28.  *     itemOperations={
  29.  *         "restore": {
  30.  *             "input": false,
  31.  *             "method": "POST",
  32.  *             "path": "/V4/customers/{id}/restore",
  33.  *             "controller": "App\V4\Action\Customer\RestoreCustomerAction",
  34.  *         }
  35.  *     }
  36.  * )
  37.  */
  38. class Customer implements IriNormalizableInterface
  39. {
  40.     public const AIRNOV_CUSTOMER_ID 'customer_124';
  41.     use ImportableObjectTrait;
  42.     use NormalizeAsIRITrait;
  43.     public const JHOOD_CUSTOMER_ID '0662705af65c48908b017d8fb0724bac';
  44.     /**
  45.      * @ApiProperty(identifier=true)
  46.      *
  47.      * @var string|null
  48.      * @Groups({
  49.      *     "read", "list", "write", "section:list", "section:read",
  50.      *     "outlook_subscription_configuration:list", "outlook_subscription_configuration:read", "outlook_subscription_configuration:write", "outlook_subscription_configuration:update"
  51.      * })
  52.      */
  53.     private $id;
  54.     /**
  55.      * @var string|null
  56.      * @Assert\NotBlank(message="Le nom de l'entreprise est obligatoire")
  57.      * @Groups({
  58.      *
  59.      *     "read", "list", "write"
  60.      * })
  61.      */
  62.     private $name;
  63.     /**
  64.      * @var DateTime|null
  65.      * @Groups({"read", "list", "write"})
  66.      */
  67.     private $expiredAt;
  68.     /**
  69.      * @var bool|null
  70.      * @Groups({"read", "list", "write"})
  71.      */
  72.     private $isActive true;
  73.     /**
  74.      * @var bool|null
  75.      * @Groups({"read", "list", "write"})
  76.      */
  77.     private $isLiveo false;
  78.     /**
  79.      * @var bool|null
  80.      * @Groups({"read", "list", "write"})
  81.      */
  82.     private $hasIntranet false;
  83.     /**
  84.      * @var string|null
  85.      * @Groups({"read", "list", "write"})
  86.      */
  87.     private $phone;
  88.     /**
  89.      * @var string|null
  90.      * @Groups({"read", "list", "write"})
  91.      */
  92.     private $fax;
  93.     /**
  94.      * @var int|null
  95.      * @Groups({"read"})
  96.      */
  97.     private $activeUsersNumber;
  98.     /**
  99.      * @var string|null
  100.      * @Groups({"read", "list", "write"})
  101.      */
  102.     private $email;
  103.     /**
  104.      * @var string|null
  105.      * @Groups({"read", "list", "write"})
  106.      */
  107.     private $website;
  108.     /**
  109.      * @var string|null
  110.      * @Groups({"read", "list", "write"})
  111.      */
  112.     private $address;
  113.     /**
  114.      * @var string|null
  115.      * @Groups({"read", "list", "write"})
  116.      */
  117.     private $postalCode;
  118.     /**
  119.      * @var string|null
  120.      * @Groups({"read", "list", "write"})
  121.      */
  122.     private $city;
  123.     /**
  124.      * @var float|null
  125.      */
  126.     private $lat;
  127.     /**
  128.      * @var float|null
  129.      */
  130.     private $lng;
  131.     /**
  132.      * @var bool|null
  133.      */
  134.     private $isGeolocated false;
  135.     /**
  136.      * @var string|null
  137.      * @Groups({"read", "list", "write"})
  138.      */
  139.     private $externalId;
  140.     /**
  141.      * @var string|null
  142.      * @Groups({"read", "list", "write"})
  143.      */
  144.     private $mailingId;
  145.     /**
  146.      * @var string|null
  147.      * @Groups({"read", "list"})
  148.      */
  149.     private $logoUrl;
  150.     /**
  151.      * @var int|null
  152.      * @Groups({"read", "list", "write"})
  153.      */
  154.     private $licenseNumber;
  155.     /**
  156.      * @var DateTime|null
  157.      * @Groups({"read", "list", "write"})
  158.      */
  159.     private $buyingAt;
  160.     /**
  161.      * @var UserInfo[]|Collection
  162.      * @Groups({"read", "list"})
  163.      */
  164.     private $users;
  165.     /**
  166.      * @var CustomerFile[]|Collection
  167.      * @Groups({"read", "list"})
  168.      */
  169.     private $customerFiles;
  170.     /**
  171.      * @var string
  172.      * @Groups({"read", "list", "write"})
  173.      */
  174.     private $language LanguageEnum::LANGUAGE_FRENCH;
  175.     /**
  176.      * @var Module[]|Collection
  177.      * @Groups({"customer:write:modules"})
  178.      */
  179.     private $modules;
  180.     /**
  181.      * @var string
  182.      * @Groups({"read", "list", "write"})
  183.      */
  184.     private $alternativeTranslations;
  185.     /**
  186.      * @var string|null
  187.      * @Groups({"read", "list", "write"})
  188.      */
  189.     private $tenantId;
  190.     /**
  191.      * @var string|null
  192.      * @Groups({"read", "list", "write"})
  193.      */
  194.     private $mailingHost;
  195.     /**
  196.      * @var DateTime|null
  197.      * @Groups({"read", "list", "write"})
  198.      */
  199.     private $deletedAt;
  200.     /**
  201.      * @var Collection|OutlookSubscriptionConfiguration[]
  202.      */
  203.     private $outlookSubscriptionConfigurations;
  204.     public function __construct()
  205.     {
  206.         $this->users = new ArrayCollection();
  207.         $this->customerFiles = new ArrayCollection();
  208.         $this->modules = new ArrayCollection();
  209.         $this->outlookSubscriptionConfigurations = new ArrayCollection();
  210.     }
  211.     public function __toString()
  212.     {
  213.         return $this->id;
  214.     }
  215.     /**
  216.      * @param string $moduleRole
  217.      *
  218.      * @return bool
  219.      */
  220.     public function hasCustomerModule(string $moduleRole): bool
  221.     {
  222.         foreach ($this->getModules() as $module) {
  223.             if ($module->getRole() === $moduleRole) {
  224.                 return true;
  225.             }
  226.         }
  227.         return false;
  228.     }
  229.     /**
  230.      * @return string|null
  231.      */
  232.     public function getId(): ?string
  233.     {
  234.         return $this->id;
  235.     }
  236.     /**
  237.      * @param string|null $id
  238.      *
  239.      * @return Customer
  240.      */
  241.     public function setId(?string $id): Customer
  242.     {
  243.         $this->id $id;
  244.         return $this;
  245.     }
  246.     /**
  247.      * @return string|null
  248.      */
  249.     public function getName(): ?string
  250.     {
  251.         return $this->name;
  252.     }
  253.     /**
  254.      * @param string|null $name
  255.      *
  256.      * @return Customer
  257.      */
  258.     public function setName(?string $name): Customer
  259.     {
  260.         $this->name $name;
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return DateTime|null
  265.      */
  266.     public function getExpiredAt(): ?DateTime
  267.     {
  268.         return $this->expiredAt;
  269.     }
  270.     /**
  271.      * @param DateTime|null $expiredAt
  272.      *
  273.      * @return Customer
  274.      */
  275.     public function setExpiredAt(?DateTime $expiredAt): Customer
  276.     {
  277.         $this->expiredAt $expiredAt;
  278.         return $this;
  279.     }
  280.     /**
  281.      * @return bool|null
  282.      */
  283.     public function getIsActive(): ?bool
  284.     {
  285.         return $this->isActive;
  286.     }
  287.     /**
  288.      * @param bool|null $isActive
  289.      *
  290.      * @return Customer
  291.      */
  292.     public function setIsActive(?bool $isActive): Customer
  293.     {
  294.         $this->isActive $isActive;
  295.         return $this;
  296.     }
  297.     /**
  298.      * @return string|null
  299.      */
  300.     public function getPhone(): ?string
  301.     {
  302.         return $this->phone;
  303.     }
  304.     /**
  305.      * @param string|null $phone
  306.      *
  307.      * @return Customer
  308.      */
  309.     public function setPhone(?string $phone): Customer
  310.     {
  311.         $this->phone $phone;
  312.         return $this;
  313.     }
  314.     /**
  315.      * @return string|null
  316.      */
  317.     public function getFax(): ?string
  318.     {
  319.         return $this->fax;
  320.     }
  321.     /**
  322.      * @param string|null $fax
  323.      *
  324.      * @return Customer
  325.      */
  326.     public function setFax(?string $fax): Customer
  327.     {
  328.         $this->fax $fax;
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return string|null
  333.      */
  334.     public function getEmail(): ?string
  335.     {
  336.         return $this->email;
  337.     }
  338.     /**
  339.      * @param string|null $email
  340.      *
  341.      * @return Customer
  342.      */
  343.     public function setEmail(?string $email): Customer
  344.     {
  345.         $this->email $email;
  346.         return $this;
  347.     }
  348.     /**
  349.      * @return string|null
  350.      */
  351.     public function getWebsite(): ?string
  352.     {
  353.         return $this->website;
  354.     }
  355.     /**
  356.      * @param string|null $website
  357.      *
  358.      * @return Customer
  359.      */
  360.     public function setWebsite(?string $website): Customer
  361.     {
  362.         $this->website $website;
  363.         return $this;
  364.     }
  365.     /**
  366.      * @return string|null
  367.      */
  368.     public function getAddress(): ?string
  369.     {
  370.         return $this->address;
  371.     }
  372.     /**
  373.      * @param string|null $address
  374.      *
  375.      * @return Customer
  376.      */
  377.     public function setAddress(?string $address): Customer
  378.     {
  379.         $this->address $address;
  380.         return $this;
  381.     }
  382.     /**
  383.      * @return string|null
  384.      */
  385.     public function getPostalCode(): ?string
  386.     {
  387.         return $this->postalCode;
  388.     }
  389.     /**
  390.      * @param string|null $postalCode
  391.      *
  392.      * @return Customer
  393.      */
  394.     public function setPostalCode(?string $postalCode): Customer
  395.     {
  396.         $this->postalCode $postalCode;
  397.         return $this;
  398.     }
  399.     /**
  400.      * @return string|null
  401.      */
  402.     public function getCity(): ?string
  403.     {
  404.         return $this->city;
  405.     }
  406.     /**
  407.      * @param string|null $city
  408.      *
  409.      * @return Customer
  410.      */
  411.     public function setCity(?string $city): Customer
  412.     {
  413.         $this->city $city;
  414.         return $this;
  415.     }
  416.     /**
  417.      * @return float|null
  418.      */
  419.     public function getLat(): ?float
  420.     {
  421.         return $this->lat;
  422.     }
  423.     /**
  424.      * @param float|null $lat
  425.      *
  426.      * @return Customer
  427.      */
  428.     public function setLat(?float $lat): Customer
  429.     {
  430.         $this->lat $lat;
  431.         return $this;
  432.     }
  433.     /**
  434.      * @return float|null
  435.      */
  436.     public function getLng(): ?float
  437.     {
  438.         return $this->lng;
  439.     }
  440.     /**
  441.      * @param float|null $lng
  442.      *
  443.      * @return Customer
  444.      */
  445.     public function setLng(?float $lng): Customer
  446.     {
  447.         $this->lng $lng;
  448.         return $this;
  449.     }
  450.     /**
  451.      * @return bool|null
  452.      */
  453.     public function getIsGeolocated(): ?bool
  454.     {
  455.         return $this->isGeolocated;
  456.     }
  457.     /**
  458.      * @param bool|null $isGeolocated
  459.      *
  460.      * @return Customer
  461.      */
  462.     public function setIsGeolocated(?bool $isGeolocated): Customer
  463.     {
  464.         $this->isGeolocated $isGeolocated;
  465.         return $this;
  466.     }
  467.     /**
  468.      * @return string|null
  469.      */
  470.     public function getExternalId(): ?string
  471.     {
  472.         return $this->externalId;
  473.     }
  474.     /**
  475.      * @param string|null $externalId
  476.      *
  477.      * @return Customer
  478.      */
  479.     public function setExternalId(?string $externalId): Customer
  480.     {
  481.         $this->externalId $externalId;
  482.         return $this;
  483.     }
  484.     /**
  485.      * @return int|null
  486.      */
  487.     public function getLicenseNumber(): ?int
  488.     {
  489.         return $this->licenseNumber;
  490.     }
  491.     /**
  492.      * @param int|null $licenseNumber
  493.      *
  494.      * @return Customer
  495.      */
  496.     public function setLicenseNumber(?int $licenseNumber): Customer
  497.     {
  498.         $this->licenseNumber $licenseNumber;
  499.         return $this;
  500.     }
  501.     /**
  502.      * @return DateTime|null
  503.      */
  504.     public function getBuyingAt(): ?DateTime
  505.     {
  506.         return $this->buyingAt;
  507.     }
  508.     /**
  509.      * @param DateTime|null $buyingAt
  510.      *
  511.      * @return Customer
  512.      */
  513.     public function setBuyingAt(?DateTime $buyingAt): Customer
  514.     {
  515.         $this->buyingAt $buyingAt;
  516.         return $this;
  517.     }
  518.     /**
  519.      * @return UserInfo[]|Collection
  520.      */
  521.     public function getUsers(): Collection
  522.     {
  523.         return $this->users;
  524.     }
  525.     /**
  526.      * @param Collection $users
  527.      *
  528.      * @return Customer
  529.      */
  530.     public function setUsersFromForm(Collection $users): self
  531.     {
  532.         $this->users $users;
  533.         return $this;
  534.     }
  535.     /**
  536.      * @param UserInfo $userInfo
  537.      *
  538.      * @return $this
  539.      */
  540.     public function addUser(UserInfo $userInfo): self
  541.     {
  542.         if (!$this->users->contains($userInfo)) {
  543.             $userInfo->setCustomer($this);
  544.             $this->users->add($userInfo);
  545.         }
  546.         return $this;
  547.     }
  548.     /**
  549.      * @param UserInfo $userInfo
  550.      *
  551.      * @return $this
  552.      */
  553.     public function removeUser(UserInfo $userInfo): self
  554.     {
  555.         if ($this->users->contains($userInfo)) {
  556.             $userInfo->setCustomer(null);
  557.             $this->users->removeElement($userInfo);
  558.         }
  559.         return $this;
  560.     }
  561.     /**
  562.      * @return int|null
  563.      */
  564.     public function getActiveUsersNumber(): ?int
  565.     {
  566.         return $this->activeUsersNumber;
  567.     }
  568.     /**
  569.      * @param int|null $activeUsersNumber
  570.      *
  571.      * @return Customer
  572.      */
  573.     public function setActiveUsersNumber(?int $activeUsersNumber): Customer
  574.     {
  575.         $this->activeUsersNumber $activeUsersNumber;
  576.         return $this;
  577.     }
  578.     /**
  579.      * @return CustomerFile[]|Collection
  580.      */
  581.     public function getCustomerFiles(): Collection
  582.     {
  583.         return $this->customerFiles;
  584.     }
  585.     /**
  586.      * @param CustomerFile[]|Collection $customerFiles
  587.      *
  588.      * @return Customer
  589.      */
  590.     public function setCustomerFiles($customerFiles): Customer
  591.     {
  592.         $this->customerFiles $customerFiles;
  593.         return $this;
  594.     }
  595.     /**
  596.      * @return string|null
  597.      */
  598.     public function getLogoUrl(): ?string
  599.     {
  600.         return $this->logoUrl;
  601.     }
  602.     /**
  603.      * @param string|null $logoUrl
  604.      *
  605.      * @return Customer
  606.      */
  607.     public function setLogoUrl(?string $logoUrl): Customer
  608.     {
  609.         $this->logoUrl $logoUrl;
  610.         return $this;
  611.     }
  612.     /**
  613.      * @return bool|null
  614.      */
  615.     public function getIsLiveo(): ?bool
  616.     {
  617.         return $this->isLiveo;
  618.     }
  619.     /**
  620.      * @param bool|null $isLiveo
  621.      *
  622.      * @return Customer
  623.      */
  624.     public function setIsLiveo(?bool $isLiveo): Customer
  625.     {
  626.         $this->isLiveo $isLiveo;
  627.         return $this;
  628.     }
  629.     /**
  630.      * @return string|null
  631.      */
  632.     public function getMailingId(): ?string
  633.     {
  634.         return $this->mailingId;
  635.     }
  636.     /**
  637.      * @param string|null $mailingId
  638.      *
  639.      * @return Customer
  640.      */
  641.     public function setMailingId(?string $mailingId): Customer
  642.     {
  643.         $this->mailingId $mailingId;
  644.         return $this;
  645.     }
  646.     /**
  647.      * @return bool|null
  648.      */
  649.     public function getHasIntranet(): ?bool
  650.     {
  651.         return $this->hasIntranet;
  652.     }
  653.     /**
  654.      * @param bool|null $hasIntranet
  655.      *
  656.      * @return Customer
  657.      */
  658.     public function setHasIntranet(?bool $hasIntranet): Customer
  659.     {
  660.         $this->hasIntranet $hasIntranet;
  661.         return $this;
  662.     }
  663.     /**
  664.      * @return string
  665.      */
  666.     public function getLanguage(): string
  667.     {
  668.         return $this->language;
  669.     }
  670.     /**
  671.      * @param string $language
  672.      *
  673.      * @return Customer
  674.      */
  675.     public function setLanguage(string $language): self
  676.     {
  677.         $this->language $language;
  678.         return $this;
  679.     }
  680.     /**
  681.      * @return Module[]|Collection
  682.      */
  683.     public function getModules(): Collection
  684.     {
  685.         return $this->modules;
  686.     }
  687.     /**
  688.      * @param Module[]|Collection $modules
  689.      *
  690.      * @return Customer
  691.      */
  692.     public function setModules(Collection $modules): self
  693.     {
  694.         $this->modules $modules;
  695.         return $this;
  696.     }
  697.     /**
  698.      * @param Module|null $module
  699.      *
  700.      * @return $this
  701.      */
  702.     public function addModule(?Module $module): self
  703.     {
  704.         if ($module && !$this->modules->contains($module)) {
  705.             $this->modules->add($module);
  706.         }
  707.         return $this;
  708.     }
  709.     /**
  710.      * @param Module|null $module
  711.      *
  712.      * @return $this
  713.      */
  714.     public function removeModule(?Module $module): self
  715.     {
  716.         if ($module && $this->modules->contains($module)) {
  717.             $this->modules->removeElement($module);
  718.             return $this;
  719.         }
  720.         if ($module) {
  721.             foreach ($this->getModules() as $customerModule) {
  722.                 if ($customerModule->getRole() === $module->getRole()) {
  723.                     $this->modules->removeElement($customerModule);
  724.                 }
  725.             }
  726.         }
  727.         return $this;
  728.     }
  729.     public function getAlternativeTranslations(): ?string
  730.     {
  731.         return $this->alternativeTranslations;
  732.     }
  733.     public function setAlternativeTranslations(?string $alternativeTranslations): Customer
  734.     {
  735.         $this->alternativeTranslations $alternativeTranslations;
  736.         return $this;
  737.     }
  738.     /**
  739.      * @return string|null
  740.      */
  741.     public function getTenantId(): ?string
  742.     {
  743.         return $this->tenantId;
  744.     }
  745.     /**
  746.      * @param string|null $tenantId
  747.      *
  748.      * @return Customer
  749.      */
  750.     public function setTenantId(?string $tenantId): self
  751.     {
  752.         $this->tenantId $tenantId;
  753.         return $this;
  754.     }
  755.     /**
  756.      * @return Collection|OutlookSubscriptionConfiguration[]
  757.      */
  758.     public function getOutlookSubscriptionConfigurations(): Collection
  759.     {
  760.         return $this->outlookSubscriptionConfigurations;
  761.     }
  762.     /**
  763.      * @param OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration
  764.      *
  765.      * @return $this
  766.      */
  767.     public function addOutlookSubscriptionConfiguration(OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration): self
  768.     {
  769.         if (!$this->outlookSubscriptionConfigurations->contains($outlookSubscriptionConfiguration)) {
  770.             $this->outlookSubscriptionConfigurations[] = $outlookSubscriptionConfiguration;
  771.             $outlookSubscriptionConfiguration->setCustomer($this);
  772.         }
  773.         return $this;
  774.     }
  775.     /**
  776.      * @param OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration
  777.      *
  778.      * @return Customer
  779.      */
  780.     public function removeOutlookSubscriptionConfiguration(OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration): self
  781.     {
  782.         if ($this->outlookSubscriptionConfigurations->contains($outlookSubscriptionConfiguration)) {
  783.             $this->outlookSubscriptionConfigurations->removeElement($outlookSubscriptionConfiguration);
  784.         }
  785.         return $this;
  786.     }
  787.     /**
  788.      * @param Collection $outlookSubscriptionConfigurations
  789.      *
  790.      * @return Customer
  791.      */
  792.     public function setOutlookSubscriptionConfigurations(Collection $outlookSubscriptionConfigurations): Customer
  793.     {
  794.         $this->outlookSubscriptionConfigurations $outlookSubscriptionConfigurations;
  795.         return $this;
  796.     }
  797.     public function getMailingHost(): ?string
  798.     {
  799.         return $this->mailingHost;
  800.     }
  801.     public function setMailingHost(?string $mailingHost): self
  802.     {
  803.         $this->mailingHost $mailingHost;
  804.         return $this;
  805.     }
  806.     public function getDeletedAt(): ?DateTime
  807.     {
  808.         return $this->deletedAt;
  809.     }
  810.     public function setDeletedAt(?DateTime $deletedAt): self
  811.     {
  812.         $this->deletedAt $deletedAt;
  813.         return $this;
  814.     }
  815. }