# Path: pytaxize/refactor.py
# class Refactor:
#     def __init__(self, url, payload={}, request="get"):
#         self.url = url
#         self.payload = payload
#         self.request = request
# 
#     def return_requests(self, **kwargs):
#         if self.request == "get":
#             return requests.get(self.url, params=self.payload, **kwargs)
#         else:
#             return requests.post(self.url, params=self.payload, **kwargs)
# 
#     def xml(self, **kwargs):
#         if self.request == "get":
#             out = requests.get(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             xmlparser = etree.XMLParser()
#             tt = etree.fromstring(out.content, xmlparser)
#             try:
#                 # If entrez api 'X-RateLimit-Remaining' header is 1 or below, pause for a second to allow rate limit to reset
#                 if (int(out.headers['X-RateLimit-Remaining'])<=1):
#                     time.sleep(1)
#             except:
#                 pass 
#             return tt
#         else:
#             out = requests.post(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             xmlparser = etree.XMLParser()
#             tt = etree.fromstring(out.content, xmlparser)
#             return tt
# 
#     def json(self, **kwargs):
#         if self.request == "get":
#             out = requests.get(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.json()
#         else:
#             out = requests.post(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.json()
# 
#     def raw(self, **kwargs):
#         if self.request == "get":
#             out = requests.get(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.text
#         else:
#             out = requests.post(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.text
# 
# Path: pytaxize/ids/format_helpers.py
# def _make_id(id_, name, rank, type_):
#     uri = None
#     if id_ is not None:
#         uri = _make_id_uri(rank, type_, id_)
# 
#     return {"id": id_, "name": name, "rank": rank, "uri": uri}


from ..refactor import Refactor
from .format_helpers import _make_id
    response = (
        Refactor(url="https://eol.org/api/pages/1.0/%s.json" % pid, request="get",)
        .json()
        .get("taxonConcept", {})
        .get("taxonConcepts", {})
    )
    response = list(map(lambda x: {**x, "page_id": pid}, response))
    return response


def process_eol_search_response(name_response_tuple):
    user_input_name, list_of_response_dicts = name_response_tuple
    user_input_name = user_input_name.lower()
    extracted_ids = list(
        filter(
            lambda page_dict: user_input_name in page_dict["title"].lower(),
            list_of_response_dicts,
        )
    )
    extracted_ids = list(
        map(lambda page_dict: page_dict.get("id", None), list_of_response_dicts,)
    )
    extracted_ids = list(filter(lambda id_: id_ is not None, extracted_ids))
    return extracted_ids


def process_list_of_taxa_details(list_of_responses):
    useful_data = list(
        map(
            lambda x: {

# Path: pytaxize/refactor.py
# class Refactor:
#     def __init__(self, url, payload={}, request="get"):
#         self.url = url
#         self.payload = payload
#         self.request = request
# 
#     def return_requests(self, **kwargs):
#         if self.request == "get":
#             return requests.get(self.url, params=self.payload, **kwargs)
#         else:
#             return requests.post(self.url, params=self.payload, **kwargs)
# 
#     def xml(self, **kwargs):
#         if self.request == "get":
#             out = requests.get(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             xmlparser = etree.XMLParser()
#             tt = etree.fromstring(out.content, xmlparser)
#             try:
#                 # If entrez api 'X-RateLimit-Remaining' header is 1 or below, pause for a second to allow rate limit to reset
#                 if (int(out.headers['X-RateLimit-Remaining'])<=1):
#                     time.sleep(1)
#             except:
#                 pass 
#             return tt
#         else:
#             out = requests.post(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             xmlparser = etree.XMLParser()
#             tt = etree.fromstring(out.content, xmlparser)
#             return tt
# 
#     def json(self, **kwargs):
#         if self.request == "get":
#             out = requests.get(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.json()
#         else:
#             out = requests.post(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.json()
# 
#     def raw(self, **kwargs):
#         if self.request == "get":
#             out = requests.get(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.text
#         else:
#             out = requests.post(self.url, params=self.payload, **kwargs)
#             out.raise_for_status()
#             return out.text
# 
# Path: pytaxize/ids/format_helpers.py
# def _make_id(id_, name, rank, type_):
#     uri = None
#     if id_ is not None:
#         uri = _make_id_uri(rank, type_, id_)
# 
#     return {"id": id_, "name": name, "rank": rank, "uri": uri}


# Path: pytaxize/ids/eol_helpers.py
from ..refactor import Refactor
from .format_helpers import _make_id

    response = (
        Refactor(url="https://eol.org/api/pages/1.0/%s.json" % pid, request="get",)
        .json()
        .get("taxonConcept", {})
        .get("taxonConcepts", {})
    )
    response = list(map(lambda x: {**x, "page_id": pid}, response))
    return response


def process_eol_search_response(name_response_tuple):
    user_input_name, list_of_response_dicts = name_response_tuple
    user_input_name = user_input_name.lower()
    extracted_ids = list(
        filter(
            lambda page_dict: user_input_name in page_dict["title"].lower(),
            list_of_response_dicts,
        )
    )
    extracted_ids = list(
        map(lambda page_dict: page_dict.get("id", None), list_of_response_dicts,)
    )
    extracted_ids = list(filter(lambda id_: id_ is not None, extracted_ids))
    return extracted_ids


def process_list_of_taxa_details(list_of_responses):
    useful_data = list(
        map(
            lambda x: {

                **_make_id(