base.py 606 B

1234567891011121314151617181920
  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 = {
  9. "Content-Type": "application/json",
  10. "Enterprise-Api-Secret-Key": cls.secret_key
  11. }
  12. url = f"{cls.base_url}{endpoint}"
  13. response = requests.request(method, url, json=json, params=params, headers=headers)
  14. return response.json()