<?php

namespace App\Modules\Xero\Exceptions;

use Exception;

class XeroApiException extends Exception
{
    protected $statusCode;
    protected $responseBody;
    protected $endpoint;

    public function __construct($message, $statusCode = null, $responseBody = null, $endpoint = null, $previous = null)
    {
        parent::__construct($message, 0, $previous);
        
        $this->statusCode = $statusCode;
        $this->responseBody = $responseBody;
        $this->endpoint = $endpoint;
    }

    public function getStatusCode()
    {
        return $this->statusCode;
    }

    public function getResponseBody()
    {
        return $this->responseBody;
    }

    public function getEndpoint()
    {
        return $this->endpoint;
    }

    public function isValidationError()
    {
        return $this->statusCode === 400;
    }

    public function isAuthenticationError()
    {
        return $this->statusCode === 401;
    }

    public function isNotFoundError()
    {
        return $this->statusCode === 404;
    }

    public function isRateLimitError()
    {
        return $this->statusCode === 429;
    }
} 