Release 0.0.1 ready

This commit is contained in:
Fred Boniface 2024-10-31 12:13:37 +00:00
parent 767e258687
commit a6c9149d5b
2 changed files with 15 additions and 2 deletions

View File

@ -83,6 +83,7 @@ class OwlBoardClient:
return
### Train Methods ###
def get_trains_by_headcode(self, headcode: str, date: datetime):
if not isinstance(headcode, str):
raise TypeError("headcode must be a string")
@ -132,11 +133,22 @@ class OwlBoardClient:
logger.info("Response received for get_trains_by_trainUid")
print(response.text)
## Location Reference Methods ##
def get_loc_ref_codes_by_tiploc(self, tiploc: str):
url_path = url_multijoin(self.base_url, ENDPOINTS['REF_LOCATION_BY_TIPLOC'], tiploc)
logger.debug(f"Generated URL: {url_path}")
# Send Request
response = self._make_request('GET', url_path)
logger.info("Response received for get_trains_by_trainUid")
print(response.text)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
try:
client = OwlBoardClient(base_url='https://owlboard.info', api_key="x")
client.get_trains_by_headcode("1A99", datetime.now())
client.get_loc_ref_codes_by_tiploc('BATHSPA')
except Exception as e:
logger.error(f"Failed to create client: {e}")

View File

@ -4,5 +4,6 @@ ENDPOINTS = {
'TEST': '/api/v1/auth/test/',
'PIS_BY_CODE': '/api/v2/pis/byCode/',
'PIS_BY_START_END_CRS': '/api/v2/pis/byStartEnd/',
'TIMETABLE_TRAINS': '/api/v2/timetable/train'
'TIMETABLE_TRAINS': '/api/v2/timetable/train',
'REF_LOCATION_BY_TIPLOC': '/api/v2/ref/locationCode/tiploc/',
}