Skip to content

Commit

Permalink
Simplify getting URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
leonghui committed Mar 12, 2024
1 parent acdcff5 commit d55e6d6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions gwr_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def get_request_bodies(query, dates):


def get_item_listing(query):
query_url = query.config.url + query.config.journey_uri

dates = [
query.timestamp + timedelta(days=(7 * x)) for x in range(query.weeks_ahead + 1)
Expand All @@ -130,7 +129,7 @@ def get_item_listing(query):

for date, body in request_dict.items():

json_dict = get_response_dict(query_url, query, body)
json_dict = get_response_dict(query.config.journey_url, query, body)

if json_dict:
journeys = json_dict["data"]["outwardservices"]
Expand Down
6 changes: 3 additions & 3 deletions gwr_feed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class FeedConfig:
base_url: str = GWR_BASE_URL
favicon_url: str = GWR_BASE_URL + FAVICON_URI
domain: str = GWR_DOMAIN
locations_uri: str = LOCATIONS_SEARCH_URI
journey_uri: str = JOURNEY_SEARCH_URI
basket_uri: str = BASKET_URI
locations_url: str = GWR_API_URL + LOCATIONS_SEARCH_URI
journey_url: str = GWR_API_URL + JOURNEY_SEARCH_URI
basket_url: str = GWR_API_URL + BASKET_URI
currency: str = CURRENCY_CODE
headers: dict = field(default_factory=dict)

Expand Down
4 changes: 1 addition & 3 deletions gwr_location.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
def get_station_id(station_code, config):

base_url = config.url + config.locations_uri

search_url = base_url
search_url = config.locations_url

config.logger.debug(f"Querying endpoint: {search_url}")

Expand Down
3 changes: 1 addition & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@


def get_session_token():
basket_url = config.url + config.basket_uri
init_response = requests.get(basket_url, timeout=10)
init_response = requests.get(config.basket_url, timeout=10)
new_session_token = init_response.headers.get("Session-Token")
if new_session_token:
config.logger.debug(f"Received new session token: {new_session_token}")
Expand Down

0 comments on commit d55e6d6

Please sign in to comment.