#------------------------------------------------------------------ # Proxy Script Generated by Delphi Microservices Container 4.3.20 # Do not modify this code! # Generated at: 2025-04-26 18.02.22 #------------------------------------------------------------------ import requests import urllib3 urllib3.disable_warnings() class ExcelRPCException(Exception): pass class ExcelRPCProxy: def __init__(self, base_url): self.__id = 1 self.base_url = base_url self.headers = { "content-type": "application/json", "accept": "application/json" } def __get_next_id(self): self.__id += 1 return self.__id def __execute(self, req): isnotif = req.get("id") is None res = requests.post(self.base_url, json=req, headers=self.headers, verify=False) if res.status_code == 204: # no content if isnotif: return None else: raise ExcelRPCException(0,"Protocol error for Notification") if res.headers["content-type"].lower().find("application/json") != 0: raise ExcelRPCException("Invalid ContentType in response: " + res.headers["content-type"]) jres = res.json() if "error" in jres: raise ExcelRPCException(jres.get("error").get("message")) if not "result" in jres: raise ExcelRPCException(0,"Protocol error in JSON-RPC response - no result nor error node exists") return jres["result"] def __new_req(self, method, typ): req = dict(jsonrpc="2.0", method=method, params=[]) if typ == "request": req["id"] = self.__get_next_id() return req # end of library code # Following methods are automatically generated def convert_to_xlsx(self, token, jsonworkbook): """ Invokes [function ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJsonObject] Generates an XLSX file based on a JSON structure """ req = self.__new_req("ConvertToXLSX", "request") req["params"].append(token) req["params"].append(jsonworkbook) result = self.__execute(req) return result def login(self, username, password): """ Invokes [function Login(const UserName: string; const Password: string): TJsonObject] Returns the JWT token which can be used to call all other methods. """ req = self.__new_req("Login", "request") req["params"].append(username) req["params"].append(password) result = self.__execute(req) return result def refresh_token(self, token): """ 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. """ req = self.__new_req("RefreshToken", "request") req["params"].append(token) result = self.__execute(req) return result # end of generated proxy