groupRequests method
Future<Iterable<MapEntry<Request, Iterable<PhoneNumber> > > >
groupRequests(
- Iterable<
PhoneNumber> to, - Message message
Groups requests.
Group Chinese Mainland and international mobile phone numbers.
Implementation
Future<Iterable<MapEntry<http.Request, Iterable<PhoneNumber>>>> groupRequests(
Iterable<PhoneNumber> to, Message message) async {
final groups = <bool, Set<PhoneNumber>>{
true: to.where((phone) => isChineseMainland(phone)).toSet(),
false: to.where((phone) => !isChineseMainland(phone)).toSet(),
};
final resutls = groups.entries.map((e) async {
final url = await generateRequestUrl(e.value, message, e.key);
final request = http.Request('GET', url);
return MapEntry(request, e.value);
});
return Future.wait(resutls);
}