You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnlogging.info("Environment file has been read")
23
+
else:
24
+
returnlogging.info(".env file not present, falling back to normal Environment")
21
25
22
26
definit(latitude, longitude):
23
27
'''
@@ -27,7 +31,7 @@ def init(latitude, longitude):
27
31
url="https://www.ah.nl/gql"#open gql endpoint for anonymous requests
28
32
headers= {'Client-Name': 'ah-stores','Client-Version':'0.230.0'} #Missing client identification. Requests should include \"client-name\" and \"client-version\" headers
29
33
gql_body="""query stores($filter: StoreFilterInput, $size: PageSize!, $start: Int) {stores(filter: $filter, size: $size, start: $start) { result { ...storeList __typename} page { total hasNextPage __typename} __typename }}fragment storeList on Store { id name storeType phone distance address { ...storeAddress __typename } geoLocation { latitude longitude __typename} openingDays { ...openingDaysInfo __typename } __typename}fragment storeAddress on StoreAddress { city street houseNumber houseNumberExtra postalCode countryCode __typename}fragment openingDaysInfo on StoreOpeningDay { dayName type date openingHour { ...storeOpeningHour __typename } }fragment storeOpeningHour on StoreOpeningHour { date openFrom openUntil __typename}"""
30
-
json_data= {"operationName":"stores","variables":{"filter":{"location":{"latitude":latitude,"longitude":longitude}},"start":0,"size":readConfig().get('number_of_stores')},"query": gql_body} #tweak size: number of albert heijns this variable is for filtering
34
+
json_data= {"operationName":"stores","variables":{"filter":{"location":{"latitude":latitude,"longitude":longitude}},"start":0,"size":os.environ['number_of_stores']},"query": gql_body} #tweak size: number of albert heijns this variable is for filtering
31
35
response=requests.post(url=url, headers=headers, json=json_data, ) #simple post request putting it all together
function where the magic happens: it connects to the local sqlite db, connects authenticated to the surprise-boxes api and executes queries on the database
119
123
'''
120
-
results=init(float(readConfig().get('latitude')),float(readConfig().get('longitude'))) #Don't forget to make this a variable / cli parameter
124
+
results=init(float(os.environ['latitude']),float(os.environ['longitude'])) #Don't forget to make this a variable / cli parameter
Copy file name to clipboardExpand all lines: readme.md
+33-1Lines changed: 33 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,39 @@ A simple Python program for polling the Albert Heijn REST and Graph API's to get
39
39
40
40
The program works by grabbing the nearest x (default 5) number of Albert Heijn stores based on your latitude and longitude. After this it keeps a record of stores with boxes available and it will send you a Telegram notification when something's changed. e.g. boxes are available, a box is gone, everything is gone.
0 commit comments