11import axios from "axios"
22
3- import { urls } from "../main"
3+ import { getCookies , urls } from "../main"
44
55/**
6- * Find puzzle informations and player's completion from an array
6+ * Find puzzle informations and player's completion from an array of number IDs.
77 *
88 * @param {number[] } ids - Every Puzzle IDs you want to inspect
9- * @param {number } userId - The user ID you want to retrieve the completion
9+ * @param {number } userId - User ID you want to retrieve the completion
1010 *
1111 */
1212
@@ -24,6 +24,33 @@ export const findProgressByIds = async (ids: number[], userId: number): Promise<
2424 return response [ "data" ]
2525}
2626
27+
28+ /**
29+ * Find every minimal puzzle progress from a user. You can also use this to get every puzzles of CodinGame
30+ *
31+ * @param {number } userId - User ID you want to retrieve the completion
32+ *
33+ */
34+
35+ export const findAllMinimalProgress = async ( userId : number ) : Promise < IPuzzleMinimalProgress [ ] > => {
36+
37+ const cookies : string = getCookies ( )
38+
39+ const response = await axios ( {
40+ url : urls . puzzle + "findAllMinimalProgress" ,
41+ method : "post" ,
42+ headers : {
43+ "content-type" : "application/json;charset=UTF-8" ,
44+ "cookie" : cookies
45+ } ,
46+ data : [ userId ]
47+ } )
48+
49+ return response [ "data" ]
50+ }
51+
52+
53+
2754export interface IPuzzleProgress {
2855 id : number
2956 level : string
@@ -62,4 +89,16 @@ type topics = {
6289 category : string
6390 value : string
6491 children : topics [ ] | [ ]
92+ }
93+
94+ export interface IPuzzleMinimalProgress {
95+ id : number
96+ level : string
97+ validatorScore : number
98+ submitted : boolean
99+ creationTime : number
100+ rank : number
101+ solvedCount : number
102+ communityCreation : boolean
103+ feedback : feedbackPuzzle
65104}
0 commit comments