160 lines
4.8 KiB
TypeScript
160 lines
4.8 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"
|
|
import * as GoogleProtobufEmpty from "../../../../../google/protobuf/empty.pb"
|
|
import * as GoogleProtobufTimestamp from "../../../../../google/protobuf/timestamp.pb"
|
|
export type Token = {
|
|
token?: string
|
|
expires?: GoogleProtobufTimestamp.Timestamp
|
|
}
|
|
|
|
export type OAuthCodeRequest = {
|
|
}
|
|
|
|
export type OAuthCodeResponse = {
|
|
redirectURI?: string
|
|
}
|
|
|
|
export type TokenRequest = {
|
|
code?: string
|
|
state?: string
|
|
}
|
|
|
|
export type DeleteTokenRequest = {
|
|
all?: boolean
|
|
token?: Token
|
|
}
|
|
|
|
export type User = {
|
|
id?: string
|
|
name?: string
|
|
email?: string
|
|
picture?: string
|
|
admin?: boolean
|
|
createdAt?: GoogleProtobufTimestamp.Timestamp
|
|
}
|
|
|
|
export type PartData = {
|
|
completed?: boolean
|
|
pointsWorth?: number
|
|
}
|
|
|
|
export type Question = {
|
|
id?: string
|
|
title?: string
|
|
text?: string
|
|
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
|
|
part?: number
|
|
code?: string
|
|
}
|
|
|
|
export type SubmitRequest = {
|
|
id?: string
|
|
body?: SubmitRequestData
|
|
}
|
|
|
|
export type SubmitResponse = {
|
|
correct?: boolean
|
|
points?: number
|
|
}
|
|
|
|
export type UpdateFields = {
|
|
name?: string
|
|
gradeLevel?: number
|
|
admin?: boolean
|
|
}
|
|
|
|
export type UserRequest = {
|
|
}
|
|
|
|
export type AllUsersRequest = {
|
|
}
|
|
|
|
export type UpdateUserRequest = {
|
|
email?: string
|
|
body?: UpdateFields
|
|
}
|
|
|
|
export type UserByEmailRequest = {
|
|
email?: string
|
|
}
|
|
|
|
export type DeleteUserRequest = {
|
|
email?: string
|
|
}
|
|
|
|
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<GoogleProtobufEmpty.Empty> {
|
|
return fm.fetchReq<DeleteTokenRequest, GoogleProtobufEmpty.Empty>(`/v1/auth/token`, {...initReq, method: "DELETE"})
|
|
}
|
|
}
|
|
export class QuestService {
|
|
static Questions(req: GoogleProtobufEmpty.Empty, initReq?: fm.InitReq): Promise<QuestionsResponse> {
|
|
return fm.fetchReq<GoogleProtobufEmpty.Empty, 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"]}`, {...initReq, method: "POST", body: JSON.stringify(req["Body"])})
|
|
}
|
|
}
|
|
export class UserService {
|
|
static User(req: UserRequest, initReq?: fm.InitReq): Promise<User> {
|
|
return fm.fetchReq<UserRequest, User>(`/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: "PUT", body: JSON.stringify(req["Body"])})
|
|
}
|
|
static AdminUpdateUser(req: UpdateUserRequest, initReq?: fm.InitReq): Promise<User> {
|
|
return fm.fetchReq<UpdateUserRequest, User>(`/v1/admin/users/${req["email"]}`, {...initReq, method: "PUT", 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"})
|
|
}
|
|
} |