<?php

namespace PloverCRM\Core\Api\V1;

use PloverCRM\Core\Api\AbstractEndpoint;
use WP_REST_Request;

/**
 * Info Endpoint
 * 
 * GET /wp-json/plover-crm/v1/info
 */
class InfoEndpoint extends AbstractEndpoint
{
    public function getRoute(): string
    {
        return '/info';
    }

    public function getMethod()
    {
        return 'GET';
    }

    public function handle(WP_REST_Request $request)
    {
        $crm = $this->container->get('crm');

        return $this->success([
            'crm_name' => $crm->getName(),
            'crm_available' => $crm->isAvailable(),
            'api_version' => 'v1',
            'namespace' => 'plover-crm/v1',
        ]);
    }


}
