send method

Future<XmlElement> send(
  1. Map<String, dynamic> data, {
  2. required String method,
  3. required String requestUri,
  4. required Map<String, AwsExceptionFn> exceptionFnMap,
  5. bool signed = true,
  6. Shape? shape,
  7. required Map<String, Shape> shapes,
  8. required String version,
  9. required String action,
  10. 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;
}