-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into chore/#163-casper-custom-folder
- Loading branch information
Showing
71 changed files
with
2,000 additions
and
302 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { | ||
GetRushBalanceResponse, | ||
GetRushOptionResultResponse, | ||
GetRushResultResponse, | ||
GetRushUserParticipationStatusResponse, | ||
GetTodayRushEventResponse, | ||
GetTotalRushEventsResponse, | ||
RushEventStatusCodeResponse, | ||
} from "@/types/rushApi"; | ||
import { fetchWithTimeout } from "@/utils/fetchWithTimeout.ts"; | ||
|
||
const baseURL = `${import.meta.env.VITE_API_URL}/event/rush`; | ||
const headers = { | ||
"Content-Type": "application/json", | ||
}; | ||
|
||
export const RushAPI = { | ||
async getRush(): Promise<GetTotalRushEventsResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}`, { | ||
method: "GET", | ||
headers: headers, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async getRushUserParticipationStatus( | ||
token: string | ||
): Promise<GetRushUserParticipationStatusResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/applied`, { | ||
method: "GET", | ||
headers: { ...headers, Authorization: `Bearer ${token}` }, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async getTodayRushEvent(token: string): Promise<GetTodayRushEventResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/today`, { | ||
method: "GET", | ||
headers: { ...headers, Authorization: `Bearer ${token}` }, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async postSelectedRushOptionApply( | ||
token: string, | ||
optionId: number | ||
): Promise<RushEventStatusCodeResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/options/${optionId}/apply`, { | ||
method: "POST", | ||
headers: { ...headers, Authorization: `Bearer ${token}` }, | ||
}); | ||
|
||
if (response.status === 204 || response.status === 404) { | ||
return response.status; | ||
} | ||
|
||
throw new Error(`Unexpected response status: ${response.status}`); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async getRushOptionResult( | ||
token: string, | ||
optionId: number | ||
): Promise<GetRushOptionResultResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/options/${optionId}/result`, { | ||
method: "GET", | ||
headers: { ...headers, Authorization: `Bearer ${token}` }, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async getRushBalance(token: string): Promise<GetRushBalanceResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/balance`, { | ||
method: "GET", | ||
headers: { ...headers, Authorization: `Bearer ${token}` }, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async getRushResult(token: string): Promise<GetRushResultResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/result`, { | ||
method: "GET", | ||
headers: { ...headers, Authorization: `Bearer ${token}` }, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
async getRushTodayEventTest(): Promise<RushEventStatusCodeResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}/today/test`, { | ||
method: "GET", | ||
headers: headers, | ||
}); | ||
if (response.status === 204 || response.status === 404) { | ||
return response.status; | ||
} | ||
|
||
throw new Error(`Unexpected response status: ${response.status}`); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { GetTotalEventDateResponse } from "@/types/totalApi.ts"; | ||
import { fetchWithTimeout } from "@/utils/fetchWithTimeout.ts"; | ||
|
||
const baseURL = `${import.meta.env.VITE_API_URL}/event/total`; | ||
const headers = { | ||
"Content-Type": "application/json", | ||
}; | ||
|
||
export const TotalAPI = { | ||
async getTotal(): Promise<GetTotalEventDateResponse> { | ||
try { | ||
const response = await fetchWithTimeout(`${baseURL}`, { | ||
method: "GET", | ||
headers: headers, | ||
}); | ||
return response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.