BP_API_URL = 'https://enterprise.bharatpe.in/v1/api/transaction/recon'

import requests

class BharatPe:
    def __init__(self, bharatpe_session: str, TOKEN: str):
        self.bharatpe_session = bharatpe_session
        self.TOKEN = TOKEN

    def get_utr_info(self, utr_number: int) -> dict:
        headers = {'token': self.TOKEN}
        params = {'utr': utr_number}
        cookies = {'bharatpe_session': self.bharatpe_session}
        try:
            return requests.get(
                BP_API_URL,
                headers=headers, 
                params=params, 
                cookies=cookies
            ).json()
        except:
            return requests.get(
                BP_API_URL,
                headers=headers, 
                params=params, 
                cookies=cookies
            ).content
