deleteInvoice method
This operation deletes the invoice object specified in the request body. Include a minimum of Invoice.Id and Invoice.SyncToken in the request body. You must unlink any linked transactions associated with the invoice object before deleting it.
Implementation
Future<DeleteResponse> deleteInvoice({
required Invoice invoice,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json',
};
Map<String, String> params = {
"minorversion": minorVersion.toString(),
"operation": "delete"
};
Uri endpoint = Uri.https(
baseUrl, "/v3/company/$realmId/invoice", params);
//print (endpoint.toString());
var response = await
http.post(endpoint, body: jsonEncode(invoice.toJson()), headers: headers);
if (response.statusCode == 200) {
//print (jsonDecode(response.body));
return DeleteResponse.fromJson(jsonDecode(response.body)["Invoice"]);
}
else {
throw InvoiceException(statusCode: response.statusCode, message: response.body);
}
}