from typing import List
from lxml import objectify
from q2_sdk.models.cores.mappers.update_demographic_info import (
BaseUpdateDemographicInfoMapper,
)
from q2_sdk.models.cores.queries.base_query import BaseQuery
from .. import data_helpers
[docs]
class UpdateEmailInfoMapper(BaseUpdateDemographicInfoMapper):
[docs]
@staticmethod
def parse_returned_queries(list_of_queries: List[BaseQuery]) -> bool:
"""Returns True if all queries were successful, False if there was an error"""
response_successes = []
# Updating phone and address give the same response, so we can just loop through
# All messages and see if the response text is 'OK'
# If not, there was a problem and we return False
for query in list_of_queries:
response = data_helpers.cleanse_itc_strings(query.raw_core_response)
root = objectify.fromstring(response)
if root.RESPONSE.text == "OK":
response_successes.append(True)
else:
query.logger.error(
"Core Failure: {}".format(root.RESPONSE.FAILED_MESSAGE.text)
)
response_successes.append(False)
return all(response_successes)