//------------------------------------------------------------------ // Proxy Script Generated by Delphi Microservices Container 4.3.20 // Do not modify this code! // Generated at: 2025-04-26 18.11.11 //------------------------------------------------------------------ export class EmailRPCProxy { __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 [procedure SetUserSender(const Token: string; const UserID: Int64; aSender: TJsonObject)] setUserSender(token, userId, aSender) { return this.__jsonRpcResponsePromise('notification', this.__baseUrl, 'SetUserSender',{ "token": token, "userId": userId, "aSender": aSender }); } // Invokes [function RemoveUserSender(const Token: string; const UserID: Int64): TJsonObject] removeUserSender(token, userId) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'RemoveUserSender',{ "token": token, "userId": userId }); } // Invokes [function GetUserSender(const Token: string; const UserID: Int64): TSender] getUserSender(token, userId) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'GetUserSender',{ "token": token, "userId": userId }); } // Invokes [function GetMessagesByUserName(const Token: string; const SenderUserName: string): TObjectList] // Returns the messages sent by SenderUserName getMessagesByUserName(token, senderUserName) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'GetMessagesByUserName',{ "token": token, "senderUserName": senderUserName }); } // Invokes [function GetMyMessages(const Token: string; const StatusList: TJsonArray): TObjectList] // Returns the messages owned by the logged user getMyMessages(token, statusList) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'GetMyMessages',{ "token": token, "statusList": statusList }); } // Invokes [function GetMessageByID(const Token: string; const MessageID: Int64): TMessage] // Returns the message with id MessageID getMessageById(token, messageId) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'GetMessageByID',{ "token": token, "messageId": messageId }); } // Invokes [function GetMessagesByStatus(const Token: string; const StatusList: TJsonArray): TObjectList] // Returns the messages with the status contained in the StatusList array getMessagesByStatus(token, statusList) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'GetMessagesByStatus',{ "token": token, "statusList": statusList }); } // Invokes [function GetMessagesByRQL(const Token: string; const Filter: TJsonObject): TJsonObject] // Returns all messages (up to 6 months) which match the filter.rql property getMessagesByRql(token, filter) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'GetMessagesByRQL',{ "token": token, "filter": filter }); } // Invokes [function SendMessage(const Token: string; const aMessage: TJsonObject): TJsonObject] // Send a message using information stored in aMessage sendMessage(token, aMessage) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'SendMessage',{ "token": token, "aMessage": aMessage }); } // Invokes [function DeleteMessageByID(const Token: string; const MessageID: Int64): TJsonObject] deleteMessageById(token, messageId) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'DeleteMessageByID',{ "token": token, "messageId": messageId }); } // Invokes [function AdminSendMessage(const Token: string; const SenderUserName: string; const aMessage: TJsonObject): TJsonObject] adminSendMessage(token, senderUserName, aMessage) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'AdminSendMessage',{ "token": token, "senderUserName": senderUserName, "aMessage": aMessage }); } // Invokes [function AdminSendTestMessage(const Token: string; const SenderUserName: string; const Recipient: string): TJsonObject] adminSendTestMessage(token, senderUserName, recipient) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'AdminSendTestMessage',{ "token": token, "senderUserName": senderUserName, "recipient": recipient }); } // Invokes [function CreateMessage(const Token: string; const aMessage: TJsonObject): TJsonObject] createMessage(token, aMessage) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'CreateMessage',{ "token": token, "aMessage": aMessage }); } // Invokes [function AddAttachmentToMessage(const Token: string; const aMessageID: Int64; const aIsRelated: Boolean; const aAttachment: TJsonObject): TJsonObject] addAttachmentToMessage(token, aMessageId, aIsRelated, aAttachment) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'AddAttachmentToMessage',{ "token": token, "aMessageId": aMessageId, "aIsRelated": aIsRelated, "aAttachment": aAttachment }); } // Invokes [function CompleteMessage(const Token: string; const aMessageID: Int64): TJsonObject] completeMessage(token, aMessageId) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'CompleteMessage',{ "token": token, "aMessageId": aMessageId }); } // Invokes [function BulkSendMessages(const Token: string; const aMetaMessage: TJsonObject; const aBulkMessagesData: TJsonObject): TJsonObject] bulkSendMessages(token, aMetaMessage, aBulkMessagesData) { return this.__jsonRpcResponsePromise('request', this.__baseUrl, 'BulkSendMessages',{ "token": token, "aMetaMessage": aMetaMessage, "aBulkMessagesData": aBulkMessagesData }); } // 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