send method
Future<XmlElement>
send(
- Map<String, dynamic> data, {
- required String method,
- required String requestUri,
- required Map<String, AwsExceptionFn> exceptionFnMap,
- bool signed = true,
- Shape? shape,
- required Map<String, Shape> shapes,
- required String version,
- required String action,
- String? resultWrapper,
})
Implementation
Future<XmlElement> send(
Map<String, dynamic> data, {
required String method,
required String requestUri,
required Map<String, AwsExceptionFn> exceptionFnMap,
bool signed = true,
Shape? shape,
required Map<String, Shape> shapes,
required String version,
required String action,
String? resultWrapper,
}) async {
final rq = await _buildRequest(
data,
method,
requestUri,
signed,
shape,
shapes,
version,
action,
);
final rs = await _client.send(rq);
final body = await rs.stream.bytesToString();
final root = XmlDocument.parse(body);
var elem = root.rootElement;
if (elem.name.local == 'ErrorResponse') {
final error = elem.findElements('Error').first;
final type = error.findElements('Type').first.innerText;
final code = error.findElements('Code').first.innerText;
final message = error.findElements('Message').first.innerText;
final fn = exceptionFnMap[code];
final exception = fn != null
? fn(type, message)
: GenericAwsException(type: type, code: code, message: message);
throw exception;
}
if (resultWrapper != null) {
elem = elem.findElements(resultWrapper).first;
}
return elem;
}