sendInvoice method
The Invoice.EmailStatus parameter is set to EmailSent. The Invoice.DeliveryInfo element is populated with sending information<./li> The Invoice.BillEmail.Address parameter is updated to the address specified with the value of the sendTo query parameter, if specified.
Implementation
Future<Invoice> sendInvoice({
required String invoiceId,
required String emailTo,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/octet-stream',
'Accept': 'application/json',
};
Map<String, String> params = {
"minorversion": minorVersion.toString(),
"sendTo": emailTo
};
Uri endpoint = Uri.https(
baseUrl, "/v3/company/$realmId/invoice/$invoiceId/send", params);
//print (endpoint.toString());
var response = await
http.post(endpoint, headers: headers);
if (response.statusCode == 200) {
//print (jsonDecode(response.body));
return Invoice.fromJson(jsonDecode(response.body)["Invoice"]);
}
else {
throw InvoiceException(statusCode: response.statusCode, message: response.body);
}
}