#------------------------------------------------------------------ # Proxy Script Generated by Delphi Microservices Container 4.3.20 # Do not modify this code! # Generated at: 2025-04-26 18.08.37 #------------------------------------------------------------------ import requests import urllib3 urllib3.disable_warnings() class ReportsRPCException(Exception): pass class ReportsRPCProxy: 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 ReportsRPCException(0,"Protocol error for Notification") if res.headers["content-type"].lower().find("application/json") != 0: raise ReportsRPCException("Invalid ContentType in response: " + res.headers["content-type"]) jres = res.json() if "error" in jres: raise ReportsRPCException(jres.get("error").get("message")) if not "result" in jres: raise ReportsRPCException(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 generate_multiple_report(self, token, template, reportdata, outputformat): """ Invokes [function GenerateMultipleReport(const Token: string; const Template: TJsonObject; const ReportData: TJsonObject; const OutputFormat: string): TJsonObject] Generates report based on a docx template and a JSON structure. Generates one PDF file for each element in the "items" JSON property. """ req = self.__new_req("GenerateMultipleReport", "request") req["params"].append(token) req["params"].append(template) req["params"].append(reportdata) req["params"].append(outputformat) result = self.__execute(req) return result def generate_multiple_report_by_name(self, token, reportname, reportdata, outputformat): """ Invokes [function GenerateMultipleReportByName(const Token: string; const ReportName: string; const ReportData: TJsonObject; const OutputFormat: string): TJsonObject] Generates report based on a docx template named "report_name" stored on server and a JSON structure. Generates one PDF file for each element in the "items" JSON property and return it as zipped base64 file. """ req = self.__new_req("GenerateMultipleReportByName", "request") req["params"].append(token) req["params"].append(reportname) req["params"].append(reportdata) req["params"].append(outputformat) result = self.__execute(req) return result def generate_report_by_name(self, token, reportname, reportdata, outputformat): """ Invokes [function GenerateReportByName(const Token: string; const ReportName: string; const ReportData: TJsonObject; const OutputFormat: string): TJsonObject] Generates a report based on a docx template named "report_name" stored on server and a JSON structure. Generates only one PDF file and return it as not compressed base64 stream, just save it and you get the PDF - the "items" JSON property must contains a single object. """ req = self.__new_req("GenerateReportByName", "request") req["params"].append(token) req["params"].append(reportname) req["params"].append(reportdata) req["params"].append(outputformat) result = self.__execute(req) return result def generate_multiple_report_async(self, token, reportname, template, reportdata, usertonotify, outputformat): """ Invokes [function GenerateMultipleReportAsync(const Token: string; const ReportName: string; const Template: TJsonObject; const ReportData: TJsonObject; const UserToNotify: TJsonArray; const OutputFormat: string): TJsonObject] Generates report asynchronously based on a docx template and a JSON structure. Generates one PDF file for each element in the "items" JSON property. """ req = self.__new_req("GenerateMultipleReportAsync", "request") req["params"].append(token) req["params"].append(reportname) req["params"].append(template) req["params"].append(reportdata) req["params"].append(usertonotify) req["params"].append(outputformat) result = self.__execute(req) return result def get_async_report(self, token, reportid): """ Invokes [function GetAsyncReport(const Token: string; const ReportID: string): TJsonObject] Returns a report generated asychronously with GenerateMultipleReportAsync """ req = self.__new_req("GetAsyncReport", "request") req["params"].append(token) req["params"].append(reportid) result = self.__execute(req) return result def get_stored_report_names(self, token, regexexpressionfilter): """ Invokes [function GetStoredReportNames(const Token: string; const RegExExpressionFilter: string): TJsonObject] Returns all the stored report template names """ req = self.__new_req("GetStoredReportNames", "request") req["params"].append(token) req["params"].append(regexexpressionfilter) 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