Trigger loss data sendind/saving outside of the widget

Testing guidelines: Adding external button for testing embedding widget submit functionality

An insurance company (IC) can embed self service widget on its web site.

Widget is self-sufficient application. But in some cases ICs may want to hide widget submit buttons (send and save) and handle it in its own way.

In this case there is a functionality to send/save loss data outside of the widget on the page.

For such a scenario there are two functions:

function ScalepointSelfService.widget.submit([successCallback, errorCallback])
function ScalepointSelfService.widget.save([successCallback, errorCallback])

In case of IC needs to handle submit success or failure event successCallback and errorCallback functions are passed as arguments (but are not required).

 function sucessCallback([lossData])

 function errorCallback([errorData])

LossData is a data submitted by the widget, Please refer to the JSON Schema for the JSON schema ErrorData is a data with response status and text. Please refer to the JSON Schema

Code sample

function successCallback(lossData){
    $.ajax({
        type: "POST",
        url: 'https://insurance-company.com/rest-api-for-posting-loss-data',
        data: lossData
        success: function(){
            alert('success')
        }
    });
}


function errorCallback(errorData){
    console.log(errorData.status + ' - ' + errorData.statusText)
}

function submit(){
    ScalepointSelfService.widget.submit(successCallback, errorCallback)
}