diff --git a/.env.example b/.env.example index 16ea642..c322157 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,5 @@ -NODE_ENV=development -TRIBUFU_API_KEY= -TRIBUFU_API_URL= -TRIBUFU_BOT_TOKEN= -TRIBUFU_CLIENT_ID= -TRIBUFU_CLIENT_SECRET= -TRIBUFU_SERVER_ID= \ No newline at end of file +NODE_ENV="development" +TRIBUFU_API_KEY="" +TRIBUFU_API_URL="https://api.tribufu.com" +TRIBUFU_CLIENT_ID="" +TRIBUFU_CLIENT_SECRET="" \ No newline at end of file diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore new file mode 100644 index 0000000..a45dd5e --- /dev/null +++ b/.openapi-generator-ignore @@ -0,0 +1,8 @@ +docs/ + +.gitignore +.npmignore +git_push.sh +package.json +README.md +src/index.ts diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100644 index 0000000..aebd5c0 --- /dev/null +++ b/.openapi-generator/FILES @@ -0,0 +1,49 @@ +package.json +src/apis/TribufuGeneratedApi.ts +src/apis/index.ts +src/index.ts +src/models/Account.ts +src/models/Application.ts +src/models/ApplicationType.ts +src/models/AuthorizeRequest.ts +src/models/CodeChallengeMethod.ts +src/models/CryptoViewModel.ts +src/models/Game.ts +src/models/GameServer.ts +src/models/GameServerCluster.ts +src/models/GrantType.ts +src/models/Group.ts +src/models/GroupGame.ts +src/models/GroupMember.ts +src/models/GroupRank.ts +src/models/HashViewModel.ts +src/models/IntrospectRequest.ts +src/models/IpAddress.ts +src/models/LeaderboardItem.ts +src/models/LeaderboardOrder.ts +src/models/LoginProvider.ts +src/models/LoginRequest.ts +src/models/LoginResponse.ts +src/models/Package.ts +src/models/Profile.ts +src/models/ProfileGame.ts +src/models/ProfileGroup.ts +src/models/RefreshRequest.ts +src/models/RegisterRequest.ts +src/models/ResponseType.ts +src/models/RevokeRequest.ts +src/models/SearchRequest.ts +src/models/SearchType.ts +src/models/ServerMetrics.ts +src/models/ServerStatus.ts +src/models/Subscription.ts +src/models/TokenHintType.ts +src/models/TokenRequest.ts +src/models/TokenResponse.ts +src/models/TokenType.ts +src/models/UpdateProfile.ts +src/models/UserInfo.ts +src/models/UserType.ts +src/models/index.ts +src/runtime.ts +tsconfig.json diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100644 index 0000000..5f84a81 --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.12.0 diff --git a/package.json b/package.json index 23f215f..677bb9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tribufu", - "version": "1.0.2", + "version": "1.1.0", "description": "Tribufu JS SDK", "repository": "https://github.com/Tribufu/TribufuJs", "author": "Tribufu ", diff --git a/scripts/generate.ps1 b/scripts/generate.ps1 new file mode 100644 index 0000000..900ec0d --- /dev/null +++ b/scripts/generate.ps1 @@ -0,0 +1,10 @@ +#!/usr/bin/env pwsh + +java -jar ./vendor/openapi-generator/openapi-generator-cli.jar generate ` + -i https://api.tribufu.com/openapi.json ` + -g typescript-fetch ` + -o . ` + --global-property apis,models,supportingFiles,apiDocs=false,modelDocs=false,apiTests=false,modelTests=false ` + --additional-properties=modelPackage=models,apiPackage=api,npmName=tribufu,prettier=true,sourceFolder=src,useSingleRequestParameter=false ` + --openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=TribufuGenerated ` + --skip-validate-spec diff --git a/scripts/nswag.ps1 b/scripts/nswag.ps1 deleted file mode 100644 index ad9ee6b..0000000 --- a/scripts/nswag.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -nswag run ./src/api/api.nswag diff --git a/src/api/api.nswag b/src/api/api.nswag deleted file mode 100644 index ae00327..0000000 --- a/src/api/api.nswag +++ /dev/null @@ -1,74 +0,0 @@ -{ - "runtime": "Default", - "defaultVariables": null, - "documentGenerator": { - "fromDocument": { - "json": "", - "url": "http://localhost:5000/openapi.json", - "output": null, - "newLineBehavior": "Auto" - } - }, - "codeGenerators": { - "openApiToTypeScriptClient": { - "className": "TribufuApiGenerated", - "moduleName": "", - "namespace": "", - "typeScriptVersion": 4.3, - "template": "Fetch", - "promiseType": "Promise", - "httpClass": "HttpClient", - "withCredentials": false, - "useSingletonProvider": false, - "injectionTokenType": "OpaqueToken", - "rxJsVersion": 6, - "dateTimeType": "String", - "nullValue": "Null", - "generateClientClasses": true, - "generateClientInterfaces": false, - "generateOptionalParameters": true, - "exportTypes": true, - "wrapDtoExceptions": false, - "exceptionClass": "TribufuApiError", - "clientBaseClass": "TribufuApiBase", - "wrapResponses": false, - "wrapResponseMethods": [], - "generateResponseClasses": true, - "responseClass": "SwaggerResponse", - "protectedMethods": [], - "configurationClass": null, - "useTransformOptionsMethod": true, - "useTransformResultMethod": false, - "generateDtoTypes": true, - "operationGenerationMode": "SingleClientFromOperationId", - "markOptionalProperties": false, - "generateCloneMethod": false, - "typeStyle": "Interface", - "enumStyle": "Enum", - "useLeafType": false, - "classTypes": [], - "extendedClasses": [], - "extensionCode": "include.ts", - "generateDefaultValues": true, - "excludedTypeNames": [], - "excludedParameterNames": [], - "handleReferences": false, - "generateTypeCheckFunctions": false, - "generateConstructorInterface": true, - "convertConstructorInterfaceData": false, - "importRequiredTypes": true, - "useGetBaseUrlMethod": false, - "baseUrlTokenName": "API_BASE_URL", - "queryNullValue": "", - "useAbortSignal": false, - "inlineNamedDictionaries": false, - "inlineNamedAny": false, - "includeHttpContext": false, - "templateDirectory": null, - "serviceHost": null, - "serviceSchemes": null, - "output": "generated.ts", - "newLineBehavior": "LF" - } - } -} diff --git a/src/api/base.ts b/src/api/base.ts deleted file mode 100644 index 730eb4c..0000000 --- a/src/api/base.ts +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: UNLICENSED - -import { HttpHeaders } from "../http/headers"; -import { JavaScriptRuntime } from "../node"; -import { TRIBUFU_VERSION } from ".."; - -export abstract class TribufuApiBase { - protected apiKey: string | null = null; - - /** - * Check if debug mode is enabled. - * - * - Debug mode is enabled if the environment variable `NODE_ENV` is set to `development`. - * - Debug mode is disabled by default. - * - Debug mode is disabled in the browser. - * - * @returns boolean - */ - public static debugEnabled(): boolean { - if (typeof process !== "undefined") { - return process.env.NODE_ENV === "development"; - } - - return false; - } - - /** - * Detect the current JavaScript runtime. - * - * - This is used to determine if the code is running in a browser or in Node.js. - * - * @returns JavaScriptRuntime - */ - public static detectRuntime(): JavaScriptRuntime { - if (typeof window !== "undefined") { - return JavaScriptRuntime.Browser; - } - - if (typeof process !== "undefined" && process?.versions?.node) { - return JavaScriptRuntime.Node; - } - - return JavaScriptRuntime.Other; - } - - /** - * Check if the current JavaScript runtime is a browser. - * @returns boolean - */ - public static isBrowser(): boolean { - return TribufuApiBase.detectRuntime() === JavaScriptRuntime.Browser; - } - - /** - * Check if the current JavaScript runtime is Node.js. - * @returns boolean - */ - public static isNode(): boolean { - return TribufuApiBase.detectRuntime() === JavaScriptRuntime.Node; - } - - /** - * Get the default headers for the Tribufu API. - * @returns HeaderMap - */ - protected static defaultHeaders(): HttpHeaders { - const headers = {}; - headers["X-Tribufu-Library"] = "javascript"; - headers["X-Tribufu-Version"] = TRIBUFU_VERSION; - return headers; - } - - /** - * Get current headers with the api key or access token. - * @returns HeaderMap - */ - protected getHeaders(): HttpHeaders { - let headers = TribufuApiBase.defaultHeaders(); - - if (this.apiKey) { - headers["Authorization"] = `ApiKey ${this.apiKey}`; - return headers; - } - - return headers; - } - - /** - * Transform the options before sending the request. - * @param options - * @returns - */ - protected transformOptions(options: RequestInit) { - options.headers = { - ...options.headers, - ...this.getHeaders(), - }; - - return Promise.resolve(options); - } -} diff --git a/src/api/generated.ts b/src/api/generated.ts deleted file mode 100644 index 5cfe8f3..0000000 --- a/src/api/generated.ts +++ /dev/null @@ -1,3099 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) -// -//---------------------- - -/* tslint:disable */ -/* eslint-disable */ -// ReSharper disable InconsistentNaming - -import { TribufuApiBase } from "./base"; - -export class TribufuApiGenerated extends TribufuApiBase { - private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; - private baseUrl: string; - protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; - - constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { - super(); - this.http = http ? http : window as any; - this.baseUrl = baseUrl ?? ""; - } - - /** - * Get current user information. - * @return OK - */ - getUserInfo(): Promise { - let url_ = this.baseUrl + "/v1/me"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserInfo(_response); - }); - } - - protected processGetUserInfo(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as UserInfo; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Login with name or email and password. - * @param body (optional) - * @return OK - */ - login(body?: LoginRequest | undefined): Promise { - let url_ = this.baseUrl + "/v1/login"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processLogin(_response); - }); - } - - protected processLogin(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as LoginResponse; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Create a new user. - * @param body (optional) - * @return OK - */ - register(body?: RegisterRequest | undefined): Promise { - let url_ = this.baseUrl + "/v1/register"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processRegister(_response); - }); - } - - protected processRegister(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as LoginResponse; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Refresh credentials. - * @param body (optional) - * @return OK - */ - refresh(body?: RefreshRequest | undefined): Promise { - let url_ = this.baseUrl + "/v1/refresh"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processRefresh(_response); - }); - } - - protected processRefresh(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as LoginResponse; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Invalidate credentials. - * @return OK - */ - logout(): Promise { - let url_ = this.baseUrl + "/v1/logout"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "POST", - headers: { - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processLogout(_response); - }); - } - - protected processLogout(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of game server clusters. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getClusters(page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/clusters?"; - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetClusters(_response); - }); - } - - protected processGetClusters(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServerCluster[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Create a new game server cluster. - * @param body (optional) - * @return OK - */ - createCluster(body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/clusters"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processCreateCluster(_response); - }); - } - - protected processCreateCluster(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a game server cluster by id. - * @return OK - */ - getClusterGetById(id: string): Promise { - let url_ = this.baseUrl + "/v1/clusters/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetClusterGetById(_response); - }); - } - - protected processGetClusterGetById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServerCluster; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Update a game server cluster. - * @param body (optional) - * @return OK - */ - updateCluster(id: string, body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/clusters/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processUpdateCluster(_response); - }); - } - - protected processUpdateCluster(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Delete a game server cluster. - * @return OK - */ - deleteCluster(id: string): Promise { - let url_ = this.baseUrl + "/v1/clusters/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "DELETE", - headers: { - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processDeleteCluster(_response); - }); - } - - protected processDeleteCluster(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of games. - * @return OK - */ - getGames(): Promise { - let url_ = this.baseUrl + "/v1/games"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGames(_response); - }); - } - - protected processGetGames(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Game[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a game by id. - * @return OK - */ - getGameById(id: string): Promise { - let url_ = this.baseUrl + "/v1/games/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGameById(_response); - }); - } - - protected processGetGameById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Game; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of game servers of a game. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getGameServers(id: string, page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/games/{id}/servers?"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGameServers(_response); - }); - } - - protected processGetGameServers(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServer[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of game server clusters of a game. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getGameClusters(id: string, page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/games/{id}/clusters?"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGameClusters(_response); - }); - } - - protected processGetGameClusters(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServerCluster[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of game items. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getGameItems(id: string, page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/games/{id}/items?"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGameItems(_response); - }); - } - - protected processGetGameItems(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as any[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of groups. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getGroups(page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/groups?"; - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGroups(_response); - }); - } - - protected processGetGroups(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Group[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Create a new group. - * @param body (optional) - * @return OK - */ - createGroup(body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/groups"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processCreateGroup(_response); - }); - } - - protected processCreateGroup(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a group by id. - * @return OK - */ - getGroupById(id: string): Promise { - let url_ = this.baseUrl + "/v1/groups/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGroupById(_response); - }); - } - - protected processGetGroupById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Group; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Update a group. - * @param body (optional) - * @return OK - */ - updateGroup(id: string, body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/groups/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processUpdateGroup(_response); - }); - } - - protected processUpdateGroup(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Delete a group. - * @return OK - */ - deleteGroup(id: string): Promise { - let url_ = this.baseUrl + "/v1/groups/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "DELETE", - headers: { - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processDeleteGroup(_response); - }); - } - - protected processDeleteGroup(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a group by uuid. - * @return OK - */ - getGroupByUuid(uuid: string): Promise { - let url_ = this.baseUrl + "/v1/groups/uuid/{uuid}"; - if (uuid === undefined || uuid === null) - throw new Error("The parameter 'uuid' must be defined."); - url_ = url_.replace("{uuid}", encodeURIComponent("" + uuid)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGroupByUuid(_response); - }); - } - - protected processGetGroupByUuid(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Group; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a group by tag. - * @return OK - */ - getGroupByTag(tag: string): Promise { - let url_ = this.baseUrl + "/v1/groups/tag/{tag}"; - if (tag === undefined || tag === null) - throw new Error("The parameter 'tag' must be defined."); - url_ = url_.replace("{tag}", encodeURIComponent("" + tag)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGroupByTag(_response); - }); - } - - protected processGetGroupByTag(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Group; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of members in a group. - * @return OK - */ - getGroupMembers(id: string): Promise { - let url_ = this.baseUrl + "/v1/groups/{id}/members"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGroupMembers(_response); - }); - } - - protected processGetGroupMembers(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GroupMember[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of games of a group. - * @return OK - */ - getGroupGames(id: string): Promise { - let url_ = this.baseUrl + "/v1/groups/{id}/games"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetGroupGames(_response); - }); - } - - protected processGetGroupGames(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GroupGame[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get the top 20 leaderboard users. - * @param order (optional) - * @return OK - */ - getLeaderboard(order?: LeaderboardOrder | undefined): Promise { - let url_ = this.baseUrl + "/v1/leaderboard?"; - if (order === null) - throw new Error("The parameter 'order' cannot be null."); - else if (order !== undefined) - url_ += "Order=" + encodeURIComponent("" + order) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetLeaderboard(_response); - }); - } - - protected processGetLeaderboard(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as LeaderboardItem[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of packages. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getPackages(page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/packages?"; - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetPackages(_response); - }); - } - - protected processGetPackages(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Package[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a package by id. - * @return OK - */ - getPackageById(id: string): Promise { - let url_ = this.baseUrl + "/v1/packages/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetPackageById(_response); - }); - } - - protected processGetPackageById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Package; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Advanced search for servers or players. - * @param body (optional) - * @return OK - */ - search(body?: SearchRequest | undefined): Promise { - let url_ = this.baseUrl + "/v1/search"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processSearch(_response); - }); - } - - protected processSearch(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as any[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of game servers. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getServers(page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/servers?"; - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetServers(_response); - }); - } - - protected processGetServers(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServer[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Create a new game server. - * @param body (optional) - * @return OK - */ - createServer(body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/servers"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processCreateServer(_response); - }); - } - - protected processCreateServer(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a game server by id. - * @return OK - */ - getServerById(id: string): Promise { - let url_ = this.baseUrl + "/v1/servers/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetServerById(_response); - }); - } - - protected processGetServerById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServer; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Update a game server. - * @param body (optional) - * @return OK - */ - updateServer(id: string, body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/servers/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processUpdateServer(_response); - }); - } - - protected processUpdateServer(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Delete a game server. - * @return OK - */ - deleteServer(id: string): Promise { - let url_ = this.baseUrl + "/v1/servers/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "DELETE", - headers: { - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processDeleteServer(_response); - }); - } - - protected processDeleteServer(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a game server by address and query port. - * @return OK - */ - getServerByAddressAndQueryPort(address: string, port: number): Promise { - let url_ = this.baseUrl + "/v1/servers/address/{address}:{port}"; - if (address === undefined || address === null) - throw new Error("The parameter 'address' must be defined."); - url_ = url_.replace("{address}", encodeURIComponent("" + address)); - if (port === undefined || port === null) - throw new Error("The parameter 'port' must be defined."); - url_ = url_.replace("{port}", encodeURIComponent("" + port)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetServerByAddressAndQueryPort(_response); - }); - } - - protected processGetServerByAddressAndQueryPort(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServer; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of game servers from a country. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getServersByCountry(country: string, page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/servers/country/{country}?"; - if (country === undefined || country === null) - throw new Error("The parameter 'country' must be defined."); - url_ = url_.replace("{country}", encodeURIComponent("" + country)); - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetServersByCountry(_response); - }); - } - - protected processGetServersByCountry(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServer[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Claim a game server. - * @param body (optional) - * @return OK - */ - claimServer(id: string, body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/servers/{id}/claim"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processClaimServer(_response); - }); - } - - protected processClaimServer(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get metrics about the tracked game servers. - * @return OK - */ - getServersMetrics(): Promise { - let url_ = this.baseUrl + "/v1/servers/metrics"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetServersMetrics(_response); - }); - } - - protected processGetServersMetrics(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as ServerMetrics; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of countries with the number of game servers. - * @return OK - */ - getServersCountries(): Promise<{ [key: string]: number; }> { - let url_ = this.baseUrl + "/v1/servers/countries"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetServersCountries(_response); - }); - } - - protected processGetServersCountries(response: Response): Promise<{ [key: string]: number; }> { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as { [key: string]: number; }; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve<{ [key: string]: number; }>(null as any); - } - - /** - * Get a list of subscriptions. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getSubscriptions(page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/subscriptions?"; - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetSubscriptions(_response); - }); - } - - protected processGetSubscriptions(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Subscription[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a subscription by id. - * @return OK - */ - getSubscriptionById(id: string): Promise { - let url_ = this.baseUrl + "/v1/subscriptions/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetSubscriptionById(_response); - }); - } - - protected processGetSubscriptionById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Subscription; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of user profiles. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getUsers(page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/users?"; - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUsers(_response); - }); - } - - protected processGetUsers(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Profile[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a user profile by id. - * @return OK - */ - getUserById(id: string): Promise { - let url_ = this.baseUrl + "/v1/users/{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserById(_response); - }); - } - - protected processGetUserById(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Profile; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a user profile by uuid. - * @return OK - */ - getUserByUuid(uuid: string): Promise { - let url_ = this.baseUrl + "/v1/users/uuid/{uuid}"; - if (uuid === undefined || uuid === null) - throw new Error("The parameter 'uuid' must be defined."); - url_ = url_.replace("{uuid}", encodeURIComponent("" + uuid)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserByUuid(_response); - }); - } - - protected processGetUserByUuid(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Profile; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a user profile by name. - * @return OK - */ - getUserByName(name: string): Promise { - let url_ = this.baseUrl + "/v1/users/name/{name}"; - if (name === undefined || name === null) - throw new Error("The parameter 'name' must be defined."); - url_ = url_.replace("{name}", encodeURIComponent("" + name)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserByName(_response); - }); - } - - protected processGetUserByName(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Profile; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of groups the user is a member of. - * @return OK - */ - getUserGroups(id: string): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/groups"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserGroups(_response); - }); - } - - protected processGetUserGroups(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as ProfileGroup[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of games the user has played. - * @return OK - */ - getUserGames(id: string): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/games"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserGames(_response); - }); - } - - protected processGetUserGames(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as ProfileGame[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of friends of the user. - * @return OK - */ - getUserFriends(id: string): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/friends"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserFriends(_response); - }); - } - - protected processGetUserFriends(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as any[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of servers the user is owner of. - * @param page (optional) - * @param limit (optional) - * @return OK - */ - getUserServers(id: string, page?: number | undefined, limit?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/servers?"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - if (page === null) - throw new Error("The parameter 'page' cannot be null."); - else if (page !== undefined) - url_ += "page=" + encodeURIComponent("" + page) + "&"; - if (limit === null) - throw new Error("The parameter 'limit' cannot be null."); - else if (limit !== undefined) - url_ += "limit=" + encodeURIComponent("" + limit) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserServers(_response); - }); - } - - protected processGetUserServers(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as GameServer[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of connected accounts of the user. - * @return OK - */ - getUserAccounts(id: string): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/accounts"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserAccounts(_response); - }); - } - - protected processGetUserAccounts(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Account[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Get a list of punishments the user has received. - * @return OK - */ - getUserPunishments(id: string): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/punishments"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGetUserPunishments(_response); - }); - } - - protected processGetUserPunishments(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as any[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Update a user profile. - * @param body (optional) - * @return OK - */ - updateUserProfile(id: string, body?: UpdateProfile | undefined): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/profile"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processUpdateUserProfile(_response); - }); - } - - protected processUpdateUserProfile(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Profile; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Change the email of a user. - * @param body (optional) - * @return OK - */ - changeEmail(id: string, body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/email"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processChangeEmail(_response); - }); - } - - protected processChangeEmail(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Change the password of a user. - * @param body (optional) - * @return OK - */ - changePassword(id: string, body?: any | undefined): Promise { - let url_ = this.baseUrl + "/v1/users/{id}/password"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "PUT", - headers: { - "Content-Type": "application/json-patch+json", - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processChangePassword(_response); - }); - } - - protected processChangePassword(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - return; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Generate a random password. - * @param length (optional) - * @param symbols (optional) - * @return OK - */ - generatePassword(length?: number | undefined, symbols?: boolean | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/password?"; - if (length === null) - throw new Error("The parameter 'length' cannot be null."); - else if (length !== undefined) - url_ += "length=" + encodeURIComponent("" + length) + "&"; - if (symbols === null) - throw new Error("The parameter 'symbols' cannot be null."); - else if (symbols !== undefined) - url_ += "symbols=" + encodeURIComponent("" + symbols) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGeneratePassword(_response); - }); - } - - protected processGeneratePassword(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as HashViewModel; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Generate one or more flake ids. - * @param amount (optional) - * @return OK - */ - generateFlakeId(amount?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/flake?"; - if (amount === null) - throw new Error("The parameter 'amount' cannot be null."); - else if (amount !== undefined) - url_ += "amount=" + encodeURIComponent("" + amount) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGenerateFlakeId(_response); - }); - } - - protected processGenerateFlakeId(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as string[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Generate one or more uuids with a specific version. - * @param version (optional) - * @param amount (optional) - * @return OK - */ - generateUuid(version?: number | undefined, amount?: number | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/uuid?"; - if (version === null) - throw new Error("The parameter 'version' cannot be null."); - else if (version !== undefined) - url_ += "version=" + encodeURIComponent("" + version) + "&"; - if (amount === null) - throw new Error("The parameter 'amount' cannot be null."); - else if (amount !== undefined) - url_ += "amount=" + encodeURIComponent("" + amount) + "&"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processGenerateUuid(_response); - }); - } - - protected processGenerateUuid(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as string[]; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Convert a string to base64 or vice versa. - * @param body (optional) - * @return OK - */ - convertBase64(body?: CryptoViewModel | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/base64"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processConvertBase64(_response); - }); - } - - protected processConvertBase64(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as CryptoViewModel; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Hash a string using md5. - * @param body (optional) - * @return OK - */ - hashMd5(body?: HashViewModel | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/md5"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processHashMd5(_response); - }); - } - - protected processHashMd5(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as HashViewModel; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Hash a string using sha256. - * @param body (optional) - * @return OK - */ - hashSha256(body?: HashViewModel | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/sha256"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processHashSha256(_response); - }); - } - - protected processHashSha256(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as HashViewModel; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Hash a string using bcrypt. - * @param body (optional) - * @return OK - */ - hashBcrypt(body?: HashViewModel | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/bcrypt"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processHashBcrypt(_response); - }); - } - - protected processHashBcrypt(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as HashViewModel; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - /** - * Hash a string using argon2. - * @param body (optional) - * @return OK - */ - hashArgon2(body?: HashViewModel | undefined): Promise { - let url_ = this.baseUrl + "/v1/utils/argon2"; - url_ = url_.replace(/[?&]$/, ""); - - const content_ = JSON.stringify(body); - - let options_: RequestInit = { - body: content_, - method: "POST", - headers: { - "Content-Type": "application/json-patch+json", - "Accept": "text/plain" - } - }; - - return this.transformOptions(options_).then(transformedOptions_ => { - return this.http.fetch(url_, transformedOptions_); - }).then((_response: Response) => { - return this.processHashArgon2(_response); - }); - } - - protected processHashArgon2(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as HashViewModel; - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } -} - -export interface Account { - id: string | null; - name: string | null; - provider: LoginProvider; - user_id: string; - authorized: boolean; - fields: any | null; - created: string; - updated: string | null; -} - -export interface Application { - id: string; - name: string | null; - description: string | null; - type: ApplicationType; - organization_id: string | null; - icon_url: string | null; - banner_url: string | null; - capsule_image_url: string | null; - library_image_url: string | null; - parent_id: string | null; - slug: string | null; - visibility: number; - password: string | null; - primary: number; - user_count: number; - achievement_count: number; - badge_count: number | null; - download_count: number; - created: string; - updated: string | null; -} - -export enum ApplicationType { - Application = "application", - Game = "game", -} - -export interface CryptoViewModel { - encoded: string | null; - decoded: string | null; -} - -export interface Game { - game_port: number | null; - query_port: number | null; - rcon_port: number | null; - server_count: number; - steam_app_id: number | null; - steam_server_app_id: number | null; - enable_servers: boolean; - rust_gamedig_id: string | null; - node_gamedig_id: string | null; - server_connect_url: string | null; - server_tags: string | null; - id: string; - name: string | null; - description: string | null; - type: ApplicationType; - organization_id: string | null; - icon_url: string | null; - banner_url: string | null; - capsule_image_url: string | null; - library_image_url: string | null; - parent_id: string | null; - slug: string | null; - visibility: number; - password: string | null; - primary: number; - user_count: number; - achievement_count: number; - badge_count: number | null; - download_count: number; - created: string; - updated: string | null; -} - -export interface GameServer { - id: string; - name: string | null; - description: string | null; - address: string | null; - game_port: number | null; - query_port: number; - game_id: string; - game_icon_url: string | null; - version: string | null; - featured: number; - cluster_id: string | null; - website_url: string | null; - banner_url: string | null; - owner_id: string | null; - uptime: number; - status: ServerStatus; - ping: number | null; - map: string | null; - used_slots: number | null; - max_slots: number | null; - motd: string | null; - players: string | null; - last_online: string | null; - country: string | null; - steam: number; - discord_server_id: string | null; - youtube_video_url: string | null; - tags: string | null; - comment_count: number; - created: string; - updated: string | null; -} - -export interface GameServerCluster { - id: string; - name: string | null; - description: string | null; - game_id: string; - website_url: string | null; - banner_url: string | null; - owner_id: string; - discord_server_id: string | null; - youtube_video_url: string | null; - tags: string | null; - comment_count: number; - server_count: number; - created: string; - updated: string | null; -} - -export interface Group { - id: string; - uuid: string; - name: string | null; - tag: string | null; - description: string | null; - type: number; - privacy: number; - owner_id: string; - verified: boolean; - photo_url: string | null; - banner_url: string | null; - member_count: number; - follower_count: number; - view_count: number; - created: string; - updated: string | null; -} - -export interface GroupGame { - group_id: string; - application_id: string; - application: Application; - stats: any | null; - acquired: string; - last_used: string | null; - group: Group; -} - -export interface GroupMember { - id: string; - uuid: string; - name: string | null; - display_name: string | null; - verified: boolean; - photo_url: string | null; - last_online: string | null; - rank: GroupRank; - since: string; -} - -export enum GroupRank { - Member = "member", - Leader = "leader", - Owner = "owner", -} - -export interface HashViewModel { - value: string | null; -} - -export interface LeaderboardItem { - name: string | null; - display_name: string | null; - photo_url: string | null; - level: number; - experience: number; - points: number; -} - -export enum LeaderboardOrder { - Level = "level", - Points = "points", -} - -export enum LoginProvider { - Steam = "steam", - Epic = "epic", - Discord = "discord", - Microsoft = "microsoft", - Playstation = "playstation", - Google = "google", - Apple = "apple", -} - -export interface LoginRequest { - login: string | null; - password: string | null; -} - -export interface LoginResponse { - user: UserInfo; - access_token: string | null; - refresh_token: string | null; - expires_in: number; -} - -export interface Package { - id: string; - name: string | null; - description: string | null; - image_url: string | null; - author_id: string; - version: string | null; - file_url: string | null; - raw_size: number; - download_count: number; - last_download: string | null; - created: string; - updated: string | null; -} - -export interface Profile { - id: string; - uuid: string; - name: string | null; - display_name: string | null; - flags: string; - verified: boolean; - level: number; - experience: number; - public_birthday: boolean; - birthday: string | null; - points: number; - location: string | null; - photo_url: string | null; - banner_url: string | null; - last_online: string | null; - biography: string | null; - view_count: number; - created: string; - updated: string | null; -} - -export interface ProfileGame { - id: string; - name: string | null; - capsule_image_url: string | null; - library_image_url: string | null; - slug: string | null; - time_used: number; - unlocked_achievements: number; - total_achievements: number; - stats: any | null; - acquired: string; - last_used: string | null; -} - -export interface ProfileGroup { - id: string; - uuid: string; - name: string | null; - tag: string | null; - privacy: number; - verified: boolean; - photo_url: string | null; - member_count: number; - rank: GroupRank; - since: string; -} - -export interface RefreshRequest { - refresh_token: string | null; -} - -export interface RegisterRequest { - uuid: string | null; - name: string; - email: string | null; - password: string; -} - -export interface SearchRequest { - type: SearchType; - query: string | null; - page: number | null; - game_id: string | null; -} - -export enum SearchType { - User = "user", - Group = "group", - Server = "server", - Cluster = "cluster", -} - -export interface ServerMetrics { - server_count: number; - package_count: number; - country_count: number; -} - -export enum ServerStatus { - Unknown = "unknown", - Offline = "offline", - Online = "online", -} - -export interface Subscription { - id: string; - name: string | null; - description: string | null; - image_url: string | null; - readonly prices: { [key: string]: number; } | null; - created: string; - updated: string | null; -} - -export interface UpdateProfile { - display_name: string | null; - biography: string | null; -} - -export interface UserInfo { - id: string; - uuid: string; - name: string | null; - display_name: string | null; - email: string | null; - type: UserType; - flags: string; - permissions: string; - verified: boolean; - level: number; - experience: number; - public_birthday: boolean; - birthday: string | null; - points: number; - location: string | null; - language: string | null; - timezone: string | null; - currency: string | null; - photo_url: string | null; - banner_url: string | null; - last_online: string | null; - biography: string | null; - view_count: number; - created: string; - updated: string | null; -} - -export enum UserType { - User = "user", - Bot = "bot", -} - -export class TribufuApiError extends Error { - override message: string; - status: number; - response: string; - headers: { [key: string]: any; }; - result: any; - - constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) { - super(); - - this.message = message; - this.status = status; - this.response = response; - this.headers = headers; - this.result = result; - } - - protected isTribufuApiError = true; - - static isTribufuApiError(obj: any): obj is TribufuApiError { - return obj.isTribufuApiError === true; - } -} - -function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any { - if (result !== null && result !== undefined) - throw result; - else - throw new TribufuApiError(message, status, response, headers, null); -} \ No newline at end of file diff --git a/src/api/include.ts b/src/api/include.ts deleted file mode 100644 index 041f835..0000000 --- a/src/api/include.ts +++ /dev/null @@ -1 +0,0 @@ -import { TribufuApiBase } from "./base"; diff --git a/src/api/index.ts b/src/api/index.ts deleted file mode 100644 index 57186c9..0000000 --- a/src/api/index.ts +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -import { TRIBUFU_API_URL } from ".."; -import { TribufuApiBase } from "./base"; -import { TribufuApiGenerated } from "./generated"; -import { TribufuApiOptions } from "../options"; - -/** - * **Tribufu API** - * - * Use this class to interact with the Tribufu API. - */ -export class TribufuApi extends TribufuApiGenerated { - constructor(options?: TribufuApiOptions | null) { - const baseUrl = options?.baseUrl || TribufuApi.getBaseUrl(); - const http = options?.fetch ? { fetch: options.fetch } : { fetch }; - super(baseUrl, http); - this.apiKey = options?.apiKey || null; - } - - /** - * Create a TribufuApi with the default options. - * @returns - */ - public static default(): TribufuApi { - return new TribufuApi(); - } - - /** - * Create a TribufuApi with the given api key. - * - * - A api key give you public read only access to the Tribufu API. - * - * @param apiKey - * @returns TribufuApi - */ - public static withApiKey(apiKey: string): TribufuApi { - return new TribufuApi({ apiKey }); - } - - /** - * Try to create a TribufuApi from environment variables. - * - * - This will only work if the environment variables are set. - * - * @param prefix A prefix for the environment variables. Default is `TRIBUFU`. - * @returns TribufuApi | null - * @example - * ```ts - * // process.env.TRIBUFU_API_KEY - * const api = TribufuApi.fromEnv(); - * ``` - */ - public static fromEnv(prefix?: string | null): TribufuApi | null { - if (typeof process === "undefined") { - return null; - } - - const apiKey = process.env[`${prefix || "TRIBUFU"}_API_KEY`]; - - if (apiKey) { - return TribufuApi.withApiKey(apiKey); - } - - return null; - } - - /** - * Create a TribufuApi from environment variables or the default api. - * - * - This will fallback to the default api if the environment variables are not set. - * - * @param prefix A prefix for the environment variables. Default is `TRIBUFU`. - * @returns TribufuApi | null - * @example - * ```ts - * // process.env.TRIBUFU_API_KEY = null - * const api = TribufuApi.fromEnvOrDefault(); - * ``` - */ - public static fromEnvOrDefault(prefix: string = ""): TribufuApi { - return TribufuApi.fromEnv(prefix) || TribufuApi.default(); - } - - /** - * Get the base url for the Tribufu API. - * - * - The base url can be set using the environment variable `TRIBUFU_API_URL`. - * - The custom base url is only used if debug mode is enabled. - * - The default base url is `https://api.tribufu.com`. - * - * @returns string - */ - protected static getBaseUrl(): string { - if (typeof process === "undefined") { - return TRIBUFU_API_URL; - } - - const baseUrl = process.env[`TRIBUFU_API_URL`] || null; - return TribufuApiBase.debugEnabled() && baseUrl ? baseUrl : TRIBUFU_API_URL; - } -} diff --git a/src/api/singletion.ts b/src/api/singletion.ts deleted file mode 100644 index 4fb1ac5..0000000 --- a/src/api/singletion.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -import { TribufuApi } from "./index"; - -/** - * **Tribufu API** - * - * Helper class to get a singleton instance of the Tribufu API. - */ -export class TribufuApiSingleton { - private static INSTANCE: TribufuApi | null = null; - - private constructor() {} - - public static getInstance(): TribufuApi { - if (!TribufuApiSingleton.INSTANCE) { - TribufuApiSingleton.INSTANCE = TribufuApi.fromEnvOrDefault(); - } - - return TribufuApiSingleton.INSTANCE; - } -} diff --git a/src/apis/TribufuGeneratedApi.ts b/src/apis/TribufuGeneratedApi.ts new file mode 100644 index 0000000..6ef375f --- /dev/null +++ b/src/apis/TribufuGeneratedApi.ts @@ -0,0 +1,3137 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import type { + Account, + AuthorizeRequest, + CryptoViewModel, + Game, + GameServer, + GameServerCluster, + Group, + GroupGame, + GroupMember, + HashViewModel, + IntrospectRequest, + IpAddress, + LeaderboardItem, + LeaderboardOrder, + LoginRequest, + LoginResponse, + Package, + Profile, + ProfileGame, + ProfileGroup, + RefreshRequest, + RegisterRequest, + RevokeRequest, + SearchRequest, + ServerMetrics, + Subscription, + TokenRequest, + TokenResponse, + UpdateProfile, + UserInfo, +} from '../models/index'; +import { + AccountFromJSON, + AccountToJSON, + AuthorizeRequestFromJSON, + AuthorizeRequestToJSON, + CryptoViewModelFromJSON, + CryptoViewModelToJSON, + GameFromJSON, + GameToJSON, + GameServerFromJSON, + GameServerToJSON, + GameServerClusterFromJSON, + GameServerClusterToJSON, + GroupFromJSON, + GroupToJSON, + GroupGameFromJSON, + GroupGameToJSON, + GroupMemberFromJSON, + GroupMemberToJSON, + HashViewModelFromJSON, + HashViewModelToJSON, + IntrospectRequestFromJSON, + IntrospectRequestToJSON, + IpAddressFromJSON, + IpAddressToJSON, + LeaderboardItemFromJSON, + LeaderboardItemToJSON, + LeaderboardOrderFromJSON, + LeaderboardOrderToJSON, + LoginRequestFromJSON, + LoginRequestToJSON, + LoginResponseFromJSON, + LoginResponseToJSON, + PackageFromJSON, + PackageToJSON, + ProfileFromJSON, + ProfileToJSON, + ProfileGameFromJSON, + ProfileGameToJSON, + ProfileGroupFromJSON, + ProfileGroupToJSON, + RefreshRequestFromJSON, + RefreshRequestToJSON, + RegisterRequestFromJSON, + RegisterRequestToJSON, + RevokeRequestFromJSON, + RevokeRequestToJSON, + SearchRequestFromJSON, + SearchRequestToJSON, + ServerMetricsFromJSON, + ServerMetricsToJSON, + SubscriptionFromJSON, + SubscriptionToJSON, + TokenRequestFromJSON, + TokenRequestToJSON, + TokenResponseFromJSON, + TokenResponseToJSON, + UpdateProfileFromJSON, + UpdateProfileToJSON, + UserInfoFromJSON, + UserInfoToJSON, +} from '../models/index'; + +export interface AuthorizeOperationRequest { + authorizeRequest?: AuthorizeRequest; +} + +export interface ChangeEmailRequest { + id: string; + body?: any | null; +} + +export interface ChangePasswordRequest { + id: string; + body?: any | null; +} + +export interface ClaimGameServerRequest { + id: string; + body?: any | null; +} + +export interface ConvertBase64Request { + cryptoViewModel?: CryptoViewModel; +} + +export interface CreateGameServerRequest { + body?: any | null; +} + +export interface CreateGameServerClusterRequest { + body?: any | null; +} + +export interface CreateGroupRequest { + body?: any | null; +} + +export interface CreateTokenRequest { + tokenRequest?: TokenRequest; +} + +export interface DeleteGameServerRequest { + id: string; +} + +export interface DeleteGameServerClusterRequest { + id: string; +} + +export interface DeleteGroupRequest { + id: string; +} + +export interface GenerateFlakeIdRequest { + amount?: number; +} + +export interface GenerateFlakeIdFromTimestampRequest { + timestamp: string; + amount?: number; +} + +export interface GeneratePasswordRequest { + length?: number; + symbols?: boolean; +} + +export interface GenerateUuidRequest { + version?: number; + amount?: number; +} + +export interface GetGameByIdRequest { + id: string; +} + +export interface GetGameClustersByGameIdRequest { + id: string; + page?: number; + limit?: number; +} + +export interface GetGameItemsRequest { + id: string; + page?: number; + limit?: number; +} + +export interface GetGameServerByAddressAndQueryPortRequest { + address: string; + port: number; +} + +export interface GetGameServerByIdRequest { + id: string; +} + +export interface GetGameServerClusterByIdRequest { + id: string; +} + +export interface GetGameServerClustersRequest { + page?: number; + limit?: number; +} + +export interface GetGameServersRequest { + page?: number; + limit?: number; +} + +export interface GetGameServersByCountryRequest { + country: string; + page?: number; + limit?: number; +} + +export interface GetGameServersByGameIdRequest { + id: string; + page?: number; + limit?: number; +} + +export interface GetGroupByIdRequest { + id: string; +} + +export interface GetGroupByTagRequest { + tag: string; +} + +export interface GetGroupByUuidRequest { + uuid: string; +} + +export interface GetGroupGamesRequest { + id: string; +} + +export interface GetGroupMembersRequest { + id: string; +} + +export interface GetGroupsRequest { + page?: number; + limit?: number; +} + +export interface GetIpAddressRequest { + address: string; +} + +export interface GetIpAddressesRequest { + page?: number; + limit?: number; +} + +export interface GetLeaderboardRequest { + order?: LeaderboardOrder; +} + +export interface GetPackageByIdRequest { + id: string; +} + +export interface GetPackagesRequest { + page?: number; + limit?: number; +} + +export interface GetSubscriptionByIdRequest { + id: string; +} + +export interface GetSubscriptionsRequest { + page?: number; + limit?: number; +} + +export interface GetUserAccountsRequest { + id: string; +} + +export interface GetUserByIdRequest { + id: string; +} + +export interface GetUserByNameRequest { + name: string; +} + +export interface GetUserByUuidRequest { + uuid: string; +} + +export interface GetUserFriendsRequest { + id: string; +} + +export interface GetUserGamesRequest { + id: string; +} + +export interface GetUserGroupsRequest { + id: string; +} + +export interface GetUserPunishmentsRequest { + id: string; +} + +export interface GetUserServersRequest { + id: string; + page?: number; + limit?: number; +} + +export interface GetUsersRequest { + page?: number; + limit?: number; +} + +export interface HashArgon2Request { + hashViewModel?: HashViewModel; +} + +export interface HashBcryptRequest { + hashViewModel?: HashViewModel; +} + +export interface HashMd5Request { + hashViewModel?: HashViewModel; +} + +export interface HashSha256Request { + hashViewModel?: HashViewModel; +} + +export interface IntrospectTokenRequest { + introspectRequest?: IntrospectRequest; +} + +export interface LoginOperationRequest { + loginRequest?: LoginRequest; +} + +export interface RefreshOperationRequest { + refreshRequest?: RefreshRequest; +} + +export interface RegisterOperationRequest { + registerRequest?: RegisterRequest; +} + +export interface RevokeTokenRequest { + revokeRequest?: RevokeRequest; +} + +export interface SearchOperationRequest { + searchRequest?: SearchRequest; +} + +export interface UpdateGameServerRequest { + id: string; + body?: any | null; +} + +export interface UpdateGameServerClusterRequest { + id: string; + body?: any | null; +} + +export interface UpdateGroupRequest { + id: string; + body?: any | null; +} + +export interface UpdateUserProfileRequest { + id: string; + updateProfile?: UpdateProfile; +} + +/** + * + */ +export class TribufuGeneratedApi extends runtime.BaseAPI { + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.authorize + * Authorize the client to access the user information. + */ + async authorizeRaw(requestParameters: AuthorizeOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/authorize`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: AuthorizeRequestToJSON(requestParameters['authorizeRequest']), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.authorize + * Authorize the client to access the user information. + */ + async authorize(authorizeRequest?: AuthorizeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.authorizeRaw({ authorizeRequest: authorizeRequest }, initOverrides); + } + + /** + * This endpoint is not available with an api key, only with a bearer token.

🔒 Required permissions: tribufu.identity.user.email.update + * Change the email of a user. + */ + async changeEmailRaw(requestParameters: ChangeEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling changeEmail().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/email`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This endpoint is not available with an api key, only with a bearer token.

🔒 Required permissions: tribufu.identity.user.email.update + * Change the email of a user. + */ + async changeEmail(id: string, body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.changeEmailRaw({ id: id, body: body }, initOverrides); + } + + /** + * This endpoint is not available with an api key, only with a bearer token.

🔒 Required permissions: tribufu.identity.user.password.update + * Change the password of a user. + */ + async changePasswordRaw(requestParameters: ChangePasswordRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling changePassword().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/password`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This endpoint is not available with an api key, only with a bearer token.

🔒 Required permissions: tribufu.identity.user.password.update + * Change the password of a user. + */ + async changePassword(id: string, body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.changePasswordRaw({ id: id, body: body }, initOverrides); + } + + /** + * This endpoint is not available with an api key, only with a bearer token.

🔒 Required permissions: tribufu.community.game.server.claim + * Claim a game server. + */ + async claimGameServerRaw(requestParameters: ClaimGameServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling claimGameServer().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/{id}/claim`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This endpoint is not available with an api key, only with a bearer token.

🔒 Required permissions: tribufu.community.game.server.claim + * Claim a game server. + */ + async claimGameServer(id: string, body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.claimGameServerRaw({ id: id, body: body }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.utils.convert.base64 + * Convert a string to base64 or vice versa. + */ + async convertBase64Raw(requestParameters: ConvertBase64Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/base64`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CryptoViewModelToJSON(requestParameters['cryptoViewModel']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CryptoViewModelFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.utils.convert.base64 + * Convert a string to base64 or vice versa. + */ + async convertBase64(cryptoViewModel?: CryptoViewModel, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.convertBase64Raw({ cryptoViewModel: cryptoViewModel }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.create + * Create a new game server. + */ + async createGameServerRaw(requestParameters: CreateGameServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.create + * Create a new game server. + */ + async createGameServer(body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.createGameServerRaw({ body: body }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.create + * Create a new game server cluster. + */ + async createGameServerClusterRaw(requestParameters: CreateGameServerClusterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/clusters`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.create + * Create a new game server cluster. + */ + async createGameServerCluster(body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.createGameServerClusterRaw({ body: body }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.group.create + * Create a new group. + */ + async createGroupRaw(requestParameters: CreateGroupRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.group.create + * Create a new group. + */ + async createGroup(body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.createGroupRaw({ body: body }, initOverrides); + } + + /** + * Create a new token with grant type. + */ + async createTokenRaw(requestParameters: CreateTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/token`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: TokenRequestToJSON(requestParameters['tokenRequest']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TokenResponseFromJSON(jsonValue)); + } + + /** + * Create a new token with grant type. + */ + async createToken(tokenRequest?: TokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createTokenRaw({ tokenRequest: tokenRequest }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.delete + * Delete a game server. + */ + async deleteGameServerRaw(requestParameters: DeleteGameServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling deleteGameServer().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.delete + * Delete a game server. + */ + async deleteGameServer(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteGameServerRaw({ id: id }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.delete + * Delete a game server cluster. + */ + async deleteGameServerClusterRaw(requestParameters: DeleteGameServerClusterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling deleteGameServerCluster().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/clusters/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.delete + * Delete a game server cluster. + */ + async deleteGameServerCluster(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteGameServerClusterRaw({ id: id }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.group.delete + * Delete a group. + */ + async deleteGroupRaw(requestParameters: DeleteGroupRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling deleteGroup().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.group.delete + * Delete a group. + */ + async deleteGroup(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteGroupRaw({ id: id }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.flake + * Generate one or more flake ids. + */ + async generateFlakeIdRaw(requestParameters: GenerateFlakeIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['amount'] != null) { + queryParameters['amount'] = requestParameters['amount']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/flake`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.flake + * Generate one or more flake ids. + */ + async generateFlakeId(amount?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.generateFlakeIdRaw({ amount: amount }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.flake.timestamp + * Generate one or more flake ids from a timestamp. + */ + async generateFlakeIdFromTimestampRaw(requestParameters: GenerateFlakeIdFromTimestampRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['timestamp'] == null) { + throw new runtime.RequiredError( + 'timestamp', + 'Required parameter "timestamp" was null or undefined when calling generateFlakeIdFromTimestamp().' + ); + } + + const queryParameters: any = {}; + + if (requestParameters['amount'] != null) { + queryParameters['amount'] = requestParameters['amount']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/flake/{timestamp}`.replace(`{${"timestamp"}}`, encodeURIComponent(String(requestParameters['timestamp']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.flake.timestamp + * Generate one or more flake ids from a timestamp. + */ + async generateFlakeIdFromTimestamp(timestamp: string, amount?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.generateFlakeIdFromTimestampRaw({ timestamp: timestamp, amount: amount }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.password + * Generate a random password. + */ + async generatePasswordRaw(requestParameters: GeneratePasswordRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + if (requestParameters['length'] != null) { + queryParameters['length'] = requestParameters['length']; + } + + if (requestParameters['symbols'] != null) { + queryParameters['symbols'] = requestParameters['symbols']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/password`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => HashViewModelFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.password + * Generate a random password. + */ + async generatePassword(length?: number, symbols?: boolean, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.generatePasswordRaw({ length: length, symbols: symbols }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.uuid + * Generate one or more uuids with a specific version. + */ + async generateUuidRaw(requestParameters: GenerateUuidRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['version'] != null) { + queryParameters['version'] = requestParameters['version']; + } + + if (requestParameters['amount'] != null) { + queryParameters['amount'] = requestParameters['amount']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/uuid`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.utils.generate.uuid + * Generate one or more uuids with a specific version. + */ + async generateUuid(version?: number, amount?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.generateUuidRaw({ version: version, amount: amount }, initOverrides); + return await response.value(); + } + + /** + * Get current client information. + */ + async getClientInfoRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/clientinfo`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Get current client information. + */ + async getClientInfo(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.getClientInfoRaw(initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.geoip.current + * Get current ip address location. + */ + async getCurrentIpAddressRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/geoip`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(IpAddressFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.geoip.current + * Get current ip address location. + */ + async getCurrentIpAddress(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getCurrentIpAddressRaw(initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.get + * Get a game by id. + */ + async getGameByIdRaw(requestParameters: GetGameByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGameById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/games/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GameFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.get + * Get a game by id. + */ + async getGameById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGameByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.list + * Get a list of game server clusters of a game. + */ + async getGameClustersByGameIdRaw(requestParameters: GetGameClustersByGameIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGameClustersByGameId().' + ); + } + + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/games/{id}/clusters`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameServerClusterFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.list + * Get a list of game server clusters of a game. + */ + async getGameClustersByGameId(id: string, page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGameClustersByGameIdRaw({ id: id, page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.item.list + * Get a list of game items. + */ + async getGameItemsRaw(requestParameters: GetGameItemsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGameItems().' + ); + } + + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/games/{id}/items`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.item.list + * Get a list of game items. + */ + async getGameItems(id: string, page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGameItemsRaw({ id: id, page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.get.address + * Get a game server by address and query port. + */ + async getGameServerByAddressAndQueryPortRaw(requestParameters: GetGameServerByAddressAndQueryPortRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['address'] == null) { + throw new runtime.RequiredError( + 'address', + 'Required parameter "address" was null or undefined when calling getGameServerByAddressAndQueryPort().' + ); + } + + if (requestParameters['port'] == null) { + throw new runtime.RequiredError( + 'port', + 'Required parameter "port" was null or undefined when calling getGameServerByAddressAndQueryPort().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/address/{address}:{port}`.replace(`{${"address"}}`, encodeURIComponent(String(requestParameters['address']))).replace(`{${"port"}}`, encodeURIComponent(String(requestParameters['port']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GameServerFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.get.address + * Get a game server by address and query port. + */ + async getGameServerByAddressAndQueryPort(address: string, port: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGameServerByAddressAndQueryPortRaw({ address: address, port: port }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.get + * Get a game server by id. + */ + async getGameServerByIdRaw(requestParameters: GetGameServerByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGameServerById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GameServerFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.get + * Get a game server by id. + */ + async getGameServerById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGameServerByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.get + * Get a game server cluster by id. + */ + async getGameServerClusterByIdRaw(requestParameters: GetGameServerClusterByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGameServerClusterById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/clusters/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GameServerClusterFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.get + * Get a game server cluster by id. + */ + async getGameServerClusterById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGameServerClusterByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.list + * Get a list of game server clusters. + */ + async getGameServerClustersRaw(requestParameters: GetGameServerClustersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/clusters`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameServerClusterFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.list + * Get a list of game server clusters. + */ + async getGameServerClusters(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGameServerClustersRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.list + * Get a list of game servers. + */ + async getGameServersRaw(requestParameters: GetGameServersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameServerFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.list + * Get a list of game servers. + */ + async getGameServers(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGameServersRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.list.country + * Get a list of game servers from a country. + */ + async getGameServersByCountryRaw(requestParameters: GetGameServersByCountryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['country'] == null) { + throw new runtime.RequiredError( + 'country', + 'Required parameter "country" was null or undefined when calling getGameServersByCountry().' + ); + } + + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/country/{country}`.replace(`{${"country"}}`, encodeURIComponent(String(requestParameters['country']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameServerFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.list.country + * Get a list of game servers from a country. + */ + async getGameServersByCountry(country: string, page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGameServersByCountryRaw({ country: country, page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.list + * Get a list of game servers of a game. + */ + async getGameServersByGameIdRaw(requestParameters: GetGameServersByGameIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGameServersByGameId().' + ); + } + + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/games/{id}/servers`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameServerFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.list + * Get a list of game servers of a game. + */ + async getGameServersByGameId(id: string, page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGameServersByGameIdRaw({ id: id, page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.country.list + * Get a list of countries with the number of game servers. + */ + async getGameServersCountriesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/countries`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.country.list + * Get a list of countries with the number of game servers. + */ + async getGameServersCountries(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{ [key: string]: number; }> { + const response = await this.getGameServersCountriesRaw(initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.metric.get + * Get metrics about the tracked game servers. + */ + async getGameServersMetricsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/metrics`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ServerMetricsFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.metric.get + * Get metrics about the tracked game servers. + */ + async getGameServersMetrics(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGameServersMetricsRaw(initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.list + * Get a list of games. + */ + async getGamesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/games`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.game.list + * Get a list of games. + */ + async getGames(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGamesRaw(initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.group.get + * Get a group by id. + */ + async getGroupByIdRaw(requestParameters: GetGroupByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGroupById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.group.get + * Get a group by id. + */ + async getGroupById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGroupByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.group.get.tag + * Get a group by tag. + */ + async getGroupByTagRaw(requestParameters: GetGroupByTagRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['tag'] == null) { + throw new runtime.RequiredError( + 'tag', + 'Required parameter "tag" was null or undefined when calling getGroupByTag().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/tag/{tag}`.replace(`{${"tag"}}`, encodeURIComponent(String(requestParameters['tag']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.group.get.tag + * Get a group by tag. + */ + async getGroupByTag(tag: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGroupByTagRaw({ tag: tag }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.group.get.uuid + * Get a group by uuid. + */ + async getGroupByUuidRaw(requestParameters: GetGroupByUuidRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['uuid'] == null) { + throw new runtime.RequiredError( + 'uuid', + 'Required parameter "uuid" was null or undefined when calling getGroupByUuid().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/uuid/{uuid}`.replace(`{${"uuid"}}`, encodeURIComponent(String(requestParameters['uuid']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.group.get.uuid + * Get a group by uuid. + */ + async getGroupByUuid(uuid: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getGroupByUuidRaw({ uuid: uuid }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.group.game.list + * Get a list of games of a group. + */ + async getGroupGamesRaw(requestParameters: GetGroupGamesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGroupGames().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/{id}/games`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GroupGameFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.group.game.list + * Get a list of games of a group. + */ + async getGroupGames(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGroupGamesRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.group.member.list + * Get a list of members in a group. + */ + async getGroupMembersRaw(requestParameters: GetGroupMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getGroupMembers().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/{id}/members`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GroupMemberFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.group.member.list + * Get a list of members in a group. + */ + async getGroupMembers(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGroupMembersRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.group.list + * Get a list of groups. + */ + async getGroupsRaw(requestParameters: GetGroupsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GroupFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.group.list + * Get a list of groups. + */ + async getGroups(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getGroupsRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.geoip.address.get + * Get a ip address location. + */ + async getIpAddressRaw(requestParameters: GetIpAddressRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['address'] == null) { + throw new runtime.RequiredError( + 'address', + 'Required parameter "address" was null or undefined when calling getIpAddress().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/geoip/addresses/{address}`.replace(`{${"address"}}`, encodeURIComponent(String(requestParameters['address']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => IpAddressFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.geoip.address.get + * Get a ip address location. + */ + async getIpAddress(address: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getIpAddressRaw({ address: address }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.geoip.address.list + * Get a list of ip addresses. + */ + async getIpAddressesRaw(requestParameters: GetIpAddressesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/geoip/addresses`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(IpAddressFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.geoip.address.list + * Get a list of ip addresses. + */ + async getIpAddresses(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getIpAddressesRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.leaderboard.get + * Get the top 20 leaderboard users. + */ + async getLeaderboardRaw(requestParameters: GetLeaderboardRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['order'] != null) { + queryParameters['Order'] = requestParameters['order']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/leaderboard`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(LeaderboardItemFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.leaderboard.get + * Get the top 20 leaderboard users. + */ + async getLeaderboard(order?: LeaderboardOrder, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getLeaderboardRaw({ order: order }, initOverrides); + return await response.value(); + } + + /** + * Get current user information. + * @deprecated + */ + async getMeRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/me`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserInfoFromJSON(jsonValue)); + } + + /** + * Get current user information. + * @deprecated + */ + async getMe(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getMeRaw(initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.package.get + * Get a package by id. + */ + async getPackageByIdRaw(requestParameters: GetPackageByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getPackageById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/packages/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => PackageFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.package.get + * Get a package by id. + */ + async getPackageById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getPackageByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.package.list + * Get a list of packages. + */ + async getPackagesRaw(requestParameters: GetPackagesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/packages`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PackageFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.package.list + * Get a list of packages. + */ + async getPackages(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getPackagesRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.client.keys + * Get the public keys for the client. + */ + async getPublicKeysRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/jwks`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.client.keys + * Get the public keys for the client. + */ + async getPublicKeys(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.getPublicKeysRaw(initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.store.subscription.get + * Get a subscription by id. + */ + async getSubscriptionByIdRaw(requestParameters: GetSubscriptionByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getSubscriptionById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/subscriptions/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => SubscriptionFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.store.subscription.get + * Get a subscription by id. + */ + async getSubscriptionById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getSubscriptionByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.store.subscription.list + * Get a list of subscriptions. + */ + async getSubscriptionsRaw(requestParameters: GetSubscriptionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/subscriptions`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(SubscriptionFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.store.subscription.list + * Get a list of subscriptions. + */ + async getSubscriptions(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getSubscriptionsRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.user.account.list + * Get a list of connected accounts of the user. + */ + async getUserAccountsRaw(requestParameters: GetUserAccountsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserAccounts().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/accounts`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(AccountFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.identity.user.account.list + * Get a list of connected accounts of the user. + */ + async getUserAccounts(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUserAccountsRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.get + * Get a user profile by id. + */ + async getUserByIdRaw(requestParameters: GetUserByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserById().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.get + * Get a user profile by id. + */ + async getUserById(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserByIdRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.get.name + * Get a user profile by name. + */ + async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['name'] == null) { + throw new runtime.RequiredError( + 'name', + 'Required parameter "name" was null or undefined when calling getUserByName().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/name/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.get.name + * Get a user profile by name. + */ + async getUserByName(name: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserByNameRaw({ name: name }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.get.uuid + * Get a user profile by uuid. + */ + async getUserByUuidRaw(requestParameters: GetUserByUuidRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['uuid'] == null) { + throw new runtime.RequiredError( + 'uuid', + 'Required parameter "uuid" was null or undefined when calling getUserByUuid().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/uuid/{uuid}`.replace(`{${"uuid"}}`, encodeURIComponent(String(requestParameters['uuid']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.get.uuid + * Get a user profile by uuid. + */ + async getUserByUuid(uuid: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserByUuidRaw({ uuid: uuid }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.friend.list + * Get a list of friends of the user. + */ + async getUserFriendsRaw(requestParameters: GetUserFriendsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserFriends().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/friends`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.friend.list + * Get a list of friends of the user. + */ + async getUserFriends(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUserFriendsRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.game.list + * Get a list of games the user has played. + */ + async getUserGamesRaw(requestParameters: GetUserGamesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserGames().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/games`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ProfileGameFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.game.list + * Get a list of games the user has played. + */ + async getUserGames(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUserGamesRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.group.list + * Get a list of groups the user is a member of. + */ + async getUserGroupsRaw(requestParameters: GetUserGroupsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserGroups().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/groups`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ProfileGroupFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.group.list + * Get a list of groups the user is a member of. + */ + async getUserGroups(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUserGroupsRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.user.info + * Get current user information. + */ + async getUserInfoRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/userinfo`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserInfoFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.user.info + * Get current user information. + */ + async getUserInfo(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserInfoRaw(initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.punishment.list + * Get a list of punishments the user has received. + */ + async getUserPunishmentsRaw(requestParameters: GetUserPunishmentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserPunishments().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/punishments`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.punishment.list + * Get a list of punishments the user has received. + */ + async getUserPunishments(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUserPunishmentsRaw({ id: id }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.game.server.list + * Get a list of servers the user is owner of. + */ + async getUserServersRaw(requestParameters: GetUserServersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getUserServers().' + ); + } + + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/servers`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GameServerFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.game.server.list + * Get a list of servers the user is owner of. + */ + async getUserServers(id: string, page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUserServersRaw({ id: id, page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.list + * Get a list of user profiles. + */ + async getUsersRaw(requestParameters: GetUsersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters['page'] != null) { + queryParameters['page'] = requestParameters['page']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ProfileFromJSON)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.list + * Get a list of user profiles. + */ + async getUsers(page?: number, limit?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getUsersRaw({ page: page, limit: limit }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.argon2 + * Hash a string using argon2. + */ + async hashArgon2Raw(requestParameters: HashArgon2Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/argon2`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: HashViewModelToJSON(requestParameters['hashViewModel']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => HashViewModelFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.argon2 + * Hash a string using argon2. + */ + async hashArgon2(hashViewModel?: HashViewModel, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.hashArgon2Raw({ hashViewModel: hashViewModel }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.bcrypt + * Hash a string using bcrypt. + */ + async hashBcryptRaw(requestParameters: HashBcryptRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/bcrypt`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: HashViewModelToJSON(requestParameters['hashViewModel']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => HashViewModelFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.bcrypt + * Hash a string using bcrypt. + */ + async hashBcrypt(hashViewModel?: HashViewModel, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.hashBcryptRaw({ hashViewModel: hashViewModel }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.md5 + * Hash a string using md5. + */ + async hashMd5Raw(requestParameters: HashMd5Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/md5`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: HashViewModelToJSON(requestParameters['hashViewModel']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => HashViewModelFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.md5 + * Hash a string using md5. + */ + async hashMd5(hashViewModel?: HashViewModel, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.hashMd5Raw({ hashViewModel: hashViewModel }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.sha256 + * Hash a string using sha256. + */ + async hashSha256Raw(requestParameters: HashSha256Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/utils/sha256`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: HashViewModelToJSON(requestParameters['hashViewModel']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => HashViewModelFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.utils.hash.sha256 + * Hash a string using sha256. + */ + async hashSha256(hashViewModel?: HashViewModel, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.hashSha256Raw({ hashViewModel: hashViewModel }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.token.introspect + * Introspect a token. + */ + async introspectTokenRaw(requestParameters: IntrospectTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/introspect`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: IntrospectRequestToJSON(requestParameters['introspectRequest']), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.token.introspect + * Introspect a token. + */ + async introspectToken(introspectRequest?: IntrospectRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.introspectTokenRaw({ introspectRequest: introspectRequest }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.identity.token.create + * Login with name or email and password. + * @deprecated + */ + async loginRaw(requestParameters: LoginOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/login`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: LoginRequestToJSON(requestParameters['loginRequest']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => LoginResponseFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.identity.token.create + * Login with name or email and password. + * @deprecated + */ + async login(loginRequest?: LoginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.loginRaw({ loginRequest: loginRequest }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.token.revoke + * Invalidate credentials. + * @deprecated + */ + async logoutRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/logout`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.identity.token.revoke + * Invalidate credentials. + * @deprecated + */ + async logout(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.logoutRaw(initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.identity.token.refresh + * Refresh credentials. + * @deprecated + */ + async refreshRaw(requestParameters: RefreshOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/refresh`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RefreshRequestToJSON(requestParameters['refreshRequest']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => LoginResponseFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.identity.token.refresh + * Refresh credentials. + * @deprecated + */ + async refresh(refreshRequest?: RefreshRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.refreshRaw({ refreshRequest: refreshRequest }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.user.create + * Create a new user. + */ + async registerRaw(requestParameters: RegisterOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/register`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RegisterRequestToJSON(requestParameters['registerRequest']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => LoginResponseFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.identity.user.create + * Create a new user. + */ + async register(registerRequest?: RegisterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.registerRaw({ registerRequest: registerRequest }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.token.revoke + * Revoke a token. + */ + async revokeTokenRaw(requestParameters: RevokeTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/oauth2/revoke`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RevokeRequestToJSON(requestParameters['revokeRequest']), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.identity.oauth2.token.revoke + * Revoke a token. + */ + async revokeToken(revokeRequest?: RevokeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.revokeTokenRaw({ revokeRequest: revokeRequest }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.search + * Advanced search for servers or players. + */ + async searchRaw(requestParameters: SearchOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/search`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: SearchRequestToJSON(requestParameters['searchRequest']), + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.search + * Advanced search for servers or players. + */ + async search(searchRequest?: SearchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.searchRaw({ searchRequest: searchRequest }, initOverrides); + return await response.value(); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.update + * Update a game server. + */ + async updateGameServerRaw(requestParameters: UpdateGameServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling updateGameServer().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/servers/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.update + * Update a game server. + */ + async updateGameServer(id: string, body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updateGameServerRaw({ id: id, body: body }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.update + * Update a game server cluster. + */ + async updateGameServerClusterRaw(requestParameters: UpdateGameServerClusterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling updateGameServerCluster().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/clusters/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.game.server.cluster.update + * Update a game server cluster. + */ + async updateGameServerCluster(id: string, body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updateGameServerClusterRaw({ id: id, body: body }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.group.update + * Update a group. + */ + async updateGroupRaw(requestParameters: UpdateGroupRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling updateGroup().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/groups/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters['body'] as any, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * 🔒 Required permissions: tribufu.community.group.update + * Update a group. + */ + async updateGroup(id: string, body?: any | null, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updateGroupRaw({ id: id, body: body }, initOverrides); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.update + * Update a user profile. + */ + async updateUserProfileRaw(requestParameters: UpdateUserProfileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling updateUserProfile().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json-patch+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + const response = await this.request({ + path: `/v1/users/{id}/profile`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdateProfileToJSON(requestParameters['updateProfile']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue)); + } + + /** + * 🔒 Required permissions: tribufu.community.profile.update + * Update a user profile. + */ + async updateUserProfile(id: string, updateProfile?: UpdateProfile, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updateUserProfileRaw({ id: id, updateProfile: updateProfile }, initOverrides); + return await response.value(); + } + +} diff --git a/src/apis/index.ts b/src/apis/index.ts new file mode 100644 index 0000000..c55827e --- /dev/null +++ b/src/apis/index.ts @@ -0,0 +1,3 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './TribufuGeneratedApi'; diff --git a/src/constants.ts b/src/constants.ts index 34b47b1..2618474 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,27 +3,28 @@ import packageJson from "../package.json"; -/** - * The version of the Tribufu SDK. - */ export const TRIBUFU_VERSION: string = packageJson.version; -/** - * The default Tribufu WEB URL. - */ -export const TRIBUFU_WEB_URL: string = "https://www.tribufu.com"; - -/** - * The default Tribufu API URL. - */ -export const TRIBUFU_API_URL: string = "https://api.tribufu.com"; - -/** - * The default Tribufu CDN URL. - */ -export const TRIBUFU_CDN_URL: string = "https://cdn.tribufu.com"; - -/** - * Tribufu copyright notice. - */ export const TRIBUFU_COPYRIGHT = `© ${new Date().getFullYear()} Tribufu.`; +export const TRIBUFU_COPYRIGHT_WITH_RIGHTS = `${TRIBUFU_COPYRIGHT} All Rights Reserved.`; +export const TRIBUFU_COPYRIGHT_WITH_YEARS = `Copyright © 2016-${new Date().getFullYear()} Tribufu`; + +export const TRIBUFU_API_URL: string = "https://api.tribufu.com"; +export const TRIBUFU_COMMUNITY_URL: string = "https://www.tribufu.com"; +export const TRIBUFU_DOCS_URL: string = "https://docs.tribufu.com"; +export const TRIBUFU_GIT_URL: string = "https://git.tribufu.com"; +export const TRIBUFU_MAVEN_URL: string = "https://mvn.tribufu.com"; +export const TRIBUFU_R2_URL: string = "https://r2.tribufu.com"; +export const TRIBUFU_S3_URL: string = "https://s3.tribufu.com"; +export const TRIBUFU_STATUS_URL: string = "https://status.tribufu.com"; + +export const TRIBUFU_BLUESKY_URL: string = "https://bsky.app/profile/tribufu.com"; +export const TRIBUFU_DISCORD_URL: string = "https://www.tribufu.com/discord"; +export const TRIBUFU_GITHUB_URL: string = "https://github.com/tribufu"; +export const TRIBUFU_GITLAB_URL: string = "https://gitlab.com/tribufu"; +export const TRIBUFU_INSTAGRAM_URL: string = "https://www.instagram.com/tribufucom"; +export const TRIBUFU_LINKEDIN_URL: string = "https://www.linkedin.com/company/11747611"; +export const TRIBUFU_STEAM_URL: string = "https://steamcommunity.com/groups/tribufuservers"; +export const TRIBUFU_TIKTOK_URL: string = "https://www.tiktok.com/@tribufuservers"; +export const TRIBUFU_TWITCH_URL: string = "https://www.twitch.tv/tribufucom"; +export const TRIBUFU_YOUTUBE_URL: string = "https://www.youtube.com/@tribufuservers"; diff --git a/src/http/headers.ts b/src/http/headers.ts deleted file mode 100644 index e6a1020..0000000 --- a/src/http/headers.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -/** - * Http Headers - * - * Helper type to represent HTTP headers. - */ -export type HttpHeaders = { - [key: string]: string; -}; diff --git a/src/index.ts b/src/index.ts index 03fc263..edf0ee7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,31 +1,201 @@ // Copyright (c) Tribufu. All Rights Reserved. // SPDX-License-Identifier: MIT -import { - TRIBUFU_API_URL, - TRIBUFU_CDN_URL, - TRIBUFU_VERSION, - TRIBUFU_WEB_URL, -} from "./constants"; +import { Configuration } from "./runtime"; +import { TRIBUFU_API_URL, TRIBUFU_VERSION } from "./constants"; +import { TribufuGeneratedApi } from "./apis/TribufuGeneratedApi"; +import { JavaScriptRuntime } from "./node"; -import { TribufuApi } from "./api"; -import { TribufuApiOptions } from "./options"; -import { TribufuApiSingleton } from "./api/singletion"; +export * from "./constants"; -export { - TRIBUFU_API_URL, - TRIBUFU_CDN_URL, - TRIBUFU_VERSION, - TRIBUFU_WEB_URL, - TribufuApi, - TribufuApiOptions, - TribufuApiSingleton, -}; +/** + * **Tribufu API** + * + * Use this class to interact with the Tribufu API. + */ +export class TribufuApi extends TribufuGeneratedApi { + /** + * Create a TribufuApi with the given API key. + * + * @param apiKey The API key for authentication. + */ + constructor(apiKey: string | null = null) { + super(TribufuApi.createConfiguration(apiKey)); + } -export * from "./api/base"; -export * from "./api/generated"; -export * from "./api/include"; -export * from "./api/index"; -export * from "./api/singletion"; -export * from "./http/headers"; -export * from "./node"; + /** + * Create a default TribufuApi instance. + * + * @return TribufuApi instance with default config. + */ + public static default(): TribufuApi { + return new TribufuApi(); + } + + /** + * Create a TribufuApi with the given api key. + * + * - A api key give you public read only access to the Tribufu API. + * + * @param apiKey + * @returns TribufuApi + */ + public static withApiKey(apiKey: string): TribufuApi { + return new TribufuApi(apiKey); + } + + /** + * Try to create a TribufuApi from environment variables. + * + * - This will only work if the environment variables are set. + * + * @param prefix A prefix for the environment variables. Default is `TRIBUFU`. + * @returns TribufuApi | null + * @example + * ```ts + * // process.env.TRIBUFU_API_KEY + * const api = TribufuApi.fromEnv(); + * ``` + */ + public static fromEnv(prefix?: string | null): TribufuApi | null { + if (typeof process === "undefined") { + return null; + } + + const apiKey = process.env[`${prefix || "TRIBUFU"}_API_KEY`]; + + if (apiKey) { + return TribufuApi.withApiKey(apiKey); + } + + return null; + } + + /** + * Create a TribufuApi from environment variables or the default api. + * + * - This will fallback to the default api if the environment variables are not set. + * + * @param prefix A prefix for the environment variables. Default is `TRIBUFU`. + * @returns TribufuApi | null + * @example + * ```ts + * // process.env.TRIBUFU_API_KEY = null + * const api = TribufuApi.fromEnvOrDefault(); + * ``` + */ + public static fromEnvOrDefault(prefix: string = ""): TribufuApi { + return TribufuApi.fromEnv(prefix) || TribufuApi.default(); + } + + /** + * Creates a configuration for the Tribufu API client. + */ + private static createConfiguration(apiKey: string | null): Configuration { + const basePath = this.getBaseUrl(); + const headers: Record = { + "User-Agent": this.getUserAgent(), + }; + + if (apiKey) { + headers["Authorization"] = `ApiKey ${apiKey}`; + } + + return new Configuration({ + basePath, + headers, + }); + } + + /** + * Get the base url for the Tribufu API. + * + * - The base url can be set using the environment variable `TRIBUFU_API_URL`. + * - The custom base url is only used if debug mode is enabled. + * - The default base url is `https://api.tribufu.com`. + * + * @returns string + */ + protected static getBaseUrl(): string { + if (typeof process === "undefined") { + return TRIBUFU_API_URL; + } + + const baseUrl = process.env[`TRIBUFU_API_URL`] || null; + return this.debugEnabled() && baseUrl ? baseUrl : TRIBUFU_API_URL; + } + + /** + * Get the version of the Tribufu client. + */ + public static getVersion(): string { + try { + return TRIBUFU_VERSION; + } catch { + return "dev"; + } + } + + /** + * Get the User-Agent string for the API. + */ + private static getUserAgent(): string { + const version = this.getVersion(); + const os = process.platform; + const arch = process.arch; + const nodeVersion = process.version; + return `Tribufu/${version} (Node.js ${nodeVersion}; ${os}; ${arch})`; + } + + /** + * Check if debug mode is enabled. + * + * - Debug mode is enabled if the environment variable `NODE_ENV` is set to `development`. + * - Debug mode is disabled by default. + * - Debug mode is disabled in the browser. + * + * @returns boolean + */ + public static debugEnabled(): boolean { + if (typeof process !== "undefined") { + return process.env.NODE_ENV === "development"; + } + + return false; + } + + /** + * Detect the current JavaScript runtime. + * + * - This is used to determine if the code is running in a browser or in Node.js. + * + * @returns JavaScriptRuntime + */ + public static detectRuntime(): JavaScriptRuntime { + if (typeof window !== "undefined") { + return JavaScriptRuntime.Browser; + } + + if (typeof process !== "undefined" && process?.versions?.node) { + return JavaScriptRuntime.Node; + } + + return JavaScriptRuntime.Other; + } + + /** + * Check if the current JavaScript runtime is a browser. + * @returns boolean + */ + public static isBrowser(): boolean { + return this.detectRuntime() === JavaScriptRuntime.Browser; + } + + /** + * Check if the current JavaScript runtime is Node.js. + * @returns boolean + */ + public static isNode(): boolean { + return this.detectRuntime() === JavaScriptRuntime.Node; + } +} diff --git a/src/models/Account.ts b/src/models/Account.ts new file mode 100644 index 0000000..3ab19d6 --- /dev/null +++ b/src/models/Account.ts @@ -0,0 +1,131 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { LoginProvider } from './LoginProvider'; +import { + LoginProviderFromJSON, + LoginProviderFromJSONTyped, + LoginProviderToJSON, + LoginProviderToJSONTyped, +} from './LoginProvider'; + +/** + * + * @export + * @interface Account + */ +export interface Account { + /** + * + * @type {string} + * @memberof Account + */ + id?: string | null; + /** + * + * @type {string} + * @memberof Account + */ + name?: string | null; + /** + * + * @type {LoginProvider} + * @memberof Account + */ + provider?: LoginProvider; + /** + * + * @type {string} + * @memberof Account + */ + userId?: string; + /** + * + * @type {boolean} + * @memberof Account + */ + authorized?: boolean; + /** + * + * @type {any} + * @memberof Account + */ + fields?: any | null; + /** + * + * @type {Date} + * @memberof Account + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Account + */ + updated?: Date | null; +} + + + +/** + * Check if a given object implements the Account interface. + */ +export function instanceOfAccount(value: object): value is Account { + return true; +} + +export function AccountFromJSON(json: any): Account { + return AccountFromJSONTyped(json, false); +} + +export function AccountFromJSONTyped(json: any, ignoreDiscriminator: boolean): Account { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'provider': json['provider'] == null ? undefined : LoginProviderFromJSON(json['provider']), + 'userId': json['user_id'] == null ? undefined : json['user_id'], + 'authorized': json['authorized'] == null ? undefined : json['authorized'], + 'fields': json['fields'] == null ? undefined : json['fields'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function AccountToJSON(json: any): Account { + return AccountToJSONTyped(json, false); +} + +export function AccountToJSONTyped(value?: Account | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'provider': LoginProviderToJSON(value['provider']), + 'user_id': value['userId'], + 'authorized': value['authorized'], + 'fields': value['fields'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/Application.ts b/src/models/Application.ts new file mode 100644 index 0000000..68fe08d --- /dev/null +++ b/src/models/Application.ts @@ -0,0 +1,227 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { ApplicationType } from './ApplicationType'; +import { + ApplicationTypeFromJSON, + ApplicationTypeFromJSONTyped, + ApplicationTypeToJSON, + ApplicationTypeToJSONTyped, +} from './ApplicationType'; + +/** + * + * @export + * @interface Application + */ +export interface Application { + /** + * + * @type {string} + * @memberof Application + */ + id?: string; + /** + * + * @type {string} + * @memberof Application + */ + name?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + description?: string | null; + /** + * + * @type {ApplicationType} + * @memberof Application + */ + type?: ApplicationType; + /** + * + * @type {string} + * @memberof Application + */ + organizationId?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + iconUrl?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + bannerUrl?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + capsuleImageUrl?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + libraryImageUrl?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + parentId?: string | null; + /** + * + * @type {string} + * @memberof Application + */ + slug?: string | null; + /** + * + * @type {number} + * @memberof Application + */ + visibility?: number; + /** + * + * @type {string} + * @memberof Application + */ + password?: string | null; + /** + * + * @type {number} + * @memberof Application + */ + primary?: number; + /** + * + * @type {number} + * @memberof Application + */ + userCount?: number; + /** + * + * @type {number} + * @memberof Application + */ + achievementCount?: number; + /** + * + * @type {number} + * @memberof Application + */ + badgeCount?: number | null; + /** + * + * @type {number} + * @memberof Application + */ + downloadCount?: number; + /** + * + * @type {Date} + * @memberof Application + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Application + */ + updated?: Date | null; +} + + + +/** + * Check if a given object implements the Application interface. + */ +export function instanceOfApplication(value: object): value is Application { + return true; +} + +export function ApplicationFromJSON(json: any): Application { + return ApplicationFromJSONTyped(json, false); +} + +export function ApplicationFromJSONTyped(json: any, ignoreDiscriminator: boolean): Application { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'description': json['description'] == null ? undefined : json['description'], + 'type': json['type'] == null ? undefined : ApplicationTypeFromJSON(json['type']), + 'organizationId': json['organization_id'] == null ? undefined : json['organization_id'], + 'iconUrl': json['icon_url'] == null ? undefined : json['icon_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'capsuleImageUrl': json['capsule_image_url'] == null ? undefined : json['capsule_image_url'], + 'libraryImageUrl': json['library_image_url'] == null ? undefined : json['library_image_url'], + 'parentId': json['parent_id'] == null ? undefined : json['parent_id'], + 'slug': json['slug'] == null ? undefined : json['slug'], + 'visibility': json['visibility'] == null ? undefined : json['visibility'], + 'password': json['password'] == null ? undefined : json['password'], + 'primary': json['primary'] == null ? undefined : json['primary'], + 'userCount': json['user_count'] == null ? undefined : json['user_count'], + 'achievementCount': json['achievement_count'] == null ? undefined : json['achievement_count'], + 'badgeCount': json['badge_count'] == null ? undefined : json['badge_count'], + 'downloadCount': json['download_count'] == null ? undefined : json['download_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function ApplicationToJSON(json: any): Application { + return ApplicationToJSONTyped(json, false); +} + +export function ApplicationToJSONTyped(value?: Application | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'description': value['description'], + 'type': ApplicationTypeToJSON(value['type']), + 'organization_id': value['organizationId'], + 'icon_url': value['iconUrl'], + 'banner_url': value['bannerUrl'], + 'capsule_image_url': value['capsuleImageUrl'], + 'library_image_url': value['libraryImageUrl'], + 'parent_id': value['parentId'], + 'slug': value['slug'], + 'visibility': value['visibility'], + 'password': value['password'], + 'primary': value['primary'], + 'user_count': value['userCount'], + 'achievement_count': value['achievementCount'], + 'badge_count': value['badgeCount'], + 'download_count': value['downloadCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/ApplicationType.ts b/src/models/ApplicationType.ts new file mode 100644 index 0000000..71ce93d --- /dev/null +++ b/src/models/ApplicationType.ts @@ -0,0 +1,53 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const ApplicationType = { + Application: 'application', + Game: 'game' +} as const; +export type ApplicationType = typeof ApplicationType[keyof typeof ApplicationType]; + + +export function instanceOfApplicationType(value: any): boolean { + for (const key in ApplicationType) { + if (Object.prototype.hasOwnProperty.call(ApplicationType, key)) { + if (ApplicationType[key as keyof typeof ApplicationType] === value) { + return true; + } + } + } + return false; +} + +export function ApplicationTypeFromJSON(json: any): ApplicationType { + return ApplicationTypeFromJSONTyped(json, false); +} + +export function ApplicationTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApplicationType { + return json as ApplicationType; +} + +export function ApplicationTypeToJSON(value?: ApplicationType | null): any { + return value as any; +} + +export function ApplicationTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): ApplicationType { + return value as ApplicationType; +} + diff --git a/src/models/AuthorizeRequest.ts b/src/models/AuthorizeRequest.ts new file mode 100644 index 0000000..6c72e67 --- /dev/null +++ b/src/models/AuthorizeRequest.ts @@ -0,0 +1,130 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { CodeChallengeMethod } from './CodeChallengeMethod'; +import { + CodeChallengeMethodFromJSON, + CodeChallengeMethodFromJSONTyped, + CodeChallengeMethodToJSON, + CodeChallengeMethodToJSONTyped, +} from './CodeChallengeMethod'; +import type { ResponseType } from './ResponseType'; +import { + ResponseTypeFromJSON, + ResponseTypeFromJSONTyped, + ResponseTypeToJSON, + ResponseTypeToJSONTyped, +} from './ResponseType'; + +/** + * + * @export + * @interface AuthorizeRequest + */ +export interface AuthorizeRequest { + /** + * + * @type {ResponseType} + * @memberof AuthorizeRequest + */ + responseType?: ResponseType; + /** + * + * @type {string} + * @memberof AuthorizeRequest + */ + clientId?: string | null; + /** + * + * @type {string} + * @memberof AuthorizeRequest + */ + codeChallenge?: string | null; + /** + * + * @type {CodeChallengeMethod} + * @memberof AuthorizeRequest + */ + codeChallengeMethod?: CodeChallengeMethod; + /** + * + * @type {string} + * @memberof AuthorizeRequest + */ + redirectUri?: string | null; + /** + * + * @type {string} + * @memberof AuthorizeRequest + */ + scope?: string | null; + /** + * + * @type {string} + * @memberof AuthorizeRequest + */ + state?: string | null; +} + + + +/** + * Check if a given object implements the AuthorizeRequest interface. + */ +export function instanceOfAuthorizeRequest(value: object): value is AuthorizeRequest { + return true; +} + +export function AuthorizeRequestFromJSON(json: any): AuthorizeRequest { + return AuthorizeRequestFromJSONTyped(json, false); +} + +export function AuthorizeRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): AuthorizeRequest { + if (json == null) { + return json; + } + return { + + 'responseType': json['response_type'] == null ? undefined : ResponseTypeFromJSON(json['response_type']), + 'clientId': json['client_id'] == null ? undefined : json['client_id'], + 'codeChallenge': json['code_challenge'] == null ? undefined : json['code_challenge'], + 'codeChallengeMethod': json['code_challenge_method'] == null ? undefined : CodeChallengeMethodFromJSON(json['code_challenge_method']), + 'redirectUri': json['redirect_uri'] == null ? undefined : json['redirect_uri'], + 'scope': json['scope'] == null ? undefined : json['scope'], + 'state': json['state'] == null ? undefined : json['state'], + }; +} + +export function AuthorizeRequestToJSON(json: any): AuthorizeRequest { + return AuthorizeRequestToJSONTyped(json, false); +} + +export function AuthorizeRequestToJSONTyped(value?: AuthorizeRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'response_type': ResponseTypeToJSON(value['responseType']), + 'client_id': value['clientId'], + 'code_challenge': value['codeChallenge'], + 'code_challenge_method': CodeChallengeMethodToJSON(value['codeChallengeMethod']), + 'redirect_uri': value['redirectUri'], + 'scope': value['scope'], + 'state': value['state'], + }; +} + diff --git a/src/models/CodeChallengeMethod.ts b/src/models/CodeChallengeMethod.ts new file mode 100644 index 0000000..a8689c5 --- /dev/null +++ b/src/models/CodeChallengeMethod.ts @@ -0,0 +1,53 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const CodeChallengeMethod = { + Plain: 'plain', + S256: 'S256' +} as const; +export type CodeChallengeMethod = typeof CodeChallengeMethod[keyof typeof CodeChallengeMethod]; + + +export function instanceOfCodeChallengeMethod(value: any): boolean { + for (const key in CodeChallengeMethod) { + if (Object.prototype.hasOwnProperty.call(CodeChallengeMethod, key)) { + if (CodeChallengeMethod[key as keyof typeof CodeChallengeMethod] === value) { + return true; + } + } + } + return false; +} + +export function CodeChallengeMethodFromJSON(json: any): CodeChallengeMethod { + return CodeChallengeMethodFromJSONTyped(json, false); +} + +export function CodeChallengeMethodFromJSONTyped(json: any, ignoreDiscriminator: boolean): CodeChallengeMethod { + return json as CodeChallengeMethod; +} + +export function CodeChallengeMethodToJSON(value?: CodeChallengeMethod | null): any { + return value as any; +} + +export function CodeChallengeMethodToJSONTyped(value: any, ignoreDiscriminator: boolean): CodeChallengeMethod { + return value as CodeChallengeMethod; +} + diff --git a/src/models/CryptoViewModel.ts b/src/models/CryptoViewModel.ts new file mode 100644 index 0000000..292cac6 --- /dev/null +++ b/src/models/CryptoViewModel.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface CryptoViewModel + */ +export interface CryptoViewModel { + /** + * + * @type {string} + * @memberof CryptoViewModel + */ + encoded?: string | null; + /** + * + * @type {string} + * @memberof CryptoViewModel + */ + decoded?: string | null; +} + +/** + * Check if a given object implements the CryptoViewModel interface. + */ +export function instanceOfCryptoViewModel(value: object): value is CryptoViewModel { + return true; +} + +export function CryptoViewModelFromJSON(json: any): CryptoViewModel { + return CryptoViewModelFromJSONTyped(json, false); +} + +export function CryptoViewModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): CryptoViewModel { + if (json == null) { + return json; + } + return { + + 'encoded': json['encoded'] == null ? undefined : json['encoded'], + 'decoded': json['decoded'] == null ? undefined : json['decoded'], + }; +} + +export function CryptoViewModelToJSON(json: any): CryptoViewModel { + return CryptoViewModelToJSONTyped(json, false); +} + +export function CryptoViewModelToJSONTyped(value?: CryptoViewModel | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'encoded': value['encoded'], + 'decoded': value['decoded'], + }; +} + diff --git a/src/models/Game.ts b/src/models/Game.ts new file mode 100644 index 0000000..6936ffb --- /dev/null +++ b/src/models/Game.ts @@ -0,0 +1,315 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { ApplicationType } from './ApplicationType'; +import { + ApplicationTypeFromJSON, + ApplicationTypeFromJSONTyped, + ApplicationTypeToJSON, + ApplicationTypeToJSONTyped, +} from './ApplicationType'; + +/** + * + * @export + * @interface Game + */ +export interface Game { + /** + * + * @type {number} + * @memberof Game + */ + gamePort?: number | null; + /** + * + * @type {number} + * @memberof Game + */ + queryPort?: number | null; + /** + * + * @type {number} + * @memberof Game + */ + rconPort?: number | null; + /** + * + * @type {number} + * @memberof Game + */ + serverCount?: number; + /** + * + * @type {number} + * @memberof Game + */ + steamAppId?: number | null; + /** + * + * @type {number} + * @memberof Game + */ + steamServerAppId?: number | null; + /** + * + * @type {boolean} + * @memberof Game + */ + enableServers?: boolean; + /** + * + * @type {string} + * @memberof Game + */ + rustGamedigId?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + nodeGamedigId?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + serverConnectUrl?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + serverTags?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + id?: string; + /** + * + * @type {string} + * @memberof Game + */ + name?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + description?: string | null; + /** + * + * @type {ApplicationType} + * @memberof Game + */ + type?: ApplicationType; + /** + * + * @type {string} + * @memberof Game + */ + organizationId?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + iconUrl?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + bannerUrl?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + capsuleImageUrl?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + libraryImageUrl?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + parentId?: string | null; + /** + * + * @type {string} + * @memberof Game + */ + slug?: string | null; + /** + * + * @type {number} + * @memberof Game + */ + visibility?: number; + /** + * + * @type {string} + * @memberof Game + */ + password?: string | null; + /** + * + * @type {number} + * @memberof Game + */ + primary?: number; + /** + * + * @type {number} + * @memberof Game + */ + userCount?: number; + /** + * + * @type {number} + * @memberof Game + */ + achievementCount?: number; + /** + * + * @type {number} + * @memberof Game + */ + badgeCount?: number | null; + /** + * + * @type {number} + * @memberof Game + */ + downloadCount?: number; + /** + * + * @type {Date} + * @memberof Game + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Game + */ + updated?: Date | null; +} + + + +/** + * Check if a given object implements the Game interface. + */ +export function instanceOfGame(value: object): value is Game { + return true; +} + +export function GameFromJSON(json: any): Game { + return GameFromJSONTyped(json, false); +} + +export function GameFromJSONTyped(json: any, ignoreDiscriminator: boolean): Game { + if (json == null) { + return json; + } + return { + + 'gamePort': json['game_port'] == null ? undefined : json['game_port'], + 'queryPort': json['query_port'] == null ? undefined : json['query_port'], + 'rconPort': json['rcon_port'] == null ? undefined : json['rcon_port'], + 'serverCount': json['server_count'] == null ? undefined : json['server_count'], + 'steamAppId': json['steam_app_id'] == null ? undefined : json['steam_app_id'], + 'steamServerAppId': json['steam_server_app_id'] == null ? undefined : json['steam_server_app_id'], + 'enableServers': json['enable_servers'] == null ? undefined : json['enable_servers'], + 'rustGamedigId': json['rust_gamedig_id'] == null ? undefined : json['rust_gamedig_id'], + 'nodeGamedigId': json['node_gamedig_id'] == null ? undefined : json['node_gamedig_id'], + 'serverConnectUrl': json['server_connect_url'] == null ? undefined : json['server_connect_url'], + 'serverTags': json['server_tags'] == null ? undefined : json['server_tags'], + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'description': json['description'] == null ? undefined : json['description'], + 'type': json['type'] == null ? undefined : ApplicationTypeFromJSON(json['type']), + 'organizationId': json['organization_id'] == null ? undefined : json['organization_id'], + 'iconUrl': json['icon_url'] == null ? undefined : json['icon_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'capsuleImageUrl': json['capsule_image_url'] == null ? undefined : json['capsule_image_url'], + 'libraryImageUrl': json['library_image_url'] == null ? undefined : json['library_image_url'], + 'parentId': json['parent_id'] == null ? undefined : json['parent_id'], + 'slug': json['slug'] == null ? undefined : json['slug'], + 'visibility': json['visibility'] == null ? undefined : json['visibility'], + 'password': json['password'] == null ? undefined : json['password'], + 'primary': json['primary'] == null ? undefined : json['primary'], + 'userCount': json['user_count'] == null ? undefined : json['user_count'], + 'achievementCount': json['achievement_count'] == null ? undefined : json['achievement_count'], + 'badgeCount': json['badge_count'] == null ? undefined : json['badge_count'], + 'downloadCount': json['download_count'] == null ? undefined : json['download_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function GameToJSON(json: any): Game { + return GameToJSONTyped(json, false); +} + +export function GameToJSONTyped(value?: Game | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'game_port': value['gamePort'], + 'query_port': value['queryPort'], + 'rcon_port': value['rconPort'], + 'server_count': value['serverCount'], + 'steam_app_id': value['steamAppId'], + 'steam_server_app_id': value['steamServerAppId'], + 'enable_servers': value['enableServers'], + 'rust_gamedig_id': value['rustGamedigId'], + 'node_gamedig_id': value['nodeGamedigId'], + 'server_connect_url': value['serverConnectUrl'], + 'server_tags': value['serverTags'], + 'id': value['id'], + 'name': value['name'], + 'description': value['description'], + 'type': ApplicationTypeToJSON(value['type']), + 'organization_id': value['organizationId'], + 'icon_url': value['iconUrl'], + 'banner_url': value['bannerUrl'], + 'capsule_image_url': value['capsuleImageUrl'], + 'library_image_url': value['libraryImageUrl'], + 'parent_id': value['parentId'], + 'slug': value['slug'], + 'visibility': value['visibility'], + 'password': value['password'], + 'primary': value['primary'], + 'user_count': value['userCount'], + 'achievement_count': value['achievementCount'], + 'badge_count': value['badgeCount'], + 'download_count': value['downloadCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/GameServer.ts b/src/models/GameServer.ts new file mode 100644 index 0000000..6d59bb5 --- /dev/null +++ b/src/models/GameServer.ts @@ -0,0 +1,315 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { ServerStatus } from './ServerStatus'; +import { + ServerStatusFromJSON, + ServerStatusFromJSONTyped, + ServerStatusToJSON, + ServerStatusToJSONTyped, +} from './ServerStatus'; + +/** + * + * @export + * @interface GameServer + */ +export interface GameServer { + /** + * + * @type {string} + * @memberof GameServer + */ + id?: string; + /** + * + * @type {string} + * @memberof GameServer + */ + name?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + description?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + address?: string | null; + /** + * + * @type {number} + * @memberof GameServer + */ + gamePort?: number | null; + /** + * + * @type {number} + * @memberof GameServer + */ + queryPort?: number; + /** + * + * @type {string} + * @memberof GameServer + */ + gameId?: string; + /** + * + * @type {string} + * @memberof GameServer + */ + gameIconUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + version?: string | null; + /** + * + * @type {boolean} + * @memberof GameServer + */ + featured?: boolean; + /** + * + * @type {string} + * @memberof GameServer + */ + clusterId?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + websiteUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + bannerUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + ownerId?: string | null; + /** + * + * @type {number} + * @memberof GameServer + */ + uptime?: number; + /** + * + * @type {ServerStatus} + * @memberof GameServer + */ + status?: ServerStatus; + /** + * + * @type {number} + * @memberof GameServer + */ + ping?: number | null; + /** + * + * @type {string} + * @memberof GameServer + */ + map?: string | null; + /** + * + * @type {number} + * @memberof GameServer + */ + usedSlots?: number | null; + /** + * + * @type {number} + * @memberof GameServer + */ + maxSlots?: number | null; + /** + * + * @type {string} + * @memberof GameServer + */ + motd?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + players?: string | null; + /** + * + * @type {Date} + * @memberof GameServer + */ + lastOnline?: Date | null; + /** + * + * @type {string} + * @memberof GameServer + */ + country?: string | null; + /** + * + * @type {boolean} + * @memberof GameServer + */ + steam?: boolean; + /** + * + * @type {string} + * @memberof GameServer + */ + discordServerId?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + youtubeVideoUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServer + */ + tags?: string | null; + /** + * + * @type {number} + * @memberof GameServer + */ + commentCount?: number; + /** + * + * @type {Date} + * @memberof GameServer + */ + created?: Date; + /** + * + * @type {Date} + * @memberof GameServer + */ + updated?: Date | null; +} + + + +/** + * Check if a given object implements the GameServer interface. + */ +export function instanceOfGameServer(value: object): value is GameServer { + return true; +} + +export function GameServerFromJSON(json: any): GameServer { + return GameServerFromJSONTyped(json, false); +} + +export function GameServerFromJSONTyped(json: any, ignoreDiscriminator: boolean): GameServer { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'description': json['description'] == null ? undefined : json['description'], + 'address': json['address'] == null ? undefined : json['address'], + 'gamePort': json['game_port'] == null ? undefined : json['game_port'], + 'queryPort': json['query_port'] == null ? undefined : json['query_port'], + 'gameId': json['game_id'] == null ? undefined : json['game_id'], + 'gameIconUrl': json['game_icon_url'] == null ? undefined : json['game_icon_url'], + 'version': json['version'] == null ? undefined : json['version'], + 'featured': json['featured'] == null ? undefined : json['featured'], + 'clusterId': json['cluster_id'] == null ? undefined : json['cluster_id'], + 'websiteUrl': json['website_url'] == null ? undefined : json['website_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'ownerId': json['owner_id'] == null ? undefined : json['owner_id'], + 'uptime': json['uptime'] == null ? undefined : json['uptime'], + 'status': json['status'] == null ? undefined : ServerStatusFromJSON(json['status']), + 'ping': json['ping'] == null ? undefined : json['ping'], + 'map': json['map'] == null ? undefined : json['map'], + 'usedSlots': json['used_slots'] == null ? undefined : json['used_slots'], + 'maxSlots': json['max_slots'] == null ? undefined : json['max_slots'], + 'motd': json['motd'] == null ? undefined : json['motd'], + 'players': json['players'] == null ? undefined : json['players'], + 'lastOnline': json['last_online'] == null ? undefined : (new Date(json['last_online'])), + 'country': json['country'] == null ? undefined : json['country'], + 'steam': json['steam'] == null ? undefined : json['steam'], + 'discordServerId': json['discord_server_id'] == null ? undefined : json['discord_server_id'], + 'youtubeVideoUrl': json['youtube_video_url'] == null ? undefined : json['youtube_video_url'], + 'tags': json['tags'] == null ? undefined : json['tags'], + 'commentCount': json['comment_count'] == null ? undefined : json['comment_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function GameServerToJSON(json: any): GameServer { + return GameServerToJSONTyped(json, false); +} + +export function GameServerToJSONTyped(value?: GameServer | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'description': value['description'], + 'address': value['address'], + 'game_port': value['gamePort'], + 'query_port': value['queryPort'], + 'game_id': value['gameId'], + 'game_icon_url': value['gameIconUrl'], + 'version': value['version'], + 'featured': value['featured'], + 'cluster_id': value['clusterId'], + 'website_url': value['websiteUrl'], + 'banner_url': value['bannerUrl'], + 'owner_id': value['ownerId'], + 'uptime': value['uptime'], + 'status': ServerStatusToJSON(value['status']), + 'ping': value['ping'], + 'map': value['map'], + 'used_slots': value['usedSlots'], + 'max_slots': value['maxSlots'], + 'motd': value['motd'], + 'players': value['players'], + 'last_online': value['lastOnline'] == null ? undefined : ((value['lastOnline'] as any).toISOString()), + 'country': value['country'], + 'steam': value['steam'], + 'discord_server_id': value['discordServerId'], + 'youtube_video_url': value['youtubeVideoUrl'], + 'tags': value['tags'], + 'comment_count': value['commentCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/GameServerCluster.ts b/src/models/GameServerCluster.ts new file mode 100644 index 0000000..37a1a47 --- /dev/null +++ b/src/models/GameServerCluster.ts @@ -0,0 +1,169 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface GameServerCluster + */ +export interface GameServerCluster { + /** + * + * @type {string} + * @memberof GameServerCluster + */ + id?: string; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + name?: string | null; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + description?: string | null; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + gameId?: string; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + websiteUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + bannerUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + ownerId?: string; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + discordServerId?: string | null; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + youtubeVideoUrl?: string | null; + /** + * + * @type {string} + * @memberof GameServerCluster + */ + tags?: string | null; + /** + * + * @type {number} + * @memberof GameServerCluster + */ + commentCount?: number; + /** + * + * @type {number} + * @memberof GameServerCluster + */ + serverCount?: number; + /** + * + * @type {Date} + * @memberof GameServerCluster + */ + created?: Date; + /** + * + * @type {Date} + * @memberof GameServerCluster + */ + updated?: Date | null; +} + +/** + * Check if a given object implements the GameServerCluster interface. + */ +export function instanceOfGameServerCluster(value: object): value is GameServerCluster { + return true; +} + +export function GameServerClusterFromJSON(json: any): GameServerCluster { + return GameServerClusterFromJSONTyped(json, false); +} + +export function GameServerClusterFromJSONTyped(json: any, ignoreDiscriminator: boolean): GameServerCluster { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'description': json['description'] == null ? undefined : json['description'], + 'gameId': json['game_id'] == null ? undefined : json['game_id'], + 'websiteUrl': json['website_url'] == null ? undefined : json['website_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'ownerId': json['owner_id'] == null ? undefined : json['owner_id'], + 'discordServerId': json['discord_server_id'] == null ? undefined : json['discord_server_id'], + 'youtubeVideoUrl': json['youtube_video_url'] == null ? undefined : json['youtube_video_url'], + 'tags': json['tags'] == null ? undefined : json['tags'], + 'commentCount': json['comment_count'] == null ? undefined : json['comment_count'], + 'serverCount': json['server_count'] == null ? undefined : json['server_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function GameServerClusterToJSON(json: any): GameServerCluster { + return GameServerClusterToJSONTyped(json, false); +} + +export function GameServerClusterToJSONTyped(value?: GameServerCluster | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'description': value['description'], + 'game_id': value['gameId'], + 'website_url': value['websiteUrl'], + 'banner_url': value['bannerUrl'], + 'owner_id': value['ownerId'], + 'discord_server_id': value['discordServerId'], + 'youtube_video_url': value['youtubeVideoUrl'], + 'tags': value['tags'], + 'comment_count': value['commentCount'], + 'server_count': value['serverCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/GrantType.ts b/src/models/GrantType.ts new file mode 100644 index 0000000..80ee54d --- /dev/null +++ b/src/models/GrantType.ts @@ -0,0 +1,55 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const GrantType = { + AuthorizationCode: 'authorization_code', + ClientCredentials: 'client_credentials', + Password: 'password', + RefreshToken: 'refresh_token' +} as const; +export type GrantType = typeof GrantType[keyof typeof GrantType]; + + +export function instanceOfGrantType(value: any): boolean { + for (const key in GrantType) { + if (Object.prototype.hasOwnProperty.call(GrantType, key)) { + if (GrantType[key as keyof typeof GrantType] === value) { + return true; + } + } + } + return false; +} + +export function GrantTypeFromJSON(json: any): GrantType { + return GrantTypeFromJSONTyped(json, false); +} + +export function GrantTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): GrantType { + return json as GrantType; +} + +export function GrantTypeToJSON(value?: GrantType | null): any { + return value as any; +} + +export function GrantTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): GrantType { + return value as GrantType; +} + diff --git a/src/models/Group.ts b/src/models/Group.ts new file mode 100644 index 0000000..caa8166 --- /dev/null +++ b/src/models/Group.ts @@ -0,0 +1,185 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface Group + */ +export interface Group { + /** + * + * @type {string} + * @memberof Group + */ + id?: string; + /** + * + * @type {string} + * @memberof Group + */ + uuid?: string; + /** + * + * @type {string} + * @memberof Group + */ + name?: string | null; + /** + * + * @type {string} + * @memberof Group + */ + tag?: string | null; + /** + * + * @type {string} + * @memberof Group + */ + description?: string | null; + /** + * + * @type {number} + * @memberof Group + */ + type?: number; + /** + * + * @type {number} + * @memberof Group + */ + privacy?: number; + /** + * + * @type {string} + * @memberof Group + */ + ownerId?: string; + /** + * + * @type {boolean} + * @memberof Group + */ + verified?: boolean; + /** + * + * @type {string} + * @memberof Group + */ + photoUrl?: string | null; + /** + * + * @type {string} + * @memberof Group + */ + bannerUrl?: string | null; + /** + * + * @type {number} + * @memberof Group + */ + memberCount?: number; + /** + * + * @type {number} + * @memberof Group + */ + followerCount?: number; + /** + * + * @type {number} + * @memberof Group + */ + viewCount?: number; + /** + * + * @type {Date} + * @memberof Group + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Group + */ + updated?: Date | null; +} + +/** + * Check if a given object implements the Group interface. + */ +export function instanceOfGroup(value: object): value is Group { + return true; +} + +export function GroupFromJSON(json: any): Group { + return GroupFromJSONTyped(json, false); +} + +export function GroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): Group { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'uuid': json['uuid'] == null ? undefined : json['uuid'], + 'name': json['name'] == null ? undefined : json['name'], + 'tag': json['tag'] == null ? undefined : json['tag'], + 'description': json['description'] == null ? undefined : json['description'], + 'type': json['type'] == null ? undefined : json['type'], + 'privacy': json['privacy'] == null ? undefined : json['privacy'], + 'ownerId': json['owner_id'] == null ? undefined : json['owner_id'], + 'verified': json['verified'] == null ? undefined : json['verified'], + 'photoUrl': json['photo_url'] == null ? undefined : json['photo_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'memberCount': json['member_count'] == null ? undefined : json['member_count'], + 'followerCount': json['follower_count'] == null ? undefined : json['follower_count'], + 'viewCount': json['view_count'] == null ? undefined : json['view_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function GroupToJSON(json: any): Group { + return GroupToJSONTyped(json, false); +} + +export function GroupToJSONTyped(value?: Group | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'uuid': value['uuid'], + 'name': value['name'], + 'tag': value['tag'], + 'description': value['description'], + 'type': value['type'], + 'privacy': value['privacy'], + 'owner_id': value['ownerId'], + 'verified': value['verified'], + 'photo_url': value['photoUrl'], + 'banner_url': value['bannerUrl'], + 'member_count': value['memberCount'], + 'follower_count': value['followerCount'], + 'view_count': value['viewCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/GroupGame.ts b/src/models/GroupGame.ts new file mode 100644 index 0000000..5dda8d1 --- /dev/null +++ b/src/models/GroupGame.ts @@ -0,0 +1,128 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { Group } from './Group'; +import { + GroupFromJSON, + GroupFromJSONTyped, + GroupToJSON, + GroupToJSONTyped, +} from './Group'; +import type { Application } from './Application'; +import { + ApplicationFromJSON, + ApplicationFromJSONTyped, + ApplicationToJSON, + ApplicationToJSONTyped, +} from './Application'; + +/** + * + * @export + * @interface GroupGame + */ +export interface GroupGame { + /** + * + * @type {string} + * @memberof GroupGame + */ + groupId?: string; + /** + * + * @type {Group} + * @memberof GroupGame + */ + group?: Group; + /** + * + * @type {string} + * @memberof GroupGame + */ + applicationId?: string; + /** + * + * @type {Application} + * @memberof GroupGame + */ + application?: Application; + /** + * + * @type {any} + * @memberof GroupGame + */ + stats?: any | null; + /** + * + * @type {Date} + * @memberof GroupGame + */ + acquired?: Date; + /** + * + * @type {Date} + * @memberof GroupGame + */ + lastUsed?: Date | null; +} + +/** + * Check if a given object implements the GroupGame interface. + */ +export function instanceOfGroupGame(value: object): value is GroupGame { + return true; +} + +export function GroupGameFromJSON(json: any): GroupGame { + return GroupGameFromJSONTyped(json, false); +} + +export function GroupGameFromJSONTyped(json: any, ignoreDiscriminator: boolean): GroupGame { + if (json == null) { + return json; + } + return { + + 'groupId': json['group_id'] == null ? undefined : json['group_id'], + 'group': json['group'] == null ? undefined : GroupFromJSON(json['group']), + 'applicationId': json['application_id'] == null ? undefined : json['application_id'], + 'application': json['application'] == null ? undefined : ApplicationFromJSON(json['application']), + 'stats': json['stats'] == null ? undefined : json['stats'], + 'acquired': json['acquired'] == null ? undefined : (new Date(json['acquired'])), + 'lastUsed': json['last_used'] == null ? undefined : (new Date(json['last_used'])), + }; +} + +export function GroupGameToJSON(json: any): GroupGame { + return GroupGameToJSONTyped(json, false); +} + +export function GroupGameToJSONTyped(value?: GroupGame | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'group_id': value['groupId'], + 'group': GroupToJSON(value['group']), + 'application_id': value['applicationId'], + 'application': ApplicationToJSON(value['application']), + 'stats': value['stats'], + 'acquired': value['acquired'] == null ? undefined : ((value['acquired']).toISOString()), + 'last_used': value['lastUsed'] == null ? undefined : ((value['lastUsed'] as any).toISOString()), + }; +} + diff --git a/src/models/GroupMember.ts b/src/models/GroupMember.ts new file mode 100644 index 0000000..3d7cc6f --- /dev/null +++ b/src/models/GroupMember.ts @@ -0,0 +1,139 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { GroupRank } from './GroupRank'; +import { + GroupRankFromJSON, + GroupRankFromJSONTyped, + GroupRankToJSON, + GroupRankToJSONTyped, +} from './GroupRank'; + +/** + * + * @export + * @interface GroupMember + */ +export interface GroupMember { + /** + * + * @type {string} + * @memberof GroupMember + */ + id?: string; + /** + * + * @type {string} + * @memberof GroupMember + */ + uuid?: string; + /** + * + * @type {string} + * @memberof GroupMember + */ + name?: string | null; + /** + * + * @type {string} + * @memberof GroupMember + */ + displayName?: string | null; + /** + * + * @type {boolean} + * @memberof GroupMember + */ + verified?: boolean; + /** + * + * @type {string} + * @memberof GroupMember + */ + photoUrl?: string | null; + /** + * + * @type {Date} + * @memberof GroupMember + */ + lastOnline?: Date | null; + /** + * + * @type {GroupRank} + * @memberof GroupMember + */ + rank?: GroupRank; + /** + * + * @type {Date} + * @memberof GroupMember + */ + since?: Date; +} + + + +/** + * Check if a given object implements the GroupMember interface. + */ +export function instanceOfGroupMember(value: object): value is GroupMember { + return true; +} + +export function GroupMemberFromJSON(json: any): GroupMember { + return GroupMemberFromJSONTyped(json, false); +} + +export function GroupMemberFromJSONTyped(json: any, ignoreDiscriminator: boolean): GroupMember { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'uuid': json['uuid'] == null ? undefined : json['uuid'], + 'name': json['name'] == null ? undefined : json['name'], + 'displayName': json['display_name'] == null ? undefined : json['display_name'], + 'verified': json['verified'] == null ? undefined : json['verified'], + 'photoUrl': json['photo_url'] == null ? undefined : json['photo_url'], + 'lastOnline': json['last_online'] == null ? undefined : (new Date(json['last_online'])), + 'rank': json['rank'] == null ? undefined : GroupRankFromJSON(json['rank']), + 'since': json['since'] == null ? undefined : (new Date(json['since'])), + }; +} + +export function GroupMemberToJSON(json: any): GroupMember { + return GroupMemberToJSONTyped(json, false); +} + +export function GroupMemberToJSONTyped(value?: GroupMember | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'uuid': value['uuid'], + 'name': value['name'], + 'display_name': value['displayName'], + 'verified': value['verified'], + 'photo_url': value['photoUrl'], + 'last_online': value['lastOnline'] == null ? undefined : ((value['lastOnline'] as any).toISOString()), + 'rank': GroupRankToJSON(value['rank']), + 'since': value['since'] == null ? undefined : ((value['since']).toISOString()), + }; +} + diff --git a/src/models/GroupRank.ts b/src/models/GroupRank.ts new file mode 100644 index 0000000..69d03ff --- /dev/null +++ b/src/models/GroupRank.ts @@ -0,0 +1,54 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const GroupRank = { + Member: 'member', + Leader: 'leader', + Owner: 'owner' +} as const; +export type GroupRank = typeof GroupRank[keyof typeof GroupRank]; + + +export function instanceOfGroupRank(value: any): boolean { + for (const key in GroupRank) { + if (Object.prototype.hasOwnProperty.call(GroupRank, key)) { + if (GroupRank[key as keyof typeof GroupRank] === value) { + return true; + } + } + } + return false; +} + +export function GroupRankFromJSON(json: any): GroupRank { + return GroupRankFromJSONTyped(json, false); +} + +export function GroupRankFromJSONTyped(json: any, ignoreDiscriminator: boolean): GroupRank { + return json as GroupRank; +} + +export function GroupRankToJSON(value?: GroupRank | null): any { + return value as any; +} + +export function GroupRankToJSONTyped(value: any, ignoreDiscriminator: boolean): GroupRank { + return value as GroupRank; +} + diff --git a/src/models/HashViewModel.ts b/src/models/HashViewModel.ts new file mode 100644 index 0000000..55edce7 --- /dev/null +++ b/src/models/HashViewModel.ts @@ -0,0 +1,65 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface HashViewModel + */ +export interface HashViewModel { + /** + * + * @type {string} + * @memberof HashViewModel + */ + value?: string | null; +} + +/** + * Check if a given object implements the HashViewModel interface. + */ +export function instanceOfHashViewModel(value: object): value is HashViewModel { + return true; +} + +export function HashViewModelFromJSON(json: any): HashViewModel { + return HashViewModelFromJSONTyped(json, false); +} + +export function HashViewModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): HashViewModel { + if (json == null) { + return json; + } + return { + + 'value': json['value'] == null ? undefined : json['value'], + }; +} + +export function HashViewModelToJSON(json: any): HashViewModel { + return HashViewModelToJSONTyped(json, false); +} + +export function HashViewModelToJSONTyped(value?: HashViewModel | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'value': value['value'], + }; +} + diff --git a/src/models/IntrospectRequest.ts b/src/models/IntrospectRequest.ts new file mode 100644 index 0000000..2e69234 --- /dev/null +++ b/src/models/IntrospectRequest.ts @@ -0,0 +1,83 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { TokenHintType } from './TokenHintType'; +import { + TokenHintTypeFromJSON, + TokenHintTypeFromJSONTyped, + TokenHintTypeToJSON, + TokenHintTypeToJSONTyped, +} from './TokenHintType'; + +/** + * + * @export + * @interface IntrospectRequest + */ +export interface IntrospectRequest { + /** + * + * @type {string} + * @memberof IntrospectRequest + */ + token?: string | null; + /** + * + * @type {TokenHintType} + * @memberof IntrospectRequest + */ + tokenTypeHint?: TokenHintType; +} + + + +/** + * Check if a given object implements the IntrospectRequest interface. + */ +export function instanceOfIntrospectRequest(value: object): value is IntrospectRequest { + return true; +} + +export function IntrospectRequestFromJSON(json: any): IntrospectRequest { + return IntrospectRequestFromJSONTyped(json, false); +} + +export function IntrospectRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): IntrospectRequest { + if (json == null) { + return json; + } + return { + + 'token': json['token'] == null ? undefined : json['token'], + 'tokenTypeHint': json['token_type_hint'] == null ? undefined : TokenHintTypeFromJSON(json['token_type_hint']), + }; +} + +export function IntrospectRequestToJSON(json: any): IntrospectRequest { + return IntrospectRequestToJSONTyped(json, false); +} + +export function IntrospectRequestToJSONTyped(value?: IntrospectRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'token': value['token'], + 'token_type_hint': TokenHintTypeToJSON(value['tokenTypeHint']), + }; +} + diff --git a/src/models/IpAddress.ts b/src/models/IpAddress.ts new file mode 100644 index 0000000..77d8b95 --- /dev/null +++ b/src/models/IpAddress.ts @@ -0,0 +1,201 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface IpAddress + */ +export interface IpAddress { + /** + * + * @type {string} + * @memberof IpAddress + */ + address?: string | null; + /** + * + * @type {number} + * @memberof IpAddress + */ + version?: number; + /** + * + * @type {string} + * @memberof IpAddress + */ + network?: string | null; + /** + * + * @type {boolean} + * @memberof IpAddress + */ + reserved?: boolean; + /** + * + * @type {string} + * @memberof IpAddress + */ + asn?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + isp?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + continent?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + country?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + region?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + city?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + postalCode?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + callingCode?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + tld?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + language?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + timezone?: string | null; + /** + * + * @type {string} + * @memberof IpAddress + */ + currency?: string | null; + /** + * + * @type {number} + * @memberof IpAddress + */ + latitude?: number | null; + /** + * + * @type {number} + * @memberof IpAddress + */ + longitude?: number | null; +} + +/** + * Check if a given object implements the IpAddress interface. + */ +export function instanceOfIpAddress(value: object): value is IpAddress { + return true; +} + +export function IpAddressFromJSON(json: any): IpAddress { + return IpAddressFromJSONTyped(json, false); +} + +export function IpAddressFromJSONTyped(json: any, ignoreDiscriminator: boolean): IpAddress { + if (json == null) { + return json; + } + return { + + 'address': json['address'] == null ? undefined : json['address'], + 'version': json['version'] == null ? undefined : json['version'], + 'network': json['network'] == null ? undefined : json['network'], + 'reserved': json['reserved'] == null ? undefined : json['reserved'], + 'asn': json['asn'] == null ? undefined : json['asn'], + 'isp': json['isp'] == null ? undefined : json['isp'], + 'continent': json['continent'] == null ? undefined : json['continent'], + 'country': json['country'] == null ? undefined : json['country'], + 'region': json['region'] == null ? undefined : json['region'], + 'city': json['city'] == null ? undefined : json['city'], + 'postalCode': json['postal_code'] == null ? undefined : json['postal_code'], + 'callingCode': json['calling_code'] == null ? undefined : json['calling_code'], + 'tld': json['tld'] == null ? undefined : json['tld'], + 'language': json['language'] == null ? undefined : json['language'], + 'timezone': json['timezone'] == null ? undefined : json['timezone'], + 'currency': json['currency'] == null ? undefined : json['currency'], + 'latitude': json['latitude'] == null ? undefined : json['latitude'], + 'longitude': json['longitude'] == null ? undefined : json['longitude'], + }; +} + +export function IpAddressToJSON(json: any): IpAddress { + return IpAddressToJSONTyped(json, false); +} + +export function IpAddressToJSONTyped(value?: IpAddress | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'address': value['address'], + 'version': value['version'], + 'network': value['network'], + 'reserved': value['reserved'], + 'asn': value['asn'], + 'isp': value['isp'], + 'continent': value['continent'], + 'country': value['country'], + 'region': value['region'], + 'city': value['city'], + 'postal_code': value['postalCode'], + 'calling_code': value['callingCode'], + 'tld': value['tld'], + 'language': value['language'], + 'timezone': value['timezone'], + 'currency': value['currency'], + 'latitude': value['latitude'], + 'longitude': value['longitude'], + }; +} + diff --git a/src/models/LeaderboardItem.ts b/src/models/LeaderboardItem.ts new file mode 100644 index 0000000..dbf9424 --- /dev/null +++ b/src/models/LeaderboardItem.ts @@ -0,0 +1,105 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface LeaderboardItem + */ +export interface LeaderboardItem { + /** + * + * @type {string} + * @memberof LeaderboardItem + */ + name?: string | null; + /** + * + * @type {string} + * @memberof LeaderboardItem + */ + displayName?: string | null; + /** + * + * @type {string} + * @memberof LeaderboardItem + */ + photoUrl?: string | null; + /** + * + * @type {number} + * @memberof LeaderboardItem + */ + level?: number; + /** + * + * @type {number} + * @memberof LeaderboardItem + */ + experience?: number; + /** + * + * @type {number} + * @memberof LeaderboardItem + */ + points?: number; +} + +/** + * Check if a given object implements the LeaderboardItem interface. + */ +export function instanceOfLeaderboardItem(value: object): value is LeaderboardItem { + return true; +} + +export function LeaderboardItemFromJSON(json: any): LeaderboardItem { + return LeaderboardItemFromJSONTyped(json, false); +} + +export function LeaderboardItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): LeaderboardItem { + if (json == null) { + return json; + } + return { + + 'name': json['name'] == null ? undefined : json['name'], + 'displayName': json['display_name'] == null ? undefined : json['display_name'], + 'photoUrl': json['photo_url'] == null ? undefined : json['photo_url'], + 'level': json['level'] == null ? undefined : json['level'], + 'experience': json['experience'] == null ? undefined : json['experience'], + 'points': json['points'] == null ? undefined : json['points'], + }; +} + +export function LeaderboardItemToJSON(json: any): LeaderboardItem { + return LeaderboardItemToJSONTyped(json, false); +} + +export function LeaderboardItemToJSONTyped(value?: LeaderboardItem | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'name': value['name'], + 'display_name': value['displayName'], + 'photo_url': value['photoUrl'], + 'level': value['level'], + 'experience': value['experience'], + 'points': value['points'], + }; +} + diff --git a/src/models/LeaderboardOrder.ts b/src/models/LeaderboardOrder.ts new file mode 100644 index 0000000..1517b6c --- /dev/null +++ b/src/models/LeaderboardOrder.ts @@ -0,0 +1,53 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const LeaderboardOrder = { + Level: 'level', + Points: 'points' +} as const; +export type LeaderboardOrder = typeof LeaderboardOrder[keyof typeof LeaderboardOrder]; + + +export function instanceOfLeaderboardOrder(value: any): boolean { + for (const key in LeaderboardOrder) { + if (Object.prototype.hasOwnProperty.call(LeaderboardOrder, key)) { + if (LeaderboardOrder[key as keyof typeof LeaderboardOrder] === value) { + return true; + } + } + } + return false; +} + +export function LeaderboardOrderFromJSON(json: any): LeaderboardOrder { + return LeaderboardOrderFromJSONTyped(json, false); +} + +export function LeaderboardOrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): LeaderboardOrder { + return json as LeaderboardOrder; +} + +export function LeaderboardOrderToJSON(value?: LeaderboardOrder | null): any { + return value as any; +} + +export function LeaderboardOrderToJSONTyped(value: any, ignoreDiscriminator: boolean): LeaderboardOrder { + return value as LeaderboardOrder; +} + diff --git a/src/models/LoginProvider.ts b/src/models/LoginProvider.ts new file mode 100644 index 0000000..004a725 --- /dev/null +++ b/src/models/LoginProvider.ts @@ -0,0 +1,58 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const LoginProvider = { + Steam: 'steam', + Epic: 'epic', + Discord: 'discord', + Microsoft: 'microsoft', + Playstation: 'playstation', + Google: 'google', + Apple: 'apple' +} as const; +export type LoginProvider = typeof LoginProvider[keyof typeof LoginProvider]; + + +export function instanceOfLoginProvider(value: any): boolean { + for (const key in LoginProvider) { + if (Object.prototype.hasOwnProperty.call(LoginProvider, key)) { + if (LoginProvider[key as keyof typeof LoginProvider] === value) { + return true; + } + } + } + return false; +} + +export function LoginProviderFromJSON(json: any): LoginProvider { + return LoginProviderFromJSONTyped(json, false); +} + +export function LoginProviderFromJSONTyped(json: any, ignoreDiscriminator: boolean): LoginProvider { + return json as LoginProvider; +} + +export function LoginProviderToJSON(value?: LoginProvider | null): any { + return value as any; +} + +export function LoginProviderToJSONTyped(value: any, ignoreDiscriminator: boolean): LoginProvider { + return value as LoginProvider; +} + diff --git a/src/models/LoginRequest.ts b/src/models/LoginRequest.ts new file mode 100644 index 0000000..f31d6fb --- /dev/null +++ b/src/models/LoginRequest.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface LoginRequest + */ +export interface LoginRequest { + /** + * + * @type {string} + * @memberof LoginRequest + */ + login?: string | null; + /** + * + * @type {string} + * @memberof LoginRequest + */ + password?: string | null; +} + +/** + * Check if a given object implements the LoginRequest interface. + */ +export function instanceOfLoginRequest(value: object): value is LoginRequest { + return true; +} + +export function LoginRequestFromJSON(json: any): LoginRequest { + return LoginRequestFromJSONTyped(json, false); +} + +export function LoginRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): LoginRequest { + if (json == null) { + return json; + } + return { + + 'login': json['login'] == null ? undefined : json['login'], + 'password': json['password'] == null ? undefined : json['password'], + }; +} + +export function LoginRequestToJSON(json: any): LoginRequest { + return LoginRequestToJSONTyped(json, false); +} + +export function LoginRequestToJSONTyped(value?: LoginRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'login': value['login'], + 'password': value['password'], + }; +} + diff --git a/src/models/LoginResponse.ts b/src/models/LoginResponse.ts new file mode 100644 index 0000000..8df74b8 --- /dev/null +++ b/src/models/LoginResponse.ts @@ -0,0 +1,97 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { UserInfo } from './UserInfo'; +import { + UserInfoFromJSON, + UserInfoFromJSONTyped, + UserInfoToJSON, + UserInfoToJSONTyped, +} from './UserInfo'; + +/** + * + * @export + * @interface LoginResponse + */ +export interface LoginResponse { + /** + * + * @type {UserInfo} + * @memberof LoginResponse + */ + user?: UserInfo; + /** + * + * @type {string} + * @memberof LoginResponse + */ + accessToken?: string | null; + /** + * + * @type {string} + * @memberof LoginResponse + */ + refreshToken?: string | null; + /** + * + * @type {number} + * @memberof LoginResponse + */ + expiresIn?: number; +} + +/** + * Check if a given object implements the LoginResponse interface. + */ +export function instanceOfLoginResponse(value: object): value is LoginResponse { + return true; +} + +export function LoginResponseFromJSON(json: any): LoginResponse { + return LoginResponseFromJSONTyped(json, false); +} + +export function LoginResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): LoginResponse { + if (json == null) { + return json; + } + return { + + 'user': json['user'] == null ? undefined : UserInfoFromJSON(json['user']), + 'accessToken': json['access_token'] == null ? undefined : json['access_token'], + 'refreshToken': json['refresh_token'] == null ? undefined : json['refresh_token'], + 'expiresIn': json['expires_in'] == null ? undefined : json['expires_in'], + }; +} + +export function LoginResponseToJSON(json: any): LoginResponse { + return LoginResponseToJSONTyped(json, false); +} + +export function LoginResponseToJSONTyped(value?: LoginResponse | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'user': UserInfoToJSON(value['user']), + 'access_token': value['accessToken'], + 'refresh_token': value['refreshToken'], + 'expires_in': value['expiresIn'], + }; +} + diff --git a/src/models/Package.ts b/src/models/Package.ts new file mode 100644 index 0000000..472e919 --- /dev/null +++ b/src/models/Package.ts @@ -0,0 +1,153 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface Package + */ +export interface Package { + /** + * + * @type {string} + * @memberof Package + */ + id?: string; + /** + * + * @type {string} + * @memberof Package + */ + name?: string | null; + /** + * + * @type {string} + * @memberof Package + */ + description?: string | null; + /** + * + * @type {string} + * @memberof Package + */ + imageUrl?: string | null; + /** + * + * @type {string} + * @memberof Package + */ + authorId?: string; + /** + * + * @type {string} + * @memberof Package + */ + version?: string | null; + /** + * + * @type {string} + * @memberof Package + */ + fileUrl?: string | null; + /** + * + * @type {number} + * @memberof Package + */ + rawSize?: number; + /** + * + * @type {number} + * @memberof Package + */ + downloadCount?: number; + /** + * + * @type {Date} + * @memberof Package + */ + lastDownload?: Date | null; + /** + * + * @type {Date} + * @memberof Package + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Package + */ + updated?: Date | null; +} + +/** + * Check if a given object implements the Package interface. + */ +export function instanceOfPackage(value: object): value is Package { + return true; +} + +export function PackageFromJSON(json: any): Package { + return PackageFromJSONTyped(json, false); +} + +export function PackageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Package { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'description': json['description'] == null ? undefined : json['description'], + 'imageUrl': json['image_url'] == null ? undefined : json['image_url'], + 'authorId': json['author_id'] == null ? undefined : json['author_id'], + 'version': json['version'] == null ? undefined : json['version'], + 'fileUrl': json['file_url'] == null ? undefined : json['file_url'], + 'rawSize': json['raw_size'] == null ? undefined : json['raw_size'], + 'downloadCount': json['download_count'] == null ? undefined : json['download_count'], + 'lastDownload': json['last_download'] == null ? undefined : (new Date(json['last_download'])), + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function PackageToJSON(json: any): Package { + return PackageToJSONTyped(json, false); +} + +export function PackageToJSONTyped(value?: Package | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'description': value['description'], + 'image_url': value['imageUrl'], + 'author_id': value['authorId'], + 'version': value['version'], + 'file_url': value['fileUrl'], + 'raw_size': value['rawSize'], + 'download_count': value['downloadCount'], + 'last_download': value['lastDownload'] == null ? undefined : ((value['lastDownload'] as any).toISOString()), + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/Profile.ts b/src/models/Profile.ts new file mode 100644 index 0000000..0fc4175 --- /dev/null +++ b/src/models/Profile.ts @@ -0,0 +1,201 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface Profile + */ +export interface Profile { + /** + * + * @type {string} + * @memberof Profile + */ + id?: string; + /** + * + * @type {string} + * @memberof Profile + */ + uuid?: string; + /** + * + * @type {string} + * @memberof Profile + */ + name?: string | null; + /** + * + * @type {string} + * @memberof Profile + */ + displayName?: string | null; + /** + * + * @type {boolean} + * @memberof Profile + */ + verified?: boolean; + /** + * + * @type {number} + * @memberof Profile + */ + level?: number; + /** + * + * @type {number} + * @memberof Profile + */ + experience?: number; + /** + * + * @type {boolean} + * @memberof Profile + */ + publicBirthday?: boolean; + /** + * + * @type {Date} + * @memberof Profile + */ + birthday?: Date | null; + /** + * + * @type {number} + * @memberof Profile + */ + points?: number; + /** + * + * @type {string} + * @memberof Profile + */ + location?: string | null; + /** + * + * @type {string} + * @memberof Profile + */ + photoUrl?: string | null; + /** + * + * @type {string} + * @memberof Profile + */ + bannerUrl?: string | null; + /** + * + * @type {Date} + * @memberof Profile + */ + lastOnline?: Date | null; + /** + * + * @type {string} + * @memberof Profile + */ + biography?: string | null; + /** + * + * @type {number} + * @memberof Profile + */ + viewCount?: number; + /** + * + * @type {Date} + * @memberof Profile + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Profile + */ + updated?: Date | null; +} + +/** + * Check if a given object implements the Profile interface. + */ +export function instanceOfProfile(value: object): value is Profile { + return true; +} + +export function ProfileFromJSON(json: any): Profile { + return ProfileFromJSONTyped(json, false); +} + +export function ProfileFromJSONTyped(json: any, ignoreDiscriminator: boolean): Profile { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'uuid': json['uuid'] == null ? undefined : json['uuid'], + 'name': json['name'] == null ? undefined : json['name'], + 'displayName': json['display_name'] == null ? undefined : json['display_name'], + 'verified': json['verified'] == null ? undefined : json['verified'], + 'level': json['level'] == null ? undefined : json['level'], + 'experience': json['experience'] == null ? undefined : json['experience'], + 'publicBirthday': json['public_birthday'] == null ? undefined : json['public_birthday'], + 'birthday': json['birthday'] == null ? undefined : (new Date(json['birthday'])), + 'points': json['points'] == null ? undefined : json['points'], + 'location': json['location'] == null ? undefined : json['location'], + 'photoUrl': json['photo_url'] == null ? undefined : json['photo_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'lastOnline': json['last_online'] == null ? undefined : (new Date(json['last_online'])), + 'biography': json['biography'] == null ? undefined : json['biography'], + 'viewCount': json['view_count'] == null ? undefined : json['view_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function ProfileToJSON(json: any): Profile { + return ProfileToJSONTyped(json, false); +} + +export function ProfileToJSONTyped(value?: Profile | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'uuid': value['uuid'], + 'name': value['name'], + 'display_name': value['displayName'], + 'verified': value['verified'], + 'level': value['level'], + 'experience': value['experience'], + 'public_birthday': value['publicBirthday'], + 'birthday': value['birthday'] == null ? undefined : ((value['birthday'] as any).toISOString().substring(0,10)), + 'points': value['points'], + 'location': value['location'], + 'photo_url': value['photoUrl'], + 'banner_url': value['bannerUrl'], + 'last_online': value['lastOnline'] == null ? undefined : ((value['lastOnline'] as any).toISOString()), + 'biography': value['biography'], + 'view_count': value['viewCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/ProfileGame.ts b/src/models/ProfileGame.ts new file mode 100644 index 0000000..307a2f0 --- /dev/null +++ b/src/models/ProfileGame.ts @@ -0,0 +1,145 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface ProfileGame + */ +export interface ProfileGame { + /** + * + * @type {string} + * @memberof ProfileGame + */ + id?: string; + /** + * + * @type {string} + * @memberof ProfileGame + */ + name?: string | null; + /** + * + * @type {string} + * @memberof ProfileGame + */ + capsuleImageUrl?: string | null; + /** + * + * @type {string} + * @memberof ProfileGame + */ + libraryImageUrl?: string | null; + /** + * + * @type {string} + * @memberof ProfileGame + */ + slug?: string | null; + /** + * + * @type {number} + * @memberof ProfileGame + */ + timeUsed?: number; + /** + * + * @type {number} + * @memberof ProfileGame + */ + unlockedAchievements?: number; + /** + * + * @type {number} + * @memberof ProfileGame + */ + totalAchievements?: number; + /** + * + * @type {any} + * @memberof ProfileGame + */ + stats?: any | null; + /** + * + * @type {Date} + * @memberof ProfileGame + */ + acquired?: Date; + /** + * + * @type {Date} + * @memberof ProfileGame + */ + lastUsed?: Date | null; +} + +/** + * Check if a given object implements the ProfileGame interface. + */ +export function instanceOfProfileGame(value: object): value is ProfileGame { + return true; +} + +export function ProfileGameFromJSON(json: any): ProfileGame { + return ProfileGameFromJSONTyped(json, false); +} + +export function ProfileGameFromJSONTyped(json: any, ignoreDiscriminator: boolean): ProfileGame { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'capsuleImageUrl': json['capsule_image_url'] == null ? undefined : json['capsule_image_url'], + 'libraryImageUrl': json['library_image_url'] == null ? undefined : json['library_image_url'], + 'slug': json['slug'] == null ? undefined : json['slug'], + 'timeUsed': json['time_used'] == null ? undefined : json['time_used'], + 'unlockedAchievements': json['unlocked_achievements'] == null ? undefined : json['unlocked_achievements'], + 'totalAchievements': json['total_achievements'] == null ? undefined : json['total_achievements'], + 'stats': json['stats'] == null ? undefined : json['stats'], + 'acquired': json['acquired'] == null ? undefined : (new Date(json['acquired'])), + 'lastUsed': json['last_used'] == null ? undefined : (new Date(json['last_used'])), + }; +} + +export function ProfileGameToJSON(json: any): ProfileGame { + return ProfileGameToJSONTyped(json, false); +} + +export function ProfileGameToJSONTyped(value?: ProfileGame | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'capsule_image_url': value['capsuleImageUrl'], + 'library_image_url': value['libraryImageUrl'], + 'slug': value['slug'], + 'time_used': value['timeUsed'], + 'unlocked_achievements': value['unlockedAchievements'], + 'total_achievements': value['totalAchievements'], + 'stats': value['stats'], + 'acquired': value['acquired'] == null ? undefined : ((value['acquired']).toISOString()), + 'last_used': value['lastUsed'] == null ? undefined : ((value['lastUsed'] as any).toISOString()), + }; +} + diff --git a/src/models/ProfileGroup.ts b/src/models/ProfileGroup.ts new file mode 100644 index 0000000..bc070fa --- /dev/null +++ b/src/models/ProfileGroup.ts @@ -0,0 +1,147 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { GroupRank } from './GroupRank'; +import { + GroupRankFromJSON, + GroupRankFromJSONTyped, + GroupRankToJSON, + GroupRankToJSONTyped, +} from './GroupRank'; + +/** + * + * @export + * @interface ProfileGroup + */ +export interface ProfileGroup { + /** + * + * @type {string} + * @memberof ProfileGroup + */ + id?: string; + /** + * + * @type {string} + * @memberof ProfileGroup + */ + uuid?: string; + /** + * + * @type {string} + * @memberof ProfileGroup + */ + name?: string | null; + /** + * + * @type {string} + * @memberof ProfileGroup + */ + tag?: string | null; + /** + * + * @type {number} + * @memberof ProfileGroup + */ + privacy?: number; + /** + * + * @type {boolean} + * @memberof ProfileGroup + */ + verified?: boolean; + /** + * + * @type {string} + * @memberof ProfileGroup + */ + photoUrl?: string | null; + /** + * + * @type {number} + * @memberof ProfileGroup + */ + memberCount?: number; + /** + * + * @type {GroupRank} + * @memberof ProfileGroup + */ + rank?: GroupRank; + /** + * + * @type {Date} + * @memberof ProfileGroup + */ + since?: Date; +} + + + +/** + * Check if a given object implements the ProfileGroup interface. + */ +export function instanceOfProfileGroup(value: object): value is ProfileGroup { + return true; +} + +export function ProfileGroupFromJSON(json: any): ProfileGroup { + return ProfileGroupFromJSONTyped(json, false); +} + +export function ProfileGroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): ProfileGroup { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'uuid': json['uuid'] == null ? undefined : json['uuid'], + 'name': json['name'] == null ? undefined : json['name'], + 'tag': json['tag'] == null ? undefined : json['tag'], + 'privacy': json['privacy'] == null ? undefined : json['privacy'], + 'verified': json['verified'] == null ? undefined : json['verified'], + 'photoUrl': json['photo_url'] == null ? undefined : json['photo_url'], + 'memberCount': json['member_count'] == null ? undefined : json['member_count'], + 'rank': json['rank'] == null ? undefined : GroupRankFromJSON(json['rank']), + 'since': json['since'] == null ? undefined : (new Date(json['since'])), + }; +} + +export function ProfileGroupToJSON(json: any): ProfileGroup { + return ProfileGroupToJSONTyped(json, false); +} + +export function ProfileGroupToJSONTyped(value?: ProfileGroup | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'uuid': value['uuid'], + 'name': value['name'], + 'tag': value['tag'], + 'privacy': value['privacy'], + 'verified': value['verified'], + 'photo_url': value['photoUrl'], + 'member_count': value['memberCount'], + 'rank': GroupRankToJSON(value['rank']), + 'since': value['since'] == null ? undefined : ((value['since']).toISOString()), + }; +} + diff --git a/src/models/RefreshRequest.ts b/src/models/RefreshRequest.ts new file mode 100644 index 0000000..b9bf712 --- /dev/null +++ b/src/models/RefreshRequest.ts @@ -0,0 +1,65 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface RefreshRequest + */ +export interface RefreshRequest { + /** + * + * @type {string} + * @memberof RefreshRequest + */ + refreshToken?: string | null; +} + +/** + * Check if a given object implements the RefreshRequest interface. + */ +export function instanceOfRefreshRequest(value: object): value is RefreshRequest { + return true; +} + +export function RefreshRequestFromJSON(json: any): RefreshRequest { + return RefreshRequestFromJSONTyped(json, false); +} + +export function RefreshRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RefreshRequest { + if (json == null) { + return json; + } + return { + + 'refreshToken': json['refresh_token'] == null ? undefined : json['refresh_token'], + }; +} + +export function RefreshRequestToJSON(json: any): RefreshRequest { + return RefreshRequestToJSONTyped(json, false); +} + +export function RefreshRequestToJSONTyped(value?: RefreshRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'refresh_token': value['refreshToken'], + }; +} + diff --git a/src/models/RegisterRequest.ts b/src/models/RegisterRequest.ts new file mode 100644 index 0000000..d279186 --- /dev/null +++ b/src/models/RegisterRequest.ts @@ -0,0 +1,91 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface RegisterRequest + */ +export interface RegisterRequest { + /** + * + * @type {string} + * @memberof RegisterRequest + */ + uuid?: string | null; + /** + * + * @type {string} + * @memberof RegisterRequest + */ + name: string; + /** + * + * @type {string} + * @memberof RegisterRequest + */ + email?: string | null; + /** + * + * @type {string} + * @memberof RegisterRequest + */ + password: string; +} + +/** + * Check if a given object implements the RegisterRequest interface. + */ +export function instanceOfRegisterRequest(value: object): value is RegisterRequest { + if (!('name' in value) || value['name'] === undefined) return false; + if (!('password' in value) || value['password'] === undefined) return false; + return true; +} + +export function RegisterRequestFromJSON(json: any): RegisterRequest { + return RegisterRequestFromJSONTyped(json, false); +} + +export function RegisterRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RegisterRequest { + if (json == null) { + return json; + } + return { + + 'uuid': json['uuid'] == null ? undefined : json['uuid'], + 'name': json['name'], + 'email': json['email'] == null ? undefined : json['email'], + 'password': json['password'], + }; +} + +export function RegisterRequestToJSON(json: any): RegisterRequest { + return RegisterRequestToJSONTyped(json, false); +} + +export function RegisterRequestToJSONTyped(value?: RegisterRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'uuid': value['uuid'], + 'name': value['name'], + 'email': value['email'], + 'password': value['password'], + }; +} + diff --git a/src/models/ResponseType.ts b/src/models/ResponseType.ts new file mode 100644 index 0000000..7b36282 --- /dev/null +++ b/src/models/ResponseType.ts @@ -0,0 +1,53 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const ResponseType = { + Code: 'code', + Token: 'token' +} as const; +export type ResponseType = typeof ResponseType[keyof typeof ResponseType]; + + +export function instanceOfResponseType(value: any): boolean { + for (const key in ResponseType) { + if (Object.prototype.hasOwnProperty.call(ResponseType, key)) { + if (ResponseType[key as keyof typeof ResponseType] === value) { + return true; + } + } + } + return false; +} + +export function ResponseTypeFromJSON(json: any): ResponseType { + return ResponseTypeFromJSONTyped(json, false); +} + +export function ResponseTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResponseType { + return json as ResponseType; +} + +export function ResponseTypeToJSON(value?: ResponseType | null): any { + return value as any; +} + +export function ResponseTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): ResponseType { + return value as ResponseType; +} + diff --git a/src/models/RevokeRequest.ts b/src/models/RevokeRequest.ts new file mode 100644 index 0000000..c4f133a --- /dev/null +++ b/src/models/RevokeRequest.ts @@ -0,0 +1,83 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { TokenHintType } from './TokenHintType'; +import { + TokenHintTypeFromJSON, + TokenHintTypeFromJSONTyped, + TokenHintTypeToJSON, + TokenHintTypeToJSONTyped, +} from './TokenHintType'; + +/** + * + * @export + * @interface RevokeRequest + */ +export interface RevokeRequest { + /** + * + * @type {string} + * @memberof RevokeRequest + */ + token?: string | null; + /** + * + * @type {TokenHintType} + * @memberof RevokeRequest + */ + tokenTypeHint?: TokenHintType; +} + + + +/** + * Check if a given object implements the RevokeRequest interface. + */ +export function instanceOfRevokeRequest(value: object): value is RevokeRequest { + return true; +} + +export function RevokeRequestFromJSON(json: any): RevokeRequest { + return RevokeRequestFromJSONTyped(json, false); +} + +export function RevokeRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RevokeRequest { + if (json == null) { + return json; + } + return { + + 'token': json['token'] == null ? undefined : json['token'], + 'tokenTypeHint': json['token_type_hint'] == null ? undefined : TokenHintTypeFromJSON(json['token_type_hint']), + }; +} + +export function RevokeRequestToJSON(json: any): RevokeRequest { + return RevokeRequestToJSONTyped(json, false); +} + +export function RevokeRequestToJSONTyped(value?: RevokeRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'token': value['token'], + 'token_type_hint': TokenHintTypeToJSON(value['tokenTypeHint']), + }; +} + diff --git a/src/models/SearchRequest.ts b/src/models/SearchRequest.ts new file mode 100644 index 0000000..6722f75 --- /dev/null +++ b/src/models/SearchRequest.ts @@ -0,0 +1,99 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { SearchType } from './SearchType'; +import { + SearchTypeFromJSON, + SearchTypeFromJSONTyped, + SearchTypeToJSON, + SearchTypeToJSONTyped, +} from './SearchType'; + +/** + * + * @export + * @interface SearchRequest + */ +export interface SearchRequest { + /** + * + * @type {SearchType} + * @memberof SearchRequest + */ + type?: SearchType; + /** + * + * @type {string} + * @memberof SearchRequest + */ + query?: string | null; + /** + * + * @type {number} + * @memberof SearchRequest + */ + page?: number | null; + /** + * + * @type {string} + * @memberof SearchRequest + */ + gameId?: string | null; +} + + + +/** + * Check if a given object implements the SearchRequest interface. + */ +export function instanceOfSearchRequest(value: object): value is SearchRequest { + return true; +} + +export function SearchRequestFromJSON(json: any): SearchRequest { + return SearchRequestFromJSONTyped(json, false); +} + +export function SearchRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): SearchRequest { + if (json == null) { + return json; + } + return { + + 'type': json['type'] == null ? undefined : SearchTypeFromJSON(json['type']), + 'query': json['query'] == null ? undefined : json['query'], + 'page': json['page'] == null ? undefined : json['page'], + 'gameId': json['game_id'] == null ? undefined : json['game_id'], + }; +} + +export function SearchRequestToJSON(json: any): SearchRequest { + return SearchRequestToJSONTyped(json, false); +} + +export function SearchRequestToJSONTyped(value?: SearchRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'type': SearchTypeToJSON(value['type']), + 'query': value['query'], + 'page': value['page'], + 'game_id': value['gameId'], + }; +} + diff --git a/src/models/SearchType.ts b/src/models/SearchType.ts new file mode 100644 index 0000000..604dd7e --- /dev/null +++ b/src/models/SearchType.ts @@ -0,0 +1,55 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const SearchType = { + User: 'user', + Group: 'group', + Server: 'server', + Cluster: 'cluster' +} as const; +export type SearchType = typeof SearchType[keyof typeof SearchType]; + + +export function instanceOfSearchType(value: any): boolean { + for (const key in SearchType) { + if (Object.prototype.hasOwnProperty.call(SearchType, key)) { + if (SearchType[key as keyof typeof SearchType] === value) { + return true; + } + } + } + return false; +} + +export function SearchTypeFromJSON(json: any): SearchType { + return SearchTypeFromJSONTyped(json, false); +} + +export function SearchTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): SearchType { + return json as SearchType; +} + +export function SearchTypeToJSON(value?: SearchType | null): any { + return value as any; +} + +export function SearchTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): SearchType { + return value as SearchType; +} + diff --git a/src/models/ServerMetrics.ts b/src/models/ServerMetrics.ts new file mode 100644 index 0000000..3746aaf --- /dev/null +++ b/src/models/ServerMetrics.ts @@ -0,0 +1,81 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface ServerMetrics + */ +export interface ServerMetrics { + /** + * + * @type {number} + * @memberof ServerMetrics + */ + serverCount?: number; + /** + * + * @type {number} + * @memberof ServerMetrics + */ + packageCount?: number; + /** + * + * @type {number} + * @memberof ServerMetrics + */ + countryCount?: number; +} + +/** + * Check if a given object implements the ServerMetrics interface. + */ +export function instanceOfServerMetrics(value: object): value is ServerMetrics { + return true; +} + +export function ServerMetricsFromJSON(json: any): ServerMetrics { + return ServerMetricsFromJSONTyped(json, false); +} + +export function ServerMetricsFromJSONTyped(json: any, ignoreDiscriminator: boolean): ServerMetrics { + if (json == null) { + return json; + } + return { + + 'serverCount': json['server_count'] == null ? undefined : json['server_count'], + 'packageCount': json['package_count'] == null ? undefined : json['package_count'], + 'countryCount': json['country_count'] == null ? undefined : json['country_count'], + }; +} + +export function ServerMetricsToJSON(json: any): ServerMetrics { + return ServerMetricsToJSONTyped(json, false); +} + +export function ServerMetricsToJSONTyped(value?: ServerMetrics | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'server_count': value['serverCount'], + 'package_count': value['packageCount'], + 'country_count': value['countryCount'], + }; +} + diff --git a/src/models/ServerStatus.ts b/src/models/ServerStatus.ts new file mode 100644 index 0000000..2723f95 --- /dev/null +++ b/src/models/ServerStatus.ts @@ -0,0 +1,54 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const ServerStatus = { + Unknown: 'unknown', + Offline: 'offline', + Online: 'online' +} as const; +export type ServerStatus = typeof ServerStatus[keyof typeof ServerStatus]; + + +export function instanceOfServerStatus(value: any): boolean { + for (const key in ServerStatus) { + if (Object.prototype.hasOwnProperty.call(ServerStatus, key)) { + if (ServerStatus[key as keyof typeof ServerStatus] === value) { + return true; + } + } + } + return false; +} + +export function ServerStatusFromJSON(json: any): ServerStatus { + return ServerStatusFromJSONTyped(json, false); +} + +export function ServerStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): ServerStatus { + return json as ServerStatus; +} + +export function ServerStatusToJSON(value?: ServerStatus | null): any { + return value as any; +} + +export function ServerStatusToJSONTyped(value: any, ignoreDiscriminator: boolean): ServerStatus { + return value as ServerStatus; +} + diff --git a/src/models/Subscription.ts b/src/models/Subscription.ts new file mode 100644 index 0000000..fca55e3 --- /dev/null +++ b/src/models/Subscription.ts @@ -0,0 +1,112 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface Subscription + */ +export interface Subscription { + /** + * + * @type {string} + * @memberof Subscription + */ + id?: string; + /** + * + * @type {string} + * @memberof Subscription + */ + name?: string | null; + /** + * + * @type {string} + * @memberof Subscription + */ + description?: string | null; + /** + * + * @type {string} + * @memberof Subscription + */ + imageUrl?: string | null; + /** + * + * @type {{ [key: string]: number; }} + * @memberof Subscription + */ + readonly prices?: { [key: string]: number; } | null; + /** + * + * @type {Date} + * @memberof Subscription + */ + created?: Date; + /** + * + * @type {Date} + * @memberof Subscription + */ + updated?: Date | null; +} + +/** + * Check if a given object implements the Subscription interface. + */ +export function instanceOfSubscription(value: object): value is Subscription { + return true; +} + +export function SubscriptionFromJSON(json: any): Subscription { + return SubscriptionFromJSONTyped(json, false); +} + +export function SubscriptionFromJSONTyped(json: any, ignoreDiscriminator: boolean): Subscription { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'name': json['name'] == null ? undefined : json['name'], + 'description': json['description'] == null ? undefined : json['description'], + 'imageUrl': json['image_url'] == null ? undefined : json['image_url'], + 'prices': json['prices'] == null ? undefined : json['prices'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function SubscriptionToJSON(json: any): Subscription { + return SubscriptionToJSONTyped(json, false); +} + +export function SubscriptionToJSONTyped(value?: Omit | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'name': value['name'], + 'description': value['description'], + 'image_url': value['imageUrl'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/TokenHintType.ts b/src/models/TokenHintType.ts new file mode 100644 index 0000000..4853958 --- /dev/null +++ b/src/models/TokenHintType.ts @@ -0,0 +1,53 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const TokenHintType = { + AccessToken: 'access_token', + RefreshToken: 'refresh_token' +} as const; +export type TokenHintType = typeof TokenHintType[keyof typeof TokenHintType]; + + +export function instanceOfTokenHintType(value: any): boolean { + for (const key in TokenHintType) { + if (Object.prototype.hasOwnProperty.call(TokenHintType, key)) { + if (TokenHintType[key as keyof typeof TokenHintType] === value) { + return true; + } + } + } + return false; +} + +export function TokenHintTypeFromJSON(json: any): TokenHintType { + return TokenHintTypeFromJSONTyped(json, false); +} + +export function TokenHintTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): TokenHintType { + return json as TokenHintType; +} + +export function TokenHintTypeToJSON(value?: TokenHintType | null): any { + return value as any; +} + +export function TokenHintTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): TokenHintType { + return value as TokenHintType; +} + diff --git a/src/models/TokenRequest.ts b/src/models/TokenRequest.ts new file mode 100644 index 0000000..6d92867 --- /dev/null +++ b/src/models/TokenRequest.ts @@ -0,0 +1,131 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { GrantType } from './GrantType'; +import { + GrantTypeFromJSON, + GrantTypeFromJSONTyped, + GrantTypeToJSON, + GrantTypeToJSONTyped, +} from './GrantType'; + +/** + * + * @export + * @interface TokenRequest + */ +export interface TokenRequest { + /** + * + * @type {GrantType} + * @memberof TokenRequest + */ + grantType?: GrantType; + /** + * + * @type {string} + * @memberof TokenRequest + */ + code?: string | null; + /** + * + * @type {string} + * @memberof TokenRequest + */ + username?: string | null; + /** + * + * @type {string} + * @memberof TokenRequest + */ + password?: string | null; + /** + * + * @type {string} + * @memberof TokenRequest + */ + refreshToken?: string | null; + /** + * + * @type {string} + * @memberof TokenRequest + */ + clientId?: string | null; + /** + * + * @type {string} + * @memberof TokenRequest + */ + redirectUri?: string | null; + /** + * + * @type {string} + * @memberof TokenRequest + */ + codeVerifier?: string | null; +} + + + +/** + * Check if a given object implements the TokenRequest interface. + */ +export function instanceOfTokenRequest(value: object): value is TokenRequest { + return true; +} + +export function TokenRequestFromJSON(json: any): TokenRequest { + return TokenRequestFromJSONTyped(json, false); +} + +export function TokenRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): TokenRequest { + if (json == null) { + return json; + } + return { + + 'grantType': json['grant_type'] == null ? undefined : GrantTypeFromJSON(json['grant_type']), + 'code': json['code'] == null ? undefined : json['code'], + 'username': json['username'] == null ? undefined : json['username'], + 'password': json['password'] == null ? undefined : json['password'], + 'refreshToken': json['refresh_token'] == null ? undefined : json['refresh_token'], + 'clientId': json['client_id'] == null ? undefined : json['client_id'], + 'redirectUri': json['redirect_uri'] == null ? undefined : json['redirect_uri'], + 'codeVerifier': json['code_verifier'] == null ? undefined : json['code_verifier'], + }; +} + +export function TokenRequestToJSON(json: any): TokenRequest { + return TokenRequestToJSONTyped(json, false); +} + +export function TokenRequestToJSONTyped(value?: TokenRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'grant_type': GrantTypeToJSON(value['grantType']), + 'code': value['code'], + 'username': value['username'], + 'password': value['password'], + 'refresh_token': value['refreshToken'], + 'client_id': value['clientId'], + 'redirect_uri': value['redirectUri'], + 'code_verifier': value['codeVerifier'], + }; +} + diff --git a/src/models/TokenResponse.ts b/src/models/TokenResponse.ts new file mode 100644 index 0000000..711d64b --- /dev/null +++ b/src/models/TokenResponse.ts @@ -0,0 +1,115 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { TokenType } from './TokenType'; +import { + TokenTypeFromJSON, + TokenTypeFromJSONTyped, + TokenTypeToJSON, + TokenTypeToJSONTyped, +} from './TokenType'; + +/** + * + * @export + * @interface TokenResponse + */ +export interface TokenResponse { + /** + * + * @type {TokenType} + * @memberof TokenResponse + */ + tokenType?: TokenType; + /** + * + * @type {string} + * @memberof TokenResponse + */ + accessToken?: string | null; + /** + * + * @type {string} + * @memberof TokenResponse + */ + refreshToken?: string | null; + /** + * + * @type {string} + * @memberof TokenResponse + */ + scope?: string | null; + /** + * + * @type {string} + * @memberof TokenResponse + */ + state?: string | null; + /** + * + * @type {number} + * @memberof TokenResponse + */ + expiresIn?: number; +} + + + +/** + * Check if a given object implements the TokenResponse interface. + */ +export function instanceOfTokenResponse(value: object): value is TokenResponse { + return true; +} + +export function TokenResponseFromJSON(json: any): TokenResponse { + return TokenResponseFromJSONTyped(json, false); +} + +export function TokenResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TokenResponse { + if (json == null) { + return json; + } + return { + + 'tokenType': json['token_type'] == null ? undefined : TokenTypeFromJSON(json['token_type']), + 'accessToken': json['access_token'] == null ? undefined : json['access_token'], + 'refreshToken': json['refresh_token'] == null ? undefined : json['refresh_token'], + 'scope': json['scope'] == null ? undefined : json['scope'], + 'state': json['state'] == null ? undefined : json['state'], + 'expiresIn': json['expires_in'] == null ? undefined : json['expires_in'], + }; +} + +export function TokenResponseToJSON(json: any): TokenResponse { + return TokenResponseToJSONTyped(json, false); +} + +export function TokenResponseToJSONTyped(value?: TokenResponse | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'token_type': TokenTypeToJSON(value['tokenType']), + 'access_token': value['accessToken'], + 'refresh_token': value['refreshToken'], + 'scope': value['scope'], + 'state': value['state'], + 'expires_in': value['expiresIn'], + }; +} + diff --git a/src/models/TokenType.ts b/src/models/TokenType.ts new file mode 100644 index 0000000..0fe9cdc --- /dev/null +++ b/src/models/TokenType.ts @@ -0,0 +1,52 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const TokenType = { + Bearer: 'bearer' +} as const; +export type TokenType = typeof TokenType[keyof typeof TokenType]; + + +export function instanceOfTokenType(value: any): boolean { + for (const key in TokenType) { + if (Object.prototype.hasOwnProperty.call(TokenType, key)) { + if (TokenType[key as keyof typeof TokenType] === value) { + return true; + } + } + } + return false; +} + +export function TokenTypeFromJSON(json: any): TokenType { + return TokenTypeFromJSONTyped(json, false); +} + +export function TokenTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): TokenType { + return json as TokenType; +} + +export function TokenTypeToJSON(value?: TokenType | null): any { + return value as any; +} + +export function TokenTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): TokenType { + return value as TokenType; +} + diff --git a/src/models/UpdateProfile.ts b/src/models/UpdateProfile.ts new file mode 100644 index 0000000..4888cb3 --- /dev/null +++ b/src/models/UpdateProfile.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface UpdateProfile + */ +export interface UpdateProfile { + /** + * + * @type {string} + * @memberof UpdateProfile + */ + displayName?: string | null; + /** + * + * @type {string} + * @memberof UpdateProfile + */ + biography?: string | null; +} + +/** + * Check if a given object implements the UpdateProfile interface. + */ +export function instanceOfUpdateProfile(value: object): value is UpdateProfile { + return true; +} + +export function UpdateProfileFromJSON(json: any): UpdateProfile { + return UpdateProfileFromJSONTyped(json, false); +} + +export function UpdateProfileFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateProfile { + if (json == null) { + return json; + } + return { + + 'displayName': json['display_name'] == null ? undefined : json['display_name'], + 'biography': json['biography'] == null ? undefined : json['biography'], + }; +} + +export function UpdateProfileToJSON(json: any): UpdateProfile { + return UpdateProfileToJSONTyped(json, false); +} + +export function UpdateProfileToJSONTyped(value?: UpdateProfile | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'display_name': value['displayName'], + 'biography': value['biography'], + }; +} + diff --git a/src/models/UserInfo.ts b/src/models/UserInfo.ts new file mode 100644 index 0000000..095ac68 --- /dev/null +++ b/src/models/UserInfo.ts @@ -0,0 +1,267 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { UserType } from './UserType'; +import { + UserTypeFromJSON, + UserTypeFromJSONTyped, + UserTypeToJSON, + UserTypeToJSONTyped, +} from './UserType'; + +/** + * + * @export + * @interface UserInfo + */ +export interface UserInfo { + /** + * + * @type {string} + * @memberof UserInfo + */ + id?: string; + /** + * + * @type {string} + * @memberof UserInfo + */ + uuid?: string; + /** + * + * @type {string} + * @memberof UserInfo + */ + name?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + displayName?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + email?: string | null; + /** + * + * @type {UserType} + * @memberof UserInfo + */ + type?: UserType; + /** + * + * @type {string} + * @memberof UserInfo + */ + flags?: string; + /** + * + * @type {string} + * @memberof UserInfo + */ + permissions?: string; + /** + * + * @type {boolean} + * @memberof UserInfo + */ + verified?: boolean; + /** + * + * @type {number} + * @memberof UserInfo + */ + level?: number; + /** + * + * @type {number} + * @memberof UserInfo + */ + experience?: number; + /** + * + * @type {boolean} + * @memberof UserInfo + */ + publicBirthday?: boolean; + /** + * + * @type {Date} + * @memberof UserInfo + */ + birthday?: Date | null; + /** + * + * @type {number} + * @memberof UserInfo + */ + points?: number; + /** + * + * @type {string} + * @memberof UserInfo + */ + location?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + language?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + timezone?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + currency?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + photoUrl?: string | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + bannerUrl?: string | null; + /** + * + * @type {Date} + * @memberof UserInfo + */ + lastOnline?: Date | null; + /** + * + * @type {string} + * @memberof UserInfo + */ + biography?: string | null; + /** + * + * @type {number} + * @memberof UserInfo + */ + viewCount?: number; + /** + * + * @type {Date} + * @memberof UserInfo + */ + created?: Date; + /** + * + * @type {Date} + * @memberof UserInfo + */ + updated?: Date | null; +} + + + +/** + * Check if a given object implements the UserInfo interface. + */ +export function instanceOfUserInfo(value: object): value is UserInfo { + return true; +} + +export function UserInfoFromJSON(json: any): UserInfo { + return UserInfoFromJSONTyped(json, false); +} + +export function UserInfoFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserInfo { + if (json == null) { + return json; + } + return { + + 'id': json['id'] == null ? undefined : json['id'], + 'uuid': json['uuid'] == null ? undefined : json['uuid'], + 'name': json['name'] == null ? undefined : json['name'], + 'displayName': json['display_name'] == null ? undefined : json['display_name'], + 'email': json['email'] == null ? undefined : json['email'], + 'type': json['type'] == null ? undefined : UserTypeFromJSON(json['type']), + 'flags': json['flags'] == null ? undefined : json['flags'], + 'permissions': json['permissions'] == null ? undefined : json['permissions'], + 'verified': json['verified'] == null ? undefined : json['verified'], + 'level': json['level'] == null ? undefined : json['level'], + 'experience': json['experience'] == null ? undefined : json['experience'], + 'publicBirthday': json['public_birthday'] == null ? undefined : json['public_birthday'], + 'birthday': json['birthday'] == null ? undefined : (new Date(json['birthday'])), + 'points': json['points'] == null ? undefined : json['points'], + 'location': json['location'] == null ? undefined : json['location'], + 'language': json['language'] == null ? undefined : json['language'], + 'timezone': json['timezone'] == null ? undefined : json['timezone'], + 'currency': json['currency'] == null ? undefined : json['currency'], + 'photoUrl': json['photo_url'] == null ? undefined : json['photo_url'], + 'bannerUrl': json['banner_url'] == null ? undefined : json['banner_url'], + 'lastOnline': json['last_online'] == null ? undefined : (new Date(json['last_online'])), + 'biography': json['biography'] == null ? undefined : json['biography'], + 'viewCount': json['view_count'] == null ? undefined : json['view_count'], + 'created': json['created'] == null ? undefined : (new Date(json['created'])), + 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])), + }; +} + +export function UserInfoToJSON(json: any): UserInfo { + return UserInfoToJSONTyped(json, false); +} + +export function UserInfoToJSONTyped(value?: UserInfo | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'id': value['id'], + 'uuid': value['uuid'], + 'name': value['name'], + 'display_name': value['displayName'], + 'email': value['email'], + 'type': UserTypeToJSON(value['type']), + 'flags': value['flags'], + 'permissions': value['permissions'], + 'verified': value['verified'], + 'level': value['level'], + 'experience': value['experience'], + 'public_birthday': value['publicBirthday'], + 'birthday': value['birthday'] == null ? undefined : ((value['birthday'] as any).toISOString().substring(0,10)), + 'points': value['points'], + 'location': value['location'], + 'language': value['language'], + 'timezone': value['timezone'], + 'currency': value['currency'], + 'photo_url': value['photoUrl'], + 'banner_url': value['bannerUrl'], + 'last_online': value['lastOnline'] == null ? undefined : ((value['lastOnline'] as any).toISOString()), + 'biography': value['biography'], + 'view_count': value['viewCount'], + 'created': value['created'] == null ? undefined : ((value['created']).toISOString()), + 'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()), + }; +} + diff --git a/src/models/UserType.ts b/src/models/UserType.ts new file mode 100644 index 0000000..b629c83 --- /dev/null +++ b/src/models/UserType.ts @@ -0,0 +1,53 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const UserType = { + User: 'user', + Bot: 'bot' +} as const; +export type UserType = typeof UserType[keyof typeof UserType]; + + +export function instanceOfUserType(value: any): boolean { + for (const key in UserType) { + if (Object.prototype.hasOwnProperty.call(UserType, key)) { + if (UserType[key as keyof typeof UserType] === value) { + return true; + } + } + } + return false; +} + +export function UserTypeFromJSON(json: any): UserType { + return UserTypeFromJSONTyped(json, false); +} + +export function UserTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserType { + return json as UserType; +} + +export function UserTypeToJSON(value?: UserType | null): any { + return value as any; +} + +export function UserTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): UserType { + return value as UserType; +} + diff --git a/src/models/index.ts b/src/models/index.ts new file mode 100644 index 0000000..07a081b --- /dev/null +++ b/src/models/index.ts @@ -0,0 +1,44 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './Account'; +export * from './Application'; +export * from './ApplicationType'; +export * from './AuthorizeRequest'; +export * from './CodeChallengeMethod'; +export * from './CryptoViewModel'; +export * from './Game'; +export * from './GameServer'; +export * from './GameServerCluster'; +export * from './GrantType'; +export * from './Group'; +export * from './GroupGame'; +export * from './GroupMember'; +export * from './GroupRank'; +export * from './HashViewModel'; +export * from './IntrospectRequest'; +export * from './IpAddress'; +export * from './LeaderboardItem'; +export * from './LeaderboardOrder'; +export * from './LoginProvider'; +export * from './LoginRequest'; +export * from './LoginResponse'; +export * from './Package'; +export * from './Profile'; +export * from './ProfileGame'; +export * from './ProfileGroup'; +export * from './RefreshRequest'; +export * from './RegisterRequest'; +export * from './ResponseType'; +export * from './RevokeRequest'; +export * from './SearchRequest'; +export * from './SearchType'; +export * from './ServerMetrics'; +export * from './ServerStatus'; +export * from './Subscription'; +export * from './TokenHintType'; +export * from './TokenRequest'; +export * from './TokenResponse'; +export * from './TokenType'; +export * from './UpdateProfile'; +export * from './UserInfo'; +export * from './UserType'; diff --git a/src/options.ts b/src/options.ts deleted file mode 100644 index a127d66..0000000 --- a/src/options.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -export interface TribufuApiOptions { - baseUrl?: string; - apiKey?: string; - fetch?: (url: RequestInfo, init?: RequestInit) => Promise; -} diff --git a/src/runtime.ts b/src/runtime.ts new file mode 100644 index 0000000..5856b59 --- /dev/null +++ b/src/runtime.ts @@ -0,0 +1,431 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Tribufu API + * REST API to access Tribufu services. + * + * The version of the OpenAPI document: 1.1.0 + * Contact: contact@tribufu.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | Promise | ((name: string) => string | Promise); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string | Promise) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } + return undefined; + } + + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } + + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } +} + +export const DefaultConfig = new Configuration(); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private static readonly jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + private middleware: Middleware[]; + + constructor(protected configuration = DefaultConfig) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + protected isJsonMime(mime: string | null | undefined): boolean { + if (!mime) { + return false; + } + return BaseAPI.jsonRegex.test(mime); + } + + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); + const response = await this.fetchApi(url, init); + if (response && (response.status >= 200 && response.status < 300)) { + return response; + } + throw new ResponseError(response, 'Response returned an error code'); + } + + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + this.configuration.queryParamsStringify(context.query); + } + + const headers = Object.assign({}, this.configuration.headers, context.headers); + Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); + + const initOverrideFn = + typeof initOverrides === "function" + ? initOverrides + : async () => initOverrides; + + const initParams = { + method: context.method, + headers, + body: context.body, + credentials: this.configuration.credentials, + }; + + const overriddenInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })) + }; + + let body: any; + if (isFormData(overriddenInit.body) + || (overriddenInit.body instanceof URLSearchParams) + || isBlob(overriddenInit.body)) { + body = overriddenInit.body; + } else if (this.isJsonMime(headers['Content-Type'])) { + body = JSON.stringify(overriddenInit.body); + } else { + body = overriddenInit.body; + } + + const init: RequestInit = { + ...overriddenInit, + body + }; + + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +function isBlob(value: any): value is Blob { + return typeof Blob !== 'undefined' && value instanceof Blob; +} + +function isFormData(value: any): value is FormData { + return typeof FormData !== "undefined" && value instanceof FormData; +} + +export class ResponseError extends Error { + override name: "ResponseError" = "ResponseError"; + constructor(public response: Response, msg?: string) { + super(msg); + } +} + +export class FetchError extends Error { + override name: "FetchError" = "FetchError"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + +export class RequiredError extends Error { + override name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; +export type HTTPBody = Json | FormData | URLSearchParams; +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +export function querystring(params: HTTPQuery, prefix: string = ''): string { + return Object.keys(params) + .map(key => querystringSingleKey(key, params[key], prefix)) + .filter(part => part.length > 0) + .join('&'); +} + +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { + const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); + if (value instanceof Array) { + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) + .join(`&${encodeURIComponent(fullKey)}=`); + return `${encodeURIComponent(fullKey)}=${multiValue}`; + } + if (value instanceof Set) { + const valueAsArray = Array.from(value); + return querystringSingleKey(key, valueAsArray, keyPrefix); + } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; +} + +export function exists(json: any, key: string) { + const value = json[key]; + return value !== null && value !== undefined; +} + +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + +export function canConsumeForm(consumes: Consume[]): boolean { + for (const consume of consumes) { + if ('multipart/form-data' === consume.contentType) { + return true; + } + } + return false; +} + +export interface Consume { + contentType: string; +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; +} + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value(): Promise { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.text(); + }; +} diff --git a/src/singletion.ts b/src/singletion.ts new file mode 100644 index 0000000..7bcd17b --- /dev/null +++ b/src/singletion.ts @@ -0,0 +1,35 @@ +// Copyright (c) Tribufu. All Rights Reserved. +// SPDX-License-Identifier: MIT + +import { TribufuApi } from "./"; + +/** + * **Tribufu API** + * + * Helper class to get a singleton instance of the Tribufu API. + */ +export class TribufuApiSingleton { + private static instance: TribufuApi | null = null; + + private constructor() {} + + /** + * Get the singleton instance of {@link TribufuApi}. + * + * @return Singleton instance + */ + public static getInstance(): TribufuApi { + if (!this.instance) { + this.instance = TribufuApi.fromEnvOrDefault(); + } + + return this.instance; + } + + /** + * Reset the singleton instance of {@link TribufuApi}. + */ + public static resetInstance() { + this.instance = null; + } +} diff --git a/tsconfig.json b/tsconfig.json index a6c41a8..91f1844 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,21 +12,11 @@ "resolveJsonModule": true, "rootDir": "src", "outDir": "build", - "lib": [ - "ESNext", - "DOM" - ], + "lib": ["ESNext", "DOM"], "paths": { - "@/*": [ - "./*" - ] + "@/*": ["./*"] } }, - "include": [ - "src/**/*.ts", - ], - "exclude": [ - "build", - "node_modules", - ], + "include": ["src/**/*.ts"], + "exclude": ["build", "node_modules"] } diff --git a/vendor/openapi-generator/LICENSE b/vendor/openapi-generator/LICENSE new file mode 100644 index 0000000..310853b --- /dev/null +++ b/vendor/openapi-generator/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + Copyright 2018 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/openapi-generator/openapi-generator-cli.jar b/vendor/openapi-generator/openapi-generator-cli.jar new file mode 100644 index 0000000..f373b7a Binary files /dev/null and b/vendor/openapi-generator/openapi-generator-cli.jar differ