id; } public function requireId(): string { if (! $this->id) { throw new \RuntimeException('Customer creation returned an empty id.'); } return $this->id; } public static function fromArray(array $payload): self { return new self( id: $payload['id'] ?? null, name: $payload['name'] ?? null, email: $payload['email'] ?? null, code: $payload['code'] ?? null, document: $payload['document'] ?? null, documentType: $payload['document_type'] ?? null, type: $payload['type'] ?? null, delinquent: $payload['delinquent'] ?? null, address: PagarmeCustomerAddressResponseData::fromArray($payload['address'] ?? null), phones: PagarmeCustomerPhonesResponseData::fromArray($payload['phones'] ?? null), createdAt: $payload['created_at'] ?? null, updatedAt: $payload['updated_at'] ?? null, ); } 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, ]; } }