postSpaMessage method
Send spa massage to server.
Implementation
@override
Future<Map<String, dynamic>> postSpaMessage(EventSpa event) async {
if(event.uriSand == null) throw Exception('Error uriSand not null.');
try {
print(event.toJson);
Response<dynamic> response = await _dio.post(
event.uriSand!,
data: [event.toJson],
options: Options(
headers: {
'Content-Type': 'application/json',
},
),
);
print(response.data);
if (response.statusCode == 200) {
return response.data;
} else {
throw Exception('Error while sending the message.');
}
} catch (_) {
throw Exception('Error while sending the message.');
}
}