nova-api/api/request_manager.py
2023-07-25 19:45:21 +02:00

29 lines
639 B
Python

import os
from dotenv import load_dotenv
from typing import Union, Optional
load_dotenv()
EXCLUDED_HEADERS = [
'content-encoding',
'content-length',
'transfer-encoding',
'connection'
]
class Request:
def __init__(self,
url: str,
method: str='GET',
payload: Optional[Union[dict, list]]=None,
headers: dict={
'Content-Type': 'application/json'
}
):
self.method = method.upper()
self.url = url.replace('/v1/v1', '/v1')
self.payload = payload
self.headers = headers
self.timeout = int(os.getenv('TRANSFER_TIMEOUT', '120'))