<?php

namespace PortalPeople\virtualstock\exceptions;

class RateLimitException extends ApiException
{
    private ?string $retryAfter;

    public function __construct(
        string $message = 'VirtualStock API rate limit exceeded (60 req/min)',
        ?string $retryAfter = null,
        string $responseBody = '',
        ?\Throwable $previous = null
    ) {
        $this->retryAfter = $retryAfter;
        parent::__construct($message, 429, $responseBody, $previous);
    }

    /**
     * Returns the ISO 8601 datetime string indicating when the next request can be made,
     * as provided by the VirtualStock API, or null if not available.
     */
    public function getRetryAfter(): ?string
    {
        return $this->retryAfter;
    }
}
