1
+ import { fetchWithCookie } from 'backend/utils/fetch_with_cookie'
1
2
import { DEV_PORTAL_URL } from 'common/constants'
3
+ import { GenericApiResponse , PointsClaimReturn } from 'common/types'
2
4
import { ipcMain } from 'electron'
3
5
4
6
ipcMain . handle ( 'getQuests' , async ( e , projectId ) => {
@@ -17,8 +19,31 @@ ipcMain.handle('getQuest', async (e, questId) => {
17
19
return questResultJson
18
20
} )
19
21
22
+ ipcMain . handle ( 'getUserPlayStreak' , async ( e , questId ) => {
23
+ const questResultJson = await fetchWithCookie ( {
24
+ url : `${ DEV_PORTAL_URL } api/v1/quests/${ questId } /playstreak` ,
25
+ method : 'GET'
26
+ } )
27
+ return questResultJson
28
+ } )
29
+
20
30
ipcMain . handle ( 'getSteamGameMetadata' , async ( e , gameId ) => {
21
31
const result = await fetch ( `${ DEV_PORTAL_URL } api/v1/steam/games/${ gameId } ` )
22
32
const resultJson = await result . json ( )
23
33
return resultJson
24
34
} )
35
+
36
+ ipcMain . handle ( 'claimQuestPointsReward' , async ( e , rewardId ) => {
37
+ const url = `${ DEV_PORTAL_URL } api/v1/quests/rewards/${ rewardId } /points-claim`
38
+ return ( await fetchWithCookie ( { url, method : 'POST' } ) ) as PointsClaimReturn
39
+ } )
40
+
41
+ ipcMain . handle ( 'completeExternalTask' , async ( e , rewardId ) => {
42
+ const url = `${ DEV_PORTAL_URL } api/v1/quests/rewards/${ rewardId } /external-tasks/completed`
43
+ return ( await fetchWithCookie ( { url, method : 'POST' } ) ) as GenericApiResponse
44
+ } )
45
+
46
+ ipcMain . handle ( 'resyncExternalTask' , async ( e , rewardId ) => {
47
+ const url = `${ DEV_PORTAL_URL } api/v1/quests/rewards/${ rewardId } /external-tasks/re-sync`
48
+ return ( await fetchWithCookie ( { url, method : 'POST' } ) ) as GenericApiResponse
49
+ } )
0 commit comments