richpartners-telegram-sdk
Version:
richPartners ads telegram
48 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdRequestService = void 0;
class AdRequestService {
constructor(debug = false) {
this.debug = debug;
this.TELEGRAM_BID_BASE_ENDPOINT = "https://{{ssp_id}}.xml.4armn.com/telegram-bid";
}
async fetchAds(request, sspId, callback) {
if (this.debug) {
callback(this.generateDebugAdData());
return;
}
try {
const endpoint = this.TELEGRAM_BID_BASE_ENDPOINT.replace("{{ssp_id}}", String(sspId));
const response = await fetch(endpoint, {
method: "POST",
body: JSON.stringify(request),
});
const data = await response.json();
callback(Array.isArray(data) ? data : []);
}
catch (error) {
throw new Error('[fetchAds] Error fetching ads:');
}
}
generateDebugAdData(count = 1) {
const ads = [];
for (let i = 0; i < count; i++) {
ads.push({
title: `Weather Forecaster ${i + 1}`,
description: `Accurate 12 Day Weather Forecasts for thousands of places around the World ${i + 1}`,
image: 'https://richads.com/assets/img/logos/crown-desk.svg',
banner: 'https://richads.com/assets/img/logos/crown-desk.svg',
link: 'https://publishers.richads.com/',
index: i,
message: 'Weather forecasts from the most accurate weather forecasting technology featuring up to the minute weather reports',
icon: 'https://cdn.adx1.com/files/67ebb8a633b84_2025_04_01_09_57_58_image.jpeg',
brand: 'Weatherly',
button: 'Subscribe',
video: "https://cdn.adx1.com/files/67e6baca2b60e_2025_03_28_03_05_46_video.mp4",
});
}
return ads;
}
}
exports.AdRequestService = AdRequestService;
//# sourceMappingURL=AdRequestService.js.map