<?php
/**
 * @package   Essentials YOOtheme Pro 2.2.16 build 0813.1608
 * @author    ZOOlanders https://www.zoolanders.com
 * @copyright Copyright (C) Joolanders, SL
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

namespace ZOOlanders\YOOessentials\Auth\Driver\Airtable;

use YOOtheme\Http\Request;
use YOOtheme\Http\Response;

class AirtableAuthDriverController
{
    public const PRESAVE_TOKEN_ENDPOINT = 'yooessentials/auth/airtable/token';

    public function presaveToken(Request $request, Response $response)
    {
        $form = $request->getParam('form');
        $auth = $request->getParam('auth');

        $token = $auth['accessToken'] ?? $form['accessToken'] ?? null;

        if (!$token) {
            return $response->withJson('The Access Token is required.', 400);
        }

        return $response->withJson(200);
    }
}
