# shellcheck shell=dash disable=SC2034,SC2154
# https://developer.godaddy.com/doc/endpoint/domains#/v1/recordDeleteTypeName
___x_cmd_gddy_domain_record_rm(){
    local X_help_cmd='x help -m gddy domain record rm';    help:arg:parse
    param:scope     ___x_cmd_gddy
    param:dsl    '
options:
    #1             "Domain whose DNS Records are to be deleted"                    <>
    --shopper_id   "Shopper ID which owns the domain"                              <>=""
    --type         "DNS Record Type for which DNS Records are to be deleted"       <>=""    = A AAAA CNAME MX NS SOA SRV TXT
    --name         "DNS Record Name for which DNS Records are to be deleted"       <>

    --yes          "Ignore remove prompt interception"
    --json|-j      "output raw JSON data"
'
    param:run
    gddy:arg:format:raw:json2app:all

    [ "$yes" = "true" ] || ___x_cmd_ui_yesno "Are you sure to delete dns record for the specified [domain=$(___x_cmd_ui bold red "$name")] ?" \
                        || return

    if [ -z "$type" ]; then
        if x is ip "$data"; then
            gddy:info "$data is recognized as IPv4 address, record type set to A"
            type=A
        else
            gddy:info "$data is not an IP Address; record type set to CNAME"
            type=CNAME
        fi
    fi

    local ___X_CMD_GDDY_RECORD_REQUEST=1
    if  ___x_cmd_gddy_domain_record_rm___raw "$@" ; then
        ___x_cmd_ui_tf true "[Success]: Domain delete Dns successful"
    else
        ___x_cmd_ui_tf false "Domain delete Dns failure"
        return 1
    fi

}

___x_cmd_gddy_domain_record_rm___raw(){
    ___x_cmd_gddy_ourl del "/v1/domains/$1/records/${type}/${name}"
}
