base.py 572 B

123456789101112131415161718
  1. import os
  2. import requests
  3. class EnterpriseRequest:
  4. base_url = os.environ.get("ENTERPRISE_API_URL", "ENTERPRISE_API_URL")
  5. secret_key = os.environ.get("ENTERPRISE_API_SECRET_KEY", "ENTERPRISE_API_SECRET_KEY")
  6. @classmethod
  7. def send_request(cls, method, endpoint, json=None, params=None):
  8. headers = {"Content-Type": "application/json", "Enterprise-Api-Secret-Key": cls.secret_key}
  9. url = f"{cls.base_url}{endpoint}"
  10. response = requests.request(method, url, json=json, params=params, headers=headers)
  11. return response.json()