
Campaign provides an API to fetch reports data. Just like all APIs in the SDK, it's been wrapped into a function and will return a XML or JSON object based on the requested representation
Function Definition
client.getReportData = (callContext: any, representation: string) : Promise
callContext
{
reportName: string(Report Name),
context: string("selection"|"global"),
schema: string(entity type to be used for selection),
selection: string(Comma separated list of entity IDs),
formData: any
}
Usage
const report = await client.getReportData({
reportName: "throughput",
context: "selection",
schema: "nms:delivery",
selection: "12133"
});
console.log(JSON.stringify(report));
Usage with multiple entities
const report = await client.getReportData({
reportName: "throughput",
context: "selection",
schema: "nms:delivery",
selection: "12133,12134"
});
console.log(JSON.stringify(report));
Usage with form data
const report = await client.getReportData({
reportName: "throughput",
context: "selection",
schema: "nms:delivery",
selection: "12133",
formData: {
vars_opens: 1,
userAction: "next",
ctx: {
_context: 'selection',
_reportContext: 'throughput',
_hasFilter: 'false',
_selectionCount: '1',
_selection: '12133',
vars: {
'$period': '21600',
'$trunc': '600',
'$valueScaleFactor': '6',
'$dateStepType': 'minute',
'$dateStepFactor': '10'
},
data: {
deliveryStat: { deliveryStat: [Array] },
bandwidth: { deliveryStat: [Object] }
}
}
}
});
console.log(JSON.stringify(report));
A given representation can be forced
const xmlReport = await client.getReportData({
reportName: "throughput",
context: "selection",
schema: "nms:delivery",
selection: "12133"
}, "xml");
const jsonReport = await client.getReportData({
reportName: "throughput",
context: "selection",
schema: "nms:delivery",
selection: "12133"
}, "SimpleJson");