src/DTO/LicenciasOnline/CreateEndCustomerRequestDTO.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\DTO\LicenciasOnline;
  3. final class CreateEndCustomerRequestDTO
  4. {
  5.     private ?int $id// debe ir null para "nuevo"
  6.     private ?string $fictitiousName;
  7.     private string $name;
  8.     private ?string $taxId;
  9.     private ?string $phoneNumber;
  10.     private ?string $grossIncome;
  11.     private string $type;
  12.     private int $countryId;
  13.     private ?int $addressId// null para nueva address
  14.     private string $street;
  15.     private int $provincePvsId;
  16.     
  17.     private string $addressPhoneNumber;
  18.     private string $city;
  19.     private string $postalCode;
  20.     public function __construct(
  21.         ?int $id null,
  22.         ?string $fictitiousName,
  23.         string $name,
  24.         ?string $taxId,
  25.         ?string $phoneNumber,
  26.         int $countryId,
  27.         ?string $grossIncome null,
  28.         array $address = []
  29.     ) {
  30.         $this->id $id;
  31.         $this->fictitiousName $fictitiousName;
  32.         $this->name $name;
  33.         $this->taxId $taxId;
  34.         $this->phoneNumber $phoneNumber;
  35.         $this->grossIncome $grossIncome;
  36.         $this->countryId $countryId;
  37.         $this->address $address;
  38.         $this->addressId null;
  39.         $this->type 'EndCustomer';
  40.         $this->provincePvsId 1;
  41.     }
  42.     public function toArray(): array
  43.     {
  44.         return [
  45.             'id'             => $this->id,
  46.             'fictitiousName' => $this->fictitiousName,
  47.             'name'           => $this->name,
  48.             'taxId'          => $this->taxId,
  49.             'phoneNumber'    => $this->phoneNumber,
  50.             'grossIncome'    => $this->grossIncome,
  51.             'Type'           => $this->type,
  52.             'countryId'      => $this->countryId,
  53.             'address' => [
  54.                 'id'          => $this->addressId,
  55.                 'street'      => $this->address['street'],
  56.                 'phoneNumber' => $this->address['phoneNumber'],
  57.                 'city'        => $this->address['city'],
  58.                 'PostalCode'  => $this->address['postalCode'],
  59.                 'Province'    => [
  60.                     'pvsId' => $this->address['provincePvsId'],
  61.                 ],
  62.             ],
  63.         ];
  64.     }
  65. }