204 lines
5.5 KiB
TypeScript
204 lines
5.5 KiB
TypeScript
/* eslint-disable */
|
|
// @ts-nocheck
|
|
/*
|
|
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
|
|
*/
|
|
|
|
import * as fm from "./fetch.pb"
|
|
|
|
export enum Difficulty {
|
|
Level1 = "Level1",
|
|
Level2 = "Level2",
|
|
}
|
|
|
|
export type Token = {
|
|
token?: string
|
|
expires?: string
|
|
}
|
|
|
|
export type OAuthCodeRequest = {
|
|
}
|
|
|
|
export type OAuthCodeResponse = {
|
|
redirectURI?: string
|
|
}
|
|
|
|
export type TokenRequest = {
|
|
code?: string
|
|
state?: string
|
|
}
|
|
|
|
export type DeleteTokenRequest = {
|
|
all?: boolean
|
|
token?: Token
|
|
}
|
|
|
|
export type DeleteTokenResponse = {
|
|
}
|
|
|
|
export type Info = {
|
|
currentUser?: User
|
|
active?: boolean
|
|
points?: number
|
|
startTime?: string
|
|
endTime?: string
|
|
}
|
|
|
|
export type User = {
|
|
id?: string
|
|
name?: string
|
|
email?: string
|
|
picture?: string
|
|
admin?: boolean
|
|
createdAt?: string
|
|
}
|
|
|
|
export type QuestionsRequest = {
|
|
}
|
|
|
|
export type PartData = {
|
|
completed?: boolean
|
|
pointsWorth?: number
|
|
}
|
|
|
|
export type Question = {
|
|
id?: string
|
|
title?: string
|
|
text?: string
|
|
difficulty?: Difficulty
|
|
part1?: PartData
|
|
part2?: PartData
|
|
}
|
|
|
|
export type QuestionsResponse = {
|
|
questions?: Question[]
|
|
}
|
|
|
|
export type QuestionByIDRequest = {
|
|
id?: string
|
|
}
|
|
|
|
export type QuestionInputRequest = {
|
|
id?: string
|
|
}
|
|
|
|
export type QuestionInput = {
|
|
id?: string
|
|
input?: string
|
|
}
|
|
|
|
export type SubmitRequestData = {
|
|
answer?: string
|
|
code?: string
|
|
}
|
|
|
|
export type SubmitRequest = {
|
|
id?: string
|
|
part?: number
|
|
body?: SubmitRequestData
|
|
}
|
|
|
|
export type SubmitResponse = {
|
|
correct?: boolean
|
|
points?: number
|
|
}
|
|
|
|
export type LeaderboardRequest = {
|
|
}
|
|
|
|
export type LeaderboardResponse = {
|
|
leaderboard?: LeaderboardEntry[]
|
|
}
|
|
|
|
export type LeaderboardEntry = {
|
|
username?: string
|
|
points?: number
|
|
}
|
|
|
|
export type InfoRequest = {
|
|
}
|
|
|
|
export type UpdateFields = {
|
|
name?: string
|
|
gradeLevel?: number
|
|
admin?: boolean
|
|
}
|
|
|
|
export type AdminUpdateFields = {
|
|
email?: string
|
|
name?: string
|
|
gradeLevel?: number
|
|
admin?: boolean
|
|
}
|
|
|
|
export type UpdateUserRequest = {
|
|
body?: UpdateFields
|
|
}
|
|
|
|
export type AdminUpdateUserRequest = {
|
|
body?: AdminUpdateFields
|
|
}
|
|
|
|
export type UserByEmailRequest = {
|
|
email?: string
|
|
}
|
|
|
|
export type DeleteUserRequest = {
|
|
email?: string
|
|
}
|
|
|
|
export type AllUsersRequest = {
|
|
}
|
|
|
|
export type AllUsersResponse = {
|
|
users?: User[]
|
|
}
|
|
|
|
export class AuthService {
|
|
static OAuthCode(req: OAuthCodeRequest, initReq?: fm.InitReq): Promise<OAuthCodeResponse> {
|
|
return fm.fetchReq<OAuthCodeRequest, OAuthCodeResponse>(`/v1/auth/code?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
|
|
}
|
|
static Token(req: TokenRequest, initReq?: fm.InitReq): Promise<Token> {
|
|
return fm.fetchReq<TokenRequest, Token>(`/v1/auth/token?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
|
|
}
|
|
static DeleteToken(req: DeleteTokenRequest, initReq?: fm.InitReq): Promise<DeleteTokenResponse> {
|
|
return fm.fetchReq<DeleteTokenRequest, DeleteTokenResponse>(`/v1/auth/token`, {...initReq, method: "DELETE"})
|
|
}
|
|
}
|
|
export class QuestService {
|
|
static Questions(req: QuestionsRequest, initReq?: fm.InitReq): Promise<QuestionsResponse> {
|
|
return fm.fetchReq<QuestionsRequest, QuestionsResponse>(`/v1/questions?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
|
|
}
|
|
static QuestionByID(req: QuestionByIDRequest, initReq?: fm.InitReq): Promise<Question> {
|
|
return fm.fetchReq<QuestionByIDRequest, Question>(`/v1/questions/${req["id"]}?${fm.renderURLSearchParams(req, ["id"])}`, {...initReq, method: "GET"})
|
|
}
|
|
static QuestionInput(req: QuestionInputRequest, initReq?: fm.InitReq): Promise<QuestionInput> {
|
|
return fm.fetchReq<QuestionInputRequest, QuestionInput>(`/v1/questions/${req["id"]}/input?${fm.renderURLSearchParams(req, ["id"])}`, {...initReq, method: "GET"})
|
|
}
|
|
static Submit(req: SubmitRequest, initReq?: fm.InitReq): Promise<SubmitResponse> {
|
|
return fm.fetchReq<SubmitRequest, SubmitResponse>(`/v1/questions/${req["id"]}/${req["part"]}`, {...initReq, method: "POST", body: JSON.stringify(req["Body"])})
|
|
}
|
|
static Leaderboard(req: LeaderboardRequest, initReq?: fm.InitReq): Promise<LeaderboardResponse> {
|
|
return fm.fetchReq<LeaderboardRequest, LeaderboardResponse>(`/v1/questions/leaderboard?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
|
|
}
|
|
}
|
|
export class UserService {
|
|
static Info(req: InfoRequest, initReq?: fm.InitReq): Promise<Info> {
|
|
return fm.fetchReq<InfoRequest, Info>(`/v1/users/me?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
|
|
}
|
|
static UserByEmail(req: UserByEmailRequest, initReq?: fm.InitReq): Promise<User> {
|
|
return fm.fetchReq<UserByEmailRequest, User>(`/v1/admin/users/${req["email"]}?${fm.renderURLSearchParams(req, ["email"])}`, {...initReq, method: "GET"})
|
|
}
|
|
static AllUsers(req: AllUsersRequest, initReq?: fm.InitReq): Promise<AllUsersResponse> {
|
|
return fm.fetchReq<AllUsersRequest, AllUsersResponse>(`/v1/admin/users?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
|
|
}
|
|
static UpdateUser(req: UpdateUserRequest, initReq?: fm.InitReq): Promise<User> {
|
|
return fm.fetchReq<UpdateUserRequest, User>(`/v1/users/me`, {...initReq, method: "PATCH", body: JSON.stringify(req["Body"])})
|
|
}
|
|
static AdminUpdateUser(req: AdminUpdateUserRequest, initReq?: fm.InitReq): Promise<User> {
|
|
return fm.fetchReq<AdminUpdateUserRequest, User>(`/v1/admin/users/${req["bodyEmail"]}`, {...initReq, method: "PATCH", body: JSON.stringify(req["Body"])})
|
|
}
|
|
static DeleteUser(req: DeleteUserRequest, initReq?: fm.InitReq): Promise<User> {
|
|
return fm.fetchReq<DeleteUserRequest, User>(`/v1/admin/users/${req["email"]}`, {...initReq, method: "DELETE"})
|
|
}
|
|
} |