| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Data\Pagarme\Response\PagarmeCustomerResponseData;
- use App\Data\Pagarme\Response\PagarmeCustomerResponseData\PagarmeCustomerPhonesResponseData\PagarmeCustomerPhonesResponseData;
- final readonly class PagarmeCustomerResponseData
- {
- public function __construct(
- public ?string $id,
- public ?string $name,
- public ?string $email,
- public ?string $code,
- public ?string $document,
- public ?string $documentType,
- public ?string $type,
- public ?bool $delinquent,
- public ?PagarmeCustomerAddressResponseData $address,
- public PagarmeCustomerPhonesResponseData $phones,
- public ?string $createdAt = null,
- public ?string $updatedAt = null,
- ) {}
- public function id(): ?string
- {
- return $this->id;
- }
- public function requireId(): string
- {
- if (! $this->id) {
- throw new \RuntimeException('Customer creation returned an empty id.');
- }
- return $this->id;
- }
- public function toArray(): array
- {
- return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'email' => $this->email,
- 'code' => $this->code,
- 'document' => $this->document,
- 'document_type' => $this->documentType,
- 'type' => $this->type,
- 'delinquent' => $this->delinquent,
- 'address' => $this->address?->toArray(),
- 'phones' => $this->phones->toArray(),
- 'created_at' => $this->createdAt,
- 'updated_at' => $this->updatedAt,
- ];
- }
- }
|