11from config .settings import Config
2- from leetcode .parser import parse_submissions
2+
3+ from leetcode .parser import (
4+ parse_submissions ,
5+ parse_submission_detail ,
6+ )
7+
38from leetcode .queries import (
49 PROFILE_QUERY ,
510 RECENT_SUBMISSIONS_QUERY ,
11+ SUBMISSION_DETAILS_QUERY ,
612)
713
814
915class LeetCodeAPI :
10-
1116 def __init__ (self , client ):
1217 self .client = client
1318
1419 def get_profile (self ):
20+ """Fetch the user's profile and solved statistics."""
21+
1522 response = self .client .post (
1623 PROFILE_QUERY ,
1724 {
1825 "username" : Config .LEETCODE_USERNAME
19- }
26+ },
2027 )
2128
2229 if "errors" in response :
@@ -25,6 +32,7 @@ def get_profile(self):
2532 return response ["data" ]["matchedUser" ]
2633
2734 def get_recent_submissions (self , limit = 15 ):
35+ """Fetch the user's recent accepted submissions."""
2836
2937 response = self .client .post (
3038 RECENT_SUBMISSIONS_QUERY ,
@@ -39,4 +47,22 @@ def get_recent_submissions(self, limit=15):
3947
4048 return parse_submissions (
4149 response ["data" ]["recentAcSubmissionList" ]
50+ )
51+
52+ def get_submission_detail (self , submission_id ):
53+ """Fetch detailed information about a submission."""
54+
55+ response = self .client .post (
56+ SUBMISSION_DETAILS_QUERY ,
57+ {
58+ "submissionId" : int (submission_id )
59+ },
60+ )
61+
62+ if "errors" in response :
63+ raise Exception (response ["errors" ])
64+
65+ return parse_submission_detail (
66+ submission_id ,
67+ response ["data" ]["submissionDetails" ],
4268 )
0 commit comments