mychips-react-sdk
Version:
MyChips Offerwall
40 lines (38 loc) • 1.45 kB
JavaScript
import Consts from '../Consts';
import { version } from '../../package.json';
class UriBuilderService {
buildOfferwallUrl(adunitId, userId, gaid, idfa, gender, age, totalVirtualCurrency, affSub1, affSub2, affSub3, affSub4, affSub5) {
let url = `${Consts.WEB_BASE_URL}?adunit_id=${adunitId}&user_id=${userId}&`;
if (gaid) {
url += `gaid=${gaid}&`;
}
if (idfa) {
url += `idfa=${idfa}&`;
}
if (gender) {
url += `gender=${gender}&`;
}
if (age && age > 0) {
url += `age=${age}&`;
}
if (totalVirtualCurrency && totalVirtualCurrency > 0) {
const totalVirtualCurrencyFormatted = totalVirtualCurrency.toFixed(2);
url += `total_virtual_currency=${totalVirtualCurrencyFormatted}&`;
}
// NEW: aff_sub1 ~ aff_sub5
if (affSub1 && affSub1.trim() !== '') url += `aff_sub1=${affSub1}&`;
if (affSub2 && affSub2.trim() !== '') url += `aff_sub2=${affSub2}&`;
if (affSub3 && affSub3.trim() !== '') url += `aff_sub3=${affSub3}&`;
if (affSub4 && affSub4.trim() !== '') url += `aff_sub4=${affSub4}&`;
if (affSub5 && affSub5.trim() !== '') url += `aff_sub5=${affSub5}&`;
// Always add SDK parameter
url += `sdk=react_native&sdk_version=${version}`;
// Remove the trailing '&' if it exists
if (url.endsWith('&')) {
url = url.slice(0, -1);
}
return url;
}
}
export default UriBuilderService;
//# sourceMappingURL=UriBuilderService.js.map