sendDocumentById method
Implementation
Future<Request> sendDocumentById(String phoneNumber, String mediaId,
String? caption, String? fileName) async {
final Map<String, String> headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer $accessToken',
};
final Map<String, dynamic> body = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": phoneNumber,
"type": "document",
"document": {"id": mediaId}
};
if (caption != null) {
body['document']['caption'] = caption;
}
if (fileName != null) {
body['document']['filename'] = fileName;
}
await request.post('$fromNumberId/messages', headers, body);
return request;
}