1616 "Expires" : "0" ,
1717}
1818
19- SALES_FROM_DATE_KEY : Final [str ] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromDate"
20- SALES_FROM_TIME_KEY : Final [str ] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromTime"
21- SALES_TO_DATE_KEY : Final [str ] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToDate"
22- SALES_TO_TIME_KEY : Final [str ] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToTime"
23-
24-
25- async def get_msl_context (url : str , auth_cookie : str ) -> tuple [dict [str , str ], dict [str , str ]]:
19+ SALES_FROM_DATE_KEY : Final [str ] = (
20+ "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromDate"
21+ )
22+ SALES_FROM_TIME_KEY : Final [str ] = (
23+ "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromTime"
24+ )
25+ SALES_TO_DATE_KEY : Final [str ] = (
26+ "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToDate"
27+ )
28+ SALES_TO_TIME_KEY : Final [str ] = (
29+ "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToTime"
30+ )
31+
32+
33+ async def get_msl_context (
34+ url : str , auth_cookie : str
35+ ) -> tuple [dict [str , str ], dict [str , str ]]:
2636 """Get the required context headers, data and cookies to make a request to MSL."""
2737
2838 BASE_COOKIES : Mapping [str , str ] = {
@@ -70,8 +80,12 @@ async def fetch_report_url_and_cookies(
7080 report_type : str ,
7181) -> tuple [str | None , dict [str , str ]]:
7282 """Fetch the specified report from the guild website."""
73- SALES_REPORTS_URL : Final [str ] = f"https://www.guildofstudents.com/organisation/salesreports/{ org_id } /"
74- data_fields , cookies = await get_msl_context (url = SALES_REPORTS_URL , auth_cookie = auth_cookie )
83+ SALES_REPORTS_URL : Final [str ] = (
84+ f"https://www.guildofstudents.com/organisation/salesreports/{ org_id } /"
85+ )
86+ data_fields , cookies = await get_msl_context (
87+ url = SALES_REPORTS_URL , auth_cookie = auth_cookie
88+ )
7589
7690 form_data : dict [str , str ] = {
7791 SALES_FROM_DATE_KEY : from_date .strftime ("%d/%m/%Y" ),
@@ -91,7 +105,10 @@ async def fetch_report_url_and_cookies(
91105 headers = BASE_HEADERS ,
92106 cookies = cookies ,
93107 )
94- async with (session_v2 , session_v2 .post (url = SALES_REPORTS_URL , data = data_fields ) as http_response ,): # noqa: E501
108+ async with (
109+ session_v2 ,
110+ session_v2 .post (url = SALES_REPORTS_URL , data = data_fields ) as http_response ,
111+ ):
95112 if http_response .status != 200 :
96113 print ("Returned a non 200 status code!!" )
97114 print (http_response )
0 commit comments