parseResponse method

Response parseResponse(
  1. String xmlStr, [
  2. bool isGetInfo = false
])

Response Message Format: success = "true" | "false"; status = if error return "error code", else return '0';

[xmlStr] [isGetInfo] if exce

Implementation

Response parseResponse(String xmlStr, [bool isGetInfo = false]) {
  // create xml parser
  final parser = Xml2Json();
  // parse to object
  parser.parse(xmlStr);
  final jsonStr = parser.toParkerWithAttrs();
  final xmlObj = jsonDecode(jsonStr);
  Map? response;
  if (xmlObj != null && xmlObj.isNotEmpty) {
    // get response data
    response = xmlObj[isGetInfo
        ? CustomXmlHttpClient._infoXmlResponse
        : CustomXmlHttpClient._xmlResponse];
  }
  return Response(
    ok: response != null && response['_success'] == 'true',
    body: response,
  );
}