| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Data\Pagarme\Response\PagarmeOrderResponseData;
- use App\Data\Pagarme\PagarmeResponseData;
- final readonly class PagarmeOrderItemResponseData extends PagarmeResponseData
- {
- public function __construct(
- public ?string $id,
- public ?string $code,
- public ?int $amount,
- public ?int $quantity,
- public ?string $description,
- public ?string $status,
- ) {}
- public static function fromArray(array $payload): static
- {
- return new self(
- id: static::arrString($payload, 'id'),
- code: static::arrString($payload, 'code'),
- amount: static::arrInt($payload, 'amount'),
- quantity: static::arrInt($payload, 'quantity'),
- description: static::arrString($payload, 'description'),
- status: static::arrString($payload, 'status'),
- );
- }
- public function toArray(): array
- {
- return [
- 'id' => $this->id,
- 'code' => $this->code,
- 'amount' => $this->amount,
- 'quantity' => $this->quantity,
- 'description' => $this->description,
- 'status' => $this->status,
- ];
- }
- }
|