<?php

namespace HelpGent\App\Http\Controllers;

defined( "ABSPATH" ) || exit;

use HelpGent\App\Http\Controllers\Controller;
use HelpGent\WpMVC\Routing\Response;
use HelpGent\WpMVC\RequestValidator\Validator;
use WP_REST_Request;

use HelpGent\App\Repositories\AgentRepository;

class AgentController extends Controller {
    public AgentRepository $repository;

    public function __construct( AgentRepository $repository ) {
        $this->repository = $repository;
    }

    /**
     * Display a listing of the resource.
     *
     * @param Validator $validator Instance of the Validator.
     * @param WP_REST_Request $request The REST request instance.
     * @return array
     */
    public function index( Validator $validator, WP_REST_Request $request ): array {
        return Response::send(
            [
                "items" => $this->repository->get()
            ]
        );
    }
}