# shellcheck shell=dash


___x_cmd_hub_qrcode(){
    # FIXME: if no utf8 support, use this: ANSI256
    hub:debug "QR Code url: $1"
    ___x_cmd qr run -s 1 -m 0 -t ANSIUTF8i "$1"
}

___x_cmd_hub_wechat_url(){
    local ticket="$1" ;  [ -n "$ticket" ] || M='Provide ticket' N=hub log:ret:64
    local redirect_uri="${___X_CMD_HUB_SERVICE_URL}/api/v0/account/login?type=wechat&method=qr&region=${___X_CMD_HUB_LOGIN_REGION}&ticket=${ticket}"
    redirect_uri="$(___x_cmd url encode "$redirect_uri")"

    local url_prefix="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb61f18afcafa4044&redirect_uri=${redirect_uri}"
    printf "%s" "${url_prefix}&response_type=code&scope=snsapi_userinfo&state=${ticket}"
}
