import axios from 'axios';

interface OTPEntity {
    code: string;
}

interface SendSmsOptions {
    apiKey: string;
    receptor: string;
    token: any;
    template: string; // حالا template اجباریه
}

export async function sendSms({ apiKey, receptor, token, template }: SendSmsOptions) {
    const url = `https://api.kavenegar.com/v1/${apiKey}/verify/lookup.json`;

    try {
        const response = await axios.get(url, {
            params: {
                receptor,
                token: token.code,
                template
            }
        });

        console.log('پیامک با موفقیت ارسال شد:', response.data);
        return response.data;
    } catch (error) {
        console.error('خطا در ارسال پیامک:', error);
        throw error;
    }
}
