# Path: pagarme/resources/requests_retry.py
# def requests_retry_session(
#     retries=3,
#     backoff_factor=0.3,
#     status_forcelist=(500, 502, 504),
#     session=None,
# ):
#     session = session or requests.Session()
#     session.headers.update(headers())
# 
#     retry = Retry(
#         total=retries,
#         read=retries,
#         connect=retries,
#         backoff_factor=backoff_factor,
#         status_forcelist=status_forcelist,
#     )
#     adapter = HTTPAdapter(max_retries=retry)
#     session.mount('https://', adapter)
#     return session


from .requests_retry import requests_retry_session
    valid_company = validate_response(company)
    return valid_company


def authentication_key(api_key=None, company_temporary=False):
    global KEYS
    if company_temporary is False:
        KEYS['api_key'] = api_key
        return KEYS
    if company_temporary is True:
        company = create_temporary_company()
        api_key = company['api_key']['test']
        KEYS['api_key'] = api_key
        return KEYS


def delete(end_point, data = {}):
    data['api_key'] = KEYS['api_key']
    pagarme_response = requests_retry_session().delete(end_point, json=data)
    return validate_response(pagarme_response)


def get(end_point, data = {}):
    data['api_key'] = KEYS['api_key']
    pagarme_response = requests_retry_session().get(end_point, json=data)
    return validate_response(pagarme_response)


def post(end_point, data={}):
    data['api_key'] = KEYS['api_key']

# Path: pagarme/resources/requests_retry.py
# def requests_retry_session(
#     retries=3,
#     backoff_factor=0.3,
#     status_forcelist=(500, 502, 504),
#     session=None,
# ):
#     session = session or requests.Session()
#     session.headers.update(headers())
# 
#     retry = Retry(
#         total=retries,
#         read=retries,
#         connect=retries,
#         backoff_factor=backoff_factor,
#         status_forcelist=status_forcelist,
#     )
#     adapter = HTTPAdapter(max_retries=retry)
#     session.mount('https://', adapter)
#     return session


# Path: pagarme/resources/handler_request.py
from .requests_retry import requests_retry_session

    valid_company = validate_response(company)
    return valid_company


def authentication_key(api_key=None, company_temporary=False):
    global KEYS
    if company_temporary is False:
        KEYS['api_key'] = api_key
        return KEYS
    if company_temporary is True:
        company = create_temporary_company()
        api_key = company['api_key']['test']
        KEYS['api_key'] = api_key
        return KEYS


def delete(end_point, data = {}):
    data['api_key'] = KEYS['api_key']
    pagarme_response = requests_retry_session().delete(end_point, json=data)
    return validate_response(pagarme_response)


def get(end_point, data = {}):
    data['api_key'] = KEYS['api_key']
    pagarme_response = requests_retry_session().get(end_point, json=data)
    return validate_response(pagarme_response)


def post(end_point, data={}):
    data['api_key'] = KEYS['api_key']

    pagarme_response = requests_retry_session().post(end_point, json=data)