<?php
/**
 * app/controllers/api/users.php
 *
 * This is the users' api controller.
 *
 * @version 3.0
 * @author  Joey Kimsey <Joey@thetempusproject.com>
 * @link    https://TheTempusProject.com
 * @license https://opensource.org/licenses/MIT [MIT LICENSE]
 */
namespace TheTempusProject\Controllers\Api;

use TheTempusProject\Models\User;
use TheTempusProject\Classes\ApiController;
use TheTempusProject\Houdini\Classes\Views;

class Users extends ApiController {
    public static $user;

    public function __construct() {
        parent::__construct();
        self::$user = new User;
    }

    public function find( $id = null ) {
        $user = self::$user->get( $id );
        if ( ! $user ) {
            $responseType = 'error';
            $response = 'No user found.';
        } else {
            $responseType = 'data';
            $response = $user->ID;
        }
        Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]);
    }
}