//------------------------------------------------------------------
// Proxy Unit Generated by Delphi Microservices Container 4.3.20
// Do not modify this unit!
// Generated at: 2025-04-26 18.05.03
//------------------------------------------------------------------
unit ExcelRPCProxy;
interface
uses
System.SysUtils,
System.Classes,
MVCFramework.JSONRPC,
MVCFramework.JSONRPC.Client,
MVCFramework.Serializer.Commons,
System.Net.URLClient,
JsonDataObjects;
type
IExcelRPCProxy = interface
['{D27ABEF1-8D93-4E28-ACEC-161CAC9DCBD1}']
function RPCExecutor: IMVCJSONRPCExecutor;
procedure IgnoreInvalidCert;
///
/// Invokes [function ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJsonObject]
/// Generates an XLSX file based on a JSON structure
///
function ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJDOJsonObject;
///
/// Invokes [function Login(const UserName: string; const Password: string): TJsonObject]
/// Returns the JWT token which can be used to call all other methods.
///
function Login(const UserName: string; const Password: string): TJDOJsonObject;
///
/// 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.
///
function RefreshToken(const Token: string): TJDOJsonObject;
end;
TExcelRPCProxy = class(TInterfacedObject, IExcelRPCProxy)
protected
fRPCExecutor: IMVCJSONRPCExecutor;
function NewReqID: Int64;
procedure IgnoreInvalidServerCertificate(const Sender: TObject;
const ARequest: TURLRequest; const Certificate: TCertificate; var Accepted: Boolean);
public
function RPCExecutor: IMVCJSONRPCExecutor;
procedure IgnoreInvalidCert;
constructor Create(const EndpointURL: String); virtual;
///
/// Invokes [function ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJsonObject]
/// Generates an XLSX file based on a JSON structure
///
function ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJDOJsonObject;
///
/// Invokes [function Login(const UserName: string; const Password: string): TJsonObject]
/// Returns the JWT token which can be used to call all other methods.
///
function Login(const UserName: string; const Password: string): TJDOJsonObject;
///
/// 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.
///
function RefreshToken(const Token: string): TJDOJsonObject;
end;
implementation
constructor TExcelRPCProxy.Create(const EndpointURL: String);
begin
inherited Create;
fRPCExecutor := TMVCJSONRPCExecutor.Create(EndpointURL);
fRPCExecutor.AddHTTPHeader(TNetHeader.Create('Accept-Encoding', 'gzip,deflate'));
fRPCExecutor.AddHTTPHeader(TNetHeader.Create('User-Agent', 'dmscontainer-delphi-proxy'));
end;
function TExcelRPCProxy.NewReqID: Int64;
begin
Result := 10000 + Random(10000000);
end;
function TExcelRPCProxy.RPCExecutor: IMVCJSONRPCExecutor;
begin
Result := fRPCExecutor;
end;
procedure TExcelRPCProxy.IgnoreInvalidCert;
begin
fRPCExecutor.SetOnValidateServerCertificate(IgnoreInvalidServerCertificate);
end;
procedure TExcelRPCProxy.IgnoreInvalidServerCertificate(
const Sender: TObject; const ARequest: TURLRequest;
const Certificate: TCertificate; var Accepted: Boolean);
begin
Accepted := True;
end;
function TExcelRPCProxy.ConvertToXLSX(const Token: string; const JSONWorkBook: TJsonObject): TJDOJsonObject;
var
lReq: IJSONRPCRequest;
lResp: IJSONRPCResponse;
begin
lReq := TJSONRPCRequest.Create(NewReqID, 'ConvertToXLSX');
lReq.Params.Add(Token);
lReq.Params.Add(JSONWorkBook);
lResp := fRPCExecutor.ExecuteRequest(lReq);
Result := lResp.ResultAsJSONObject.Clone as TJDOJsonObject; //TJsonObject
end;
function TExcelRPCProxy.Login(const UserName: string; const Password: string): TJDOJsonObject;
var
lReq: IJSONRPCRequest;
lResp: IJSONRPCResponse;
begin
lReq := TJSONRPCRequest.Create(NewReqID, 'Login');
lReq.Params.Add(UserName);
lReq.Params.Add(Password);
lResp := fRPCExecutor.ExecuteRequest(lReq);
Result := lResp.ResultAsJSONObject.Clone as TJDOJsonObject; //TJsonObject
end;
function TExcelRPCProxy.RefreshToken(const Token: string): TJDOJsonObject;
var
lReq: IJSONRPCRequest;
lResp: IJSONRPCResponse;
begin
lReq := TJSONRPCRequest.Create(NewReqID, 'RefreshToken');
lReq.Params.Add(Token);
lResp := fRPCExecutor.ExecuteRequest(lReq);
Result := lResp.ResultAsJSONObject.Clone as TJDOJsonObject; //TJsonObject
end;
end.