<?php
if (!defined('ABSPATH'))
    exit;

class Dori_Chatbot_Kavenegar_Client
{
    public static function send_verification_sms($receptor, $token, $template = 'verify')
    {
        $api_key = Dori_Chatbot_API_Constants::get_kavenegar_api_key();
        if (empty($api_key)) {
            throw new Exception('Kavenegar API key is not configured');
        }

        $url = "https://api.kavenegar.com/v1/{$api_key}/verify/lookup.json";
        $body = array(
            'receptor' => $receptor,
            'token'    => $token,
            'template' => $template,
            'type'     => 'sms',
        );

        $response = wp_remote_post($url, array(
            'body'    => $body,
            'timeout' => Dori_Chatbot_API_Client::get_timeout_long(),
        ));

        return Dori_Chatbot_API_Client::handle_api_response($response, 'Kavenegar: Send Verification SMS failed');
    }
}
