diff --git a/pyOwlBoard/client.py b/pyOwlBoard/client.py index 3957a39..71848b3 100644 --- a/pyOwlBoard/client.py +++ b/pyOwlBoard/client.py @@ -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}") \ No newline at end of file diff --git a/pyOwlBoard/contants.py b/pyOwlBoard/contants.py index 82c0564..652b7fc 100644 --- a/pyOwlBoard/contants.py +++ b/pyOwlBoard/contants.py @@ -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/', } \ No newline at end of file