Generic Resource
PEPPERI NOTIFICATION SERVICE
Actions Queue
CPI Node
TODO training
Powered By GitBook
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
https://api.pepperi.com
/v1.0/addons/api/async/{addonUUID}/{js_file_name}/{function_name}
execute POST add-on exported JS function
1
exports.example1= (Client, Request) => {
2
var ret= {};
3
4
ret.success = true;
5
6
ret.resultObject = {};
7
8
ret.resultObject.msg = "hello world";
9
10
return ret;
11
12
}
Copied!
1
// example calling pepperi api using request module
2
exports.example2= async (Client, Request) => {
3
var response = {};
4
Client.addLogEntry("Info", "Start GetTransactions");
5
6
var options = {
7
uri: Client.BaseURL + '/transactions',
8
qs: {
9
'page_size': 1
10
},
11
headers: {
12
'Authorization': ' Bearer ' + Client.OAuthAccessToken
13
},
14
json: true
15
};
16
try{
17
Client.addLogEntry("Info", "Request.originalUrl = " + Request.originalUrl);
18
Client.addLogEntry("Info", "Request.body = " + Request.body);
19
const res = await Client.Module.rp(options);
20
Client.addLogEntry("Info", "Got result = " + JSON.stringify(res));
21
response.success = true;
22
response.resultObject = res;
23
}
24
catch(error){
25
Client.addLogEntry("Error", "Failed GetTransactions: " + error.message);
26
response.success = false;
27
response.errorMessage = error.message;
28
response.resultObject = null;
29
}
30
return (response);
31
};
Copied!
The result from the executed function will be placed in the ResultObject of the AuditLog
Last modified 5mo ago