send method
Implementation
@override
Future<void> send(String recipient, DVNotificationMessage message) async {
if (recipient.trim().isEmpty) {
throw ArgumentError.value(
recipient,
'recipient',
'An SMS needs a destination number.',
);
}
final credentials = base64Encode(utf8.encode('$accountSid:$authToken'));
final response = await transport(DVHttpRequest(
url: baseUrl.replace(
path: '/2010-04-01/Accounts/$accountSid/Messages.json',
),
headers: <String, String>{
'content-type': 'application/x-www-form-urlencoded',
'accept': 'application/json',
'authorization': 'Basic $credentials',
},
body: dvEncodeFormBody(<(String, String)>[
('To', recipient.trim()),
if (fromNumber case final from?) ('From', from),
if (messagingServiceSid case final service?)
('MessagingServiceSid', service),
('Body', smsBody(message)),
]),
));
if (!response.isSuccess) {
throw DVPushProviderException(
'twilio',
_describe(response.body),
statusCode: response.statusCode,
responseBody: response.body,
);
}
}