old_contents: from .endpoints import Endpoints
  from .helpers import get, scrape_filters
  
  
  class Cobalt:
      def __init__(self, api_key=None):
          self.host = 'http://cobalt.qas.im/api/1.0'
  
          self.headers = {
              'Referer': 'Cobalt-UofT-Python'
          }
  
          if not api_key or not self._is_valid_key(api_key):
              raise ValueError('Expected valid API key.')
  
          self.headers['Authorization'] = api_key
  
          self.filter_map = scrape_filters()
  
      def _get(self, url, params=None):
          return get(url=url, params=params, headers=self.headers)
  
      def _is_valid_key(self, key):
          payload = {'key': key}
          r = self._get(self.host, params=payload)
          return r.reason == 'Not Found' and r.status_code == 404
  
      def _run(self, api, endpoint=None, params=None):
          res = Endpoints.run(api=api,
                              endpoint=endpoint,
                              params=params,
                              map=self.filter_map[api],
                              get=self._get)
          return res.json()
  
      def athletics(self, endpoint=None, params=None):
          return self._run(api='athletics', endpoint=endpoint, params=params)
  
      def buildings(self, endpoint=None, params=None):
          return self._run(api='buildings', endpoint=endpoint, params=params)
  
      def courses(self, endpoint=None, params=None):
          return self._run(api='courses', endpoint=endpoint, params=params)
  
      def food(self, endpoint=None, params=None):
          return self._run(api='food', endpoint=endpoint, params=params)
  
      def textbooks(self, endpoint=None, params=None):
          return self._run(api='textbooks', endpoint=endpoint, params=params)
  
new_contents: from .endpoints import Endpoints
  from .helpers import get, scrape_filters
  
  
  class Cobalt:
      def __init__(self, api_key=None):
          self.host = 'http://cobalt.qas.im/api/1.0'
  
          self.headers = {
              'Referer': 'Cobalt-UofT-Python',
              'Authorization': api_key
          }
  
          if not api_key or not self._is_valid_key():
              raise ValueError('Expected valid API key.')
  
          self.filter_map = scrape_filters()
  
      def _get(self, url, params=None, headers=None):
          headers = headers or self.headers
          return get(url=url, params=params, headers=self.headers)
  
      def _is_valid_key(self):
          r = self._get(self.host)
          return r.reason == 'Not Found' and r.status_code == 404
  
      def _run(self, api, endpoint=None, params=None):
          res = Endpoints.run(api=api,
                              endpoint=endpoint,
                              params=params,
                              map=self.filter_map[api],
                              get=self._get)
          return res.json()
  
      def athletics(self, endpoint=None, params=None):
          return self._run(api='athletics', endpoint=endpoint, params=params)
  
      def buildings(self, endpoint=None, params=None):
          return self._run(api='buildings', endpoint=endpoint, params=params)
  
      def courses(self, endpoint=None, params=None):
          return self._run(api='courses', endpoint=endpoint, params=params)
  
      def food(self, endpoint=None, params=None):
          return self._run(api='food', endpoint=endpoint, params=params)
  
      def textbooks(self, endpoint=None, params=None):
          return self._run(api='textbooks', endpoint=endpoint, params=params)
  
subject: Use headers to validate key