Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static getLatest(): GVL {
return new GVL(require('./vendorlist/vendor-list.json'));
}
public static getVersion(version: number): GVL {
return new GVL(require(`./vendorlist/vendor-list-v${version}.json`));
}
public execute(): void {
/**
* Return a clone of the current GVL if no param/version was used. Otherwise, create a new GVL with the
* specific version.
*/
const _gvl: GVL = this.param ? new GVL(this.param as string | number) : this.cmpData.getTcModel().gvl.clone();
_gvl.readyPromise.then(() => {
const gvl = new GlobalVendorListBldr(_gvl);
this.setBaseReturnFields(gvl);
(this.callback.function as VendorListCallback)(gvl.buildResponse(), true);
}, ((reason) => this.callback.fail(reason))).catch((reason) => this.callback.fail(reason));
}
protected success(): void {
let gvl: GVL;
const callback = this.callback as VendorListCallback;
if (!this.param) {
const tcModel = CmpApiModel.tcModel as TCModel;
if (tcModel.gvl) {
callback(tcModel.gvl.getJson(), true);
} else {
tcModel.gvl = new GVL(tcModel.vendorListVersion);
tcModel.gvl.readyPromise.then(() => {
callback(tcModel.gvl.getJson(), true);
}, this.fail).catch(this.fail);
}
} else {
gvl = new GVL(this.param);
const woops = (): void => {
this.fail();
callback(tcModel.gvl.getJson(), true);
} else {
tcModel.gvl = new GVL(tcModel.vendorListVersion);
tcModel.gvl.readyPromise.then(() => {
callback(tcModel.gvl.getJson(), true);
}, this.fail).catch(this.fail);
}
} else {
gvl = new GVL(this.param);
const woops = (): void => {
this.fail();
};
gvl.readyPromise.then(() => {
callback(gvl.getJson(), true);
}, woops).catch(woops);
}
}