-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathariba-api-parameters.js
44 lines (33 loc) · 1.26 KB
/
ariba-api-parameters.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$.addGenerator(start);
generateMessage = function () {
// Process the dates to be used in the API request filter parameter
var currentDate = new Date();
var dateTo = new Date();
dateTo.setDate(currentDate.getDate());
var dateFrom = new Date();
dateFrom.setDate(currentDate.getDate() - 30);
var updatedDateFrom = dateFrom.toISOString().slice(0, 10) + "T00:00:00Z";
var updatedDateTo = dateTo.toISOString().slice(0, 10) + "T00:00:00Z";
var msg = {};
msg.Attributes = {};
msg.Attributes["openapi.consumes"] = "application/json";
msg.Attributes["openapi.produces"] = "application/json";
msg.Attributes["openapi.method"] = "GET";
// Set API header parameters
msg.Attributes["openapi.header_params.apiKey"] = "ARIBA_API_KEY";
msg.Attributes["openapi.path_pattern"] = "/views/InactiveSuppliers";
// Set API query parameters
msg.Attributes["openapi.query_params.realm"] = "realm-t";
msg.Attributes["openapi.query_params.includeInactive"] = "true";
msg.Attributes["openapi.query_params.filters"] =
'{"updatedDateFrom":"' +
updatedDateFrom +
'","updatedDateTo":"' +
updatedDateTo +
'"}';
msg.Attributes["openapi.form_params.grant_type"] = "openapi_2lo";
return msg;
};
function start(ctx) {
$.output(generateMessage());
}