sendLocation method
Implementation
Future<Request> sendLocation(String phoneNumber, double latitude,
double longitude, String? name, String? address) 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": "location",
"location": {
"latitude": latitude.toString(),
"longitude": longitude.toString(),
}
};
if (name != null) {
body["location"]["name"] = name;
}
if (address != null) {
body["location"]["address"] = address;
}
await request.post('$fromNumberId/messages', headers, body);
return request;
}