| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Data\Pagarme\Response\PagarmeRecipientResponseData;
- readonly class PagarmeRecipientResponseData
- {
- public function __construct(
- public ?string $id,
- public ?string $name,
- public ?string $email,
- public ?string $document,
- public ?string $type,
- public ?string $status,
- public ?PagarmeRecipientBankAccountResponseData $defaultBankAccount = null,
- public ?string $createdAt = null,
- public ?string $updatedAt = null,
- ) {}
- public static function fromArray(array $payload): self
- {
- return new self(
- id: $payload['id'] ?? null,
- name: $payload['name'] ?? null,
- email: $payload['email'] ?? null,
- document: $payload['document'] ?? null,
- type: $payload['type'] ?? null,
- status: $payload['status'] ?? null,
- defaultBankAccount: ! empty($payload['default_bank_account'])
- ? PagarmeRecipientBankAccountResponseData::fromArray($payload['default_bank_account'])
- : null,
- createdAt: $payload['created_at'] ?? null,
- updatedAt: $payload['updated_at'] ?? null,
- );
- }
- public function id(): ?string
- {
- return $this->id;
- }
- public function defaultBankAccount(): ?PagarmeRecipientBankAccountResponseData
- {
- return $this->defaultBankAccount;
- }
- public function toArray(): array
- {
- return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'email' => $this->email,
- 'document' => $this->document,
- 'type' => $this->type,
- 'status' => $this->status,
- 'default_bank_account' => $this->defaultBankAccount?->toArray(),
- 'created_at' => $this->createdAt,
- 'updated_at' => $this->updatedAt,
- ];
- }
- }
|