mychips-react-sdk
Version:
MyChips Offerwall
41 lines (35 loc) • 1.13 kB
text/typescript
import Consts from '../Consts';
import {version} from '../../package.json'
class UriBuilderService {
buildOfferwallUrl(
adunitId: string,
userId: string,
advertisingId?: string,
gender?: string,
age?: number,
totalVirtualCurrency?: number
): string {
let url = `${Consts.WEB_BASE_URL}?adunit_id=${adunitId}&user_id=${userId}&`;
if (advertisingId) {
url += `gaid=${advertisingId}&`;
}
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}&`;
}
// 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;