function optOut()

in website-creator/js/voiceid.js [138:161]


function optOut() {
    $('#voice-id-prompt').text('Please wait while we opt-out the customer...');
    if (typeof agent === "undefined") {
        agent = new connect.Agent();
    }
    let agentConn = agent.getContacts()[0].getConnections()[0];
    $('#loading-image').css('display', 'inline-block');
    agentConn.optOutVoiceIdSpeaker()
        .then((response) => {
            $('#voice-id-prompt').text(response.Speaker.Status);
            $('#loading-image').css('display', 'none');
            if (response.Speaker.Status === 'OPTED_OUT') {
                $('#register-voice-id').prop('disabled', true).css('opacity', 0.5).css('cursor', 'default');
                $('#evaluate-voice-id').prop('disabled', true).css('opacity', 0.5).css('cursor', 'default');
                $('#opt-out').prop('disabled', true).css('opacity', 0.5).css('cursor', 'default');
                $('#voice-id-prompt').text('OPTED OUT!');
            }
        })
        .catch((error) => {
            console.log(error);
            $('#voice-id-prompt').text('optOutVoiceIdSpeaker failed');
            $('#loading-image').css('display', 'none');
        });
}