Search in sources :

Example 1 with DemandTestResults

use of org.prebid.mobile.drprebid.model.DemandTestResults in project prebid-mobile-android by prebid.

the class RealTimeDemandTest method startTest.

public void startTest() {
    GeneralSettings generalSettings = SettingsManager.getInstance(mContext).getGeneralSettings();
    PrebidServerSettings prebidServerSettings = SettingsManager.getInstance(mContext).getPrebidServerSettings();
    AdUnit adUnit = null;
    if (generalSettings.getAdFormat() == AdFormat.BANNER) {
        AdSize adSize = generalSettings.getAdSize();
        adUnit = new BannerAdUnit(prebidServerSettings.getConfigId(), adSize.getWidth(), adSize.getHeight());
    } else if (generalSettings.getAdFormat() == AdFormat.INTERSTITIAL) {
        adUnit = new InterstitialAdUnit(prebidServerSettings.getConfigId());
    }
    List<AdUnit> adUnits = Collections.singletonList(adUnit);
    String hostUrl;
    switch(prebidServerSettings.getPrebidServer()) {
        case APPNEXUS:
            PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
            hostUrl = Constants.EndpointUrls.APPNEXUS_PREBID_SERVER;
            break;
        case RUBICON:
            PrebidMobile.setPrebidServerHost(Host.RUBICON);
            hostUrl = Constants.EndpointUrls.RUBICON_PREBID_SERVER;
            break;
        case CUSTOM:
            PrebidMobile.setPrebidServerHost(Host.CUSTOM);
            hostUrl = buildCustomServerEndpoint(prebidServerSettings.getCustomPrebidServerUrl());
            Host.CUSTOM.setHostUrl(hostUrl);
            break;
        default:
            PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
            hostUrl = Constants.EndpointUrls.APPNEXUS_PREBID_SERVER;
    }
    DemandRequestBuilder builder = new DemandRequestBuilder(mContext, prebidServerSettings.getConfigId(), generalSettings.getAdSize());
    String request = builder.buildRequest(adUnits, prebidServerSettings.getAccountId(), true);
    testResponseCount = 0;
    testResults = new DemandTestResults(request);
    for (int i = 0; i < REQUEST_MAX; i++) {
        runTest(hostUrl, request, requestCompletionListener);
    }
}
Also used : PrebidServerSettings(org.prebid.mobile.drprebid.model.PrebidServerSettings) BannerAdUnit(org.prebid.mobile.BannerAdUnit) AdUnit(org.prebid.mobile.AdUnit) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit) AdSize(org.prebid.mobile.drprebid.model.AdSize) DemandTestResults(org.prebid.mobile.drprebid.model.DemandTestResults) GeneralSettings(org.prebid.mobile.drprebid.model.GeneralSettings) BannerAdUnit(org.prebid.mobile.BannerAdUnit) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit)

Aggregations

AdUnit (org.prebid.mobile.AdUnit)1 BannerAdUnit (org.prebid.mobile.BannerAdUnit)1 InterstitialAdUnit (org.prebid.mobile.InterstitialAdUnit)1 AdSize (org.prebid.mobile.drprebid.model.AdSize)1 DemandTestResults (org.prebid.mobile.drprebid.model.DemandTestResults)1 GeneralSettings (org.prebid.mobile.drprebid.model.GeneralSettings)1 PrebidServerSettings (org.prebid.mobile.drprebid.model.PrebidServerSettings)1