<?php
declare(strict_types=1);
define('ACC_BASE_PATH', __DIR__);
require __DIR__ . '/standalone/bootstrap.php';
require_once ACC_PATH . 'includes/helpers/arag-shop.php';
require_once ACC_PATH . 'includes/helpers/acc-sms.php';
require_once ACC_PATH . 'includes/helpers/arag-shop-ai.php';
require_once ACC_PATH . 'includes/helpers/sr-zarinpal.php';

$base = 'http://localhost/acc-engine/api.php/acc/v1';

$ch = curl_init("$base/public/arag/ai/status");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$status = json_decode(curl_exec($ch), true);
curl_close($ch);

$ch = curl_init("$base/public/arag/ai/chat");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'message' => 'گلاب برای شربت چی پیشنهاد می‌کنید؟',
        'session_id' => 'test_' . time(),
    ]),
]);
$chat = json_decode(curl_exec($ch), true);
curl_close($ch);

$sms = Acc_SMS::send_otp('09120000000', '123456');

echo json_encode([
    'ai_status' => $status,
    'ai_chat'   => $chat,
    'sms_test'  => $sms,
    'zarinpal'  => [
        'sandbox'  => SR_Zarinpal::is_sandbox(),
        'merchant' => SR_Zarinpal::merchant(),
    ],
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
