# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/04_ensc.ipynb.

# %% auto 0
__all__ = ['EnsemblClient']

# %% ../nbs/04_ensc.ipynb 4
from urllib.parse import urljoin

# %% ../nbs/04_ensc.ipynb 5
from .cons import ENSEMBL_SERVER, RATE_LIMIT
from .reqs import RateLimitRequest

# %% ../nbs/04_ensc.ipynb 7
class EnsemblClient(object):
    rate = RATE_LIMIT
    rest = ENSEMBL_SERVER

    def request(self, endpoint: str, **params) -> RateLimitRequest:
        return RateLimitRequest(urljoin(self.rest, endpoint), rate=self.rate, **params)()
   
    def lookup(self, symbol: str, species: str = 'homo_sapiens', **kwargs):
        endpoint = f'/lookup/symbol/{species}/{symbol}'
        return self.request(endpoint, **kwargs)
    
    def getids(self, symbol: str, species: str = 'homo_sapiens', external_db: str = 'HGNC', **kwargs):
        endpoint = f'/xrefs/symbol/{species}/{symbol}'
        return self.request(endpoint, external_db = external_db, **kwargs)
