<?php

namespace AuthStack\Driver\AUDGeneric\App\REST;

use Exception;

class AUDModel extends BaseRESTModel
{
    protected $driverName = 'AUD Generic Driver';

    /**
     * @param array $data
     * @param callable|null $after
     * @return mixed
     * @throws Exception
     */
    public function getAuthentication(array $data, ?callable $after = null)
    {
        $authenticate = $this->remote(function () use ($data): array {
            return $this->json('authenticate', $data);

        }, Exception::class, $after);

        return $authenticate;
    }

    /**
     * @param int $id
     * @param callable|null $after
     * @return mixed
     * @throws Exception
     */
    public function getUserByPrimaryKey(int $id, ?callable $after = null)
    {
        $authenticate = $this->remote(function () use ($id): array {
            return $this->json('get_account', null, [$id]);

        }, Exception::class, $after);

        return $authenticate;
    }
}
