<?php

namespace Notimatica\ApiExceptions;

use Exception;

class TooManyRequestsApiException extends ApiException
{
    /**
     * @param int|null $retryAfter
     * @param array $headers
     * @param string $message
     * @param Exception $previous
     */
    public function __construct($retryAfter = null, $headers = [],  $message = '', Exception $previous = null)
    {
        if (empty($message)) {
            $message = 'Rate limit exceed.';
        }

        if ($retryAfter) {
            $headers['Retry-After'] = $retryAfter;
        }

        parent::__construct(429, 'too_many_requests', $message, $previous, $headers);
    }
}

<?php

namespace Notimatica\ApiExceptions;

use Exception;

class TooManyRequestsApiException extends ApiException
{
    /**
     * @var int|null
     */
    protected $retryAfter = null;

    /**
     * @param int|null $retryAfter
     * @param array $headers
     * @param string $message
     * @param Exception $previous
     */
    public function __construct($retryAfter = null, $headers = [],  $message = '', Exception $previous = null)
    {
        $this->retryAfter = $retryAfter;

        if (empty($message)) {
            $message = 'Rate limit exceed.';
        }

        if ($retryAfter) {
            $headers['Retry-After'] = $retryAfter;
        }

        parent::__construct(429, 'too_many_requests', $message, $previous, $headers);
    }

    /**
     * Add extra info to the output.
     *
     * @return mixed
     */
    public function getMeta()
    {
        if ($this->retryAfter) {
            return [
                'retry_after' => $this->retryAfter
            ];
        }
    }
}

Add retry_after to meta of too many requests exception
Add retry_after to meta of too many requests exception
