//
// $Id$
//
import { cnContext } from "../infohub/cnContext.js"
import { RestServices, RestResponse } from "../tools/RestServices.js"
/**
@category Infohub Routines
@classdesc PDF, XLS Reports
*/
export class ServiceRender {
#_ctx = null;
/**
*
* @param {cnContext} ctx
*
*/
constructor( ctx ) {
this.#_ctx = ctx
}
/**
*
* Create XLS file from node tree.
*
* Uses endpoint: `https://.SERVICE_RENDER./{scope}/xls/nodes/{node}/tree`
*
* Get access token and scope from infohub context.
*
* @param {string} parent_sid Create the new document as child of this node
* @param {object} request_data Sources and configuration, see documentation of endpoint for more details
*
* @returns {RestResponse} Response of REST call
*
* @since 08.2025, jh
*
*/
async createXlsFromTree( parent_sid , request_data ) {
let scope = this.#_ctx.getScope()
let node = parent_sid
let path_endpoint = `${this.#_ctx.getServiceUrl(cnContext.SERVICE.RENDER)}/${scope}/xls/nodes/${node}/tree`
console.log(`### <createXlsFromTree()> ENDPOINT : ${path_endpoint}`)
let resp = await RestServices.makeApiCall( this.#_ctx.getToken() , RestServices.METHODS.POST , path_endpoint , request_data , "application/json" )
// console.log( "RESPONSE:" )
// console.log( JSON.stringify(resp.getData()) )
return resp
}
}
Source