PagarmeCustomerUpdateRequestData.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Data\Pagarme\Request\PagarmeCustomerRequestData;
  3. use App\Data\Pagarme\PagarmeData;
  4. final readonly class PagarmeCustomerUpdateRequestData extends PagarmeData
  5. {
  6. public function __construct(
  7. public ?string $name = null,
  8. public ?string $email = null,
  9. public ?string $document = null,
  10. public ?string $type = null,
  11. public ?string $documentType = null,
  12. public ?string $code = null,
  13. public ?PagarmeCustomerAddressRequestData $address = null,
  14. public ?PagarmeCustomerPhonesRequestData $phones = null,
  15. ) {
  16. if ($this->type !== null) {
  17. self::requireIn($this->type, ['individual', 'company'], 'type');
  18. }
  19. if ($this->documentType !== null) {
  20. self::requireIn($this->documentType, ['CPF', 'CNPJ'], 'document_type');
  21. }
  22. }
  23. public function toArray(): array
  24. {
  25. return $this->filterFilledRecursive([
  26. 'name' => $this->name,
  27. 'email' => $this->email,
  28. 'document' => $this->document,
  29. 'type' => $this->type,
  30. 'document_type' => $this->documentType,
  31. 'code' => $this->code,
  32. 'address' => $this->address,
  33. 'phones' => $this->phones,
  34. ]);
  35. }
  36. }