AeaRequestRequest.fromXML constructor

AeaRequestRequest.fromXML(
  1. String xmlSTR
)

Implementation

factory AeaRequestRequest.fromXML(String xmlSTR) {
  final document = XmlDocument.parse(xmlSTR);
  String messageID = document.rootElement.attributes
      .firstWhere((p0) => p0.name.toString() == "messageID")
      .value;
  List<XmlElement> messageElements =
      document.rootElement.findAllElements("aeaMessage").toList();
  List<XmlElement> textMessages = messageElements
      .where((element) =>
          element.childElements.any((ee) => ee.name.toString() == "aeaText"))
      .toList();
  List<XmlElement> binaryMessages = messageElements
      .where((element) => element.childElements
          .any((ee) => ee.name.toString() == "aeaBinary"))
      .toList();
  List<String> texts = textMessages.map((e) => e.text).toList();
  List<String> binaries = binaryMessages.map((e) => e.text).toList();

  return AeaRequestRequest(
      texts: texts, binaries: binaries, messageID: int.parse(messageID));
}