<?php
namespace Fifa\ConnectId\Sdk\ExceptionHandler\Handler;

use Fifa\ConnectId\Sdk\Api\ApiException;
use Fifa\ConnectId\Sdk\Exception\FifaEntityDeletedException;
use Fifa\ConnectId\Sdk\Exception\FifaEntityNotFoundException;

/**
 * Class FifaEntityDeletedHandler
 * @package Fifa\ConnectId\Sdk\ExceptionHandler\Handler
 */
class FifaEntityDeletedHandler implements HandlerInterface
{
    /**
     * Handler method for FifaEntityDeletedException
     *
     * @param ApiException $e
     * @return FifaEntityDeletedException|null
     */
    public function handle(ApiException $e): ?FifaEntityDeletedException
    {
        if ($e->getCode() == 410) {
            return new FifaEntityDeletedException($e, is_string($e->getResponseBody()) ? $e->getResponseBody() : $e->getMessage());
        }

        return null;
    }
}