send method
Future<Iterable<Response> >
send(
- Iterable<
PhoneNumber> to, - Message message,
- Client client
override
Convert a list of phone numbers and a message to a list of requests
Implementation
@override
Future<Iterable<Response>> send(
Iterable<PhoneNumber> to, Message message, http.Client client) async {
final requests = await groupRequests(to, message);
final responses = requests.map<Future<Iterable<Response>>>((e) async {
final streamedResponse = await client.send(e.key);
final httpResponse = await http.Response.fromStream(streamedResponse);
return e.value.map(
(to) => Response(
gateway: this,
to: to,
success: httpResponse.body == '0',
response: httpResponse,
),
);
});
final results = await Future.wait(responses);
return results.expand((e) => e);
}