Generic Resource
PEPPERI NOTIFICATION SERVICE
Actions Queue
CPI Node
TODO training

POST add-on function - async

The function should get two parameters:

Client: same as in user code job + Client.AddonUUID; (addon identifier - UUID)

Request: { path - the relative url request, query - dictionary of the query params, body - the original request body, originalUrl - full url request, method - POST/GET }

The audit log will be like execute now of code_job

log group in cloudwatch: code_jobs + AddonsExecuteJavaScriptLambdaAsync

post
execute POST add-on exported JS function

https://api.pepperi.com/v1.0/addons/api/async/{addonUUID}/{js_file_name}/{function_name}
Execute a specific function on the server side in asynchronous way The function is exported function on a JS file (=resource) of a specific addon Using code_jobs & audit_log
Request
Response
Request
Query Parameters
callback
optional
string
callback_uuid
retry
optional
integer
Number of retries in case of failure Default - 1 (no retrie
Response
200: OK
Note that the returned object from the function will be placed in the ResultObject in the AuditLog entry
Same as the execute now in code_jobs
exports.example1= (Client, Request) => {
var ret= {};
ret.success = true;
ret.resultObject = {};
ret.resultObject.msg = "hello world";
return ret;
}
// example calling pepperi api using request module
exports.example2= async (Client, Request) => {
var response = {};
Client.addLogEntry("Info", "Start GetTransactions");
var options = {
uri: Client.BaseURL + '/transactions',
qs: {
'page_size': 1
},
headers: {
'Authorization': ' Bearer ' + Client.OAuthAccessToken
},
json: true
};
try{
Client.addLogEntry("Info", "Request.originalUrl = " + Request.originalUrl);
Client.addLogEntry("Info", "Request.body = " + Request.body);
const res = await Client.Module.rp(options);
Client.addLogEntry("Info", "Got result = " + JSON.stringify(res));
response.success = true;
response.resultObject = res;
}
catch(error){
Client.addLogEntry("Error", "Failed GetTransactions: " + error.message);
response.success = false;
response.errorMessage = error.message;
response.resultObject = null;
}
return (response);
};

The result from the executed function will be placed in the ResultObject of the AuditLog