| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Data\Pagarme\Recipient\Parts\Request;
- use App\Data\Pagarme\PagarmeData;
- final readonly class AutomaticAnticipationSettingsData extends PagarmeData
- {
- public function __construct(
- public bool $enabled,
- public ?string $type = null,
- public ?int $volumePercentage = null,
- public ?int $delay = null,
- public ?array $days = null,
- ) {
- if ($this->type !== null) {
- self::requireIn($this->type, ['full', '1025'], 'automatic_anticipation_settings.type');
- }
- if ($this->volumePercentage !== null && ($this->volumePercentage < 0 || $this->volumePercentage > 100)) {
- throw new \InvalidArgumentException('automatic_anticipation_settings.volume_percentage deve estar entre 0 e 100.');
- }
- if ($this->delay !== null && $this->delay < 0) {
- throw new \InvalidArgumentException('automatic_anticipation_settings.delay deve ser maior ou igual a zero.');
- }
- }
- public function toArray(): array
- {
- return $this->filterFilledRecursive([
- 'enabled' => $this->enabled,
- 'type' => $this->type,
- 'volume_percentage' => $this->volumePercentage,
- 'delay' => $this->delay,
- 'days' => $this->days,
- ]);
- }
- }
|