//---------------------- // // 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 "./api.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 Application[]; 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 Application; 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 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; 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); }