sendLocationRequest method

Future<Request> sendLocationRequest(
  1. String phoneNumber,
  2. String text
)

Implementation

Future<Request> sendLocationRequest(String phoneNumber, String text) async {
  final Map<String, String> headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer $accessToken',
  };

  final Map<String, dynamic> body = {
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "type": "interactive",
    "to": phoneNumber,
    "interactive": {
      "type": "location_request_message",
      "body": {"text": text},
      "action": {"name": "send_location"}
    }
  };

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