Remove skeleton owlboard client from this code. Instead import pyOwlBoard

This commit is contained in:
Fred Boniface 2024-10-31 12:30:49 +00:00
parent f639a45de0
commit 256ca072ff

View File

@ -1,37 +0,0 @@
import requests
from urllib.parse import urljoin
class APIConnectionError(Exception):
# API Connection has failed
pass
## CONTANTS
API_TEST_PATH = ""
API_HEADCODE_PATH = ""
API_TRAIN_UID_PATH = ""
class OwlBoard_API_Connection:
def __init__(self, api_key, base_url):
self.api_key = api_key
self.base_url = base_url
self.request_headers = {
'Content-Type': 'application/json',
'uuid': self.api_key
}
if not self.test_connection():
raise APIConnectionError(f"failed to connect to API at {self.base_url} with supplied API key")
def test_connection(self):
try:
request_url = urljoin(self.base_url, API_TEST_PATH)
response = requests.get(request_url, headers=self.request_headers)
response.raise_for_status()
return True
except requests.RequestException as e:
print(f"Connection rest failed: {e}")
return False