//------------------------------------------------------------------ // Proxy Script Generated by Delphi Microservices Container 4.3.20 // Do not modify this code! // Generated at: 2025-04-26 18.05.03 //------------------------------------------------------------------ export class ExcelRPCProxy { __baseUrl = ""; constructor(baseUrl) { this.__baseUrl = baseUrl; } get baseUrl() { return this.__baseUrl; } __getJsonRpcRequest(jsonrpcRequestMethod, params) { let json = this.__getJsonRpcNotification(jsonrpcRequestMethod, params); json["id"] = Math.trunc(Math.random() * 100000); return json; } __getJsonRpcNotification(jsonrpcRequestMethod, params) { return { "jsonrpc": "2.0", "method": jsonrpcRequestMethod, "params": params }; } __internalFetch(type, baseUrl, jsonrpcMethod, params) { let jsonbody = null; if (type === 'notification') { jsonbody = this.__getJsonRpcNotification(jsonrpcMethod, params); } else if (type === 'request') { jsonbody = this.__getJsonRpcRequest(jsonrpcMethod, params); } return fetch(baseUrl, { "method": "POST", "body": JSON.stringify(jsonbody), "headers": { "content-type": "application/json", "accept": "application/json" } }).then(data => { switch (data.status) { case 200: { return data.json(); } case 204: { //no content return null; } default: { return data.json(); } } }); } __jsonRpcResponsePromise(type, baseUrl, method, params) { switch (type) { case "request": { return new Promise((resolve, reject) => { this.__internalFetch('request', this.baseUrl, method, params).then(jsonresp => { if ("result" in jsonresp) { resolve(jsonresp.result) } else if ("error" in jsonresp) { reject(jsonresp.error) } else { throw new Error("Invalid JSON-RPC response"); } }); }) break; } case "notification": { return new Promise((resolve, reject) => { this.__internalFetch('notification', this.baseUrl, method, params).then(jsonresp => { if (jsonresp !== null && "error" in jsonresp) { reject(jsonresp.error); } else { resolve(); } }); }) break; } default: { throw new Error("JSON-RPC message must be 'request' or 'notification' [Actual: '" + type + '"]'); } } } // Following methods are automatically generated // Invokes [function ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJsonObject] // Generates an XLSX file based on a JSON structure convertToXlsx(token, jsonworkBook) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'ConvertToXLSX',{ "token": token, "jsonworkBook": jsonworkBook }); } // Invokes [function Login(const UserName: string; const Password: string): TJsonObject] // Returns the JWT token which can be used to call all other methods. login(userName, password) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'Login',{ "userName": userName, "password": password }); } // Invokes [function RefreshToken(const Token: string): TJsonObject] // Extends the expiration time of a still-valid token. Clients must use the token returned instead of the previous one. refreshToken(token) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'RefreshToken',{ "token": token }); } } //end