#!/usr/bin/env bash
# send_otp_curl.sh — Gửi OTP
# Usage: bash send_otp_curl.sh
set -eu

ENDPOINT="http://10.38.31.92:8004/api/v1/otp/send"
PARTNER_ID="3ED2E2550C574D4FE0636B1F260A1EAA"
ISDN_ENC="QKfsfcoXvWqw6P2P5jZozg=="
SMS_CLIENT_ID="265"
OTP_CONTENT="[PACK360] Ma OTP cua ban la #OTP_CODE#"

CLIENT_REQ_ID="$(date +%Y%m%d)_pack360_sendotp_$(date +%s)"

echo "[$(date +'%F %T')] >>> POST ${ENDPOINT} | clientReqId=${CLIENT_REQ_ID}"
curl -v --max-time 30 --connect-timeout 5 --noproxy '*' \
    --location "${ENDPOINT}" \
    --header "Partner-Id: ${PARTNER_ID}" \
    --header "Content-Type: application/json" \
    --data "{
    \"isdn\": \"${ISDN_ENC}\",
    \"clientReqId\": \"${CLIENT_REQ_ID}\",
    \"smsClientId \": ${SMS_CLIENT_ID},
    \"otpContent\": \"${OTP_CONTENT}\"
}"
echo "[$(date +'%F %T')] curl exit=$?"
