# Path: pynubank/exception.py
# class NuRequestException(NuException):
#     def __init__(self, response: Response):
#         super().__init__(f'The request made failed with HTTP status code {response.status_code}')
#         self.url = response.url
#         self.status_code = response.status_code
#         self.response = response


from requests import Response
from requests_pkcs12 import get, post
from pynubank import NuRequestException


class HttpClient:

    def __init__(self):
        self._cert = None
        self._headers = {
            'Content-Type': 'application/json',
            'X-Correlation-Id': 'WEB-APP.pewW9',
            'User-Agent': 'pynubank Client - https://github.com/andreroggeri/pynubank',
        }

    def set_cert(self, cert_path: str):
        self._cert = cert_path

    def set_header(self, name: str, value: str):
        self._headers[name] = value

    def remove_header(self, name: str):
        self._headers.pop(name)

    def get_header(self, name: str):
        return self._headers.get(name)

    @property
    def _cert_args(self):
        return {'pkcs12_filename': self._cert, 'pkcs12_password': ''} if self._cert else {}

    def _handle_response(self, response: Response) -> dict:
        if response.status_code != 200:

# Path: pynubank/exception.py
# class NuRequestException(NuException):
#     def __init__(self, response: Response):
#         super().__init__(f'The request made failed with HTTP status code {response.status_code}')
#         self.url = response.url
#         self.status_code = response.status_code
#         self.response = response


# Path: pynubank/utils/http.py
from requests import Response
from requests_pkcs12 import get, post
from pynubank import NuRequestException



class HttpClient:

    def __init__(self):
        self._cert = None
        self._headers = {
            'Content-Type': 'application/json',
            'X-Correlation-Id': 'WEB-APP.pewW9',
            'User-Agent': 'pynubank Client - https://github.com/andreroggeri/pynubank',
        }

    def set_cert(self, cert_path: str):
        self._cert = cert_path

    def set_header(self, name: str, value: str):
        self._headers[name] = value

    def remove_header(self, name: str):
        self._headers.pop(name)

    def get_header(self, name: str):
        return self._headers.get(name)

    @property
    def _cert_args(self):
        return {'pkcs12_filename': self._cert, 'pkcs12_password': ''} if self._cert else {}

    def _handle_response(self, response: Response) -> dict:
        if response.status_code != 200:

            raise NuRequestException(response)