sendAudioById method

Future<Request> sendAudioById(
  1. String phoneNumber,
  2. String mediaId
)

Implementation

Future<Request> sendAudioById(String phoneNumber, String mediaId) 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": "audio",
    "audio": {"id": mediaId}
  };

  await request.post('$fromNumberId/messages', headers, body);
  return request;
}