Search in sources :

Example 6 with Imp

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp in project prebid-mobile-android by prebid.

the class BidRequest method getJsonObject.

public JSONObject getJsonObject() throws JSONException {
    JSONObject jsonObject = new JSONObject();
    if (mImps != null && mImps.size() > 0) {
        JSONArray jsonArray = new JSONArray();
        for (Imp i : mImps) {
            jsonArray.put(i.getJsonObject());
        }
        toJSON(jsonObject, "imp", jsonArray);
    }
    toJSON(jsonObject, "id", !TextUtils.isEmpty(mId) ? mId : null);
    toJSON(jsonObject, "app", (mApp != null) ? mApp.getJsonObject() : null);
    toJSON(jsonObject, "device", (mDevice != null) ? mDevice.getJsonObject() : null);
    toJSON(jsonObject, "regs", (mRegs != null) ? mRegs.getJsonObject() : null);
    toJSON(jsonObject, "user", (mUser != null) ? mUser.getJsonObject() : null);
    toJSON(jsonObject, "source", mSource != null ? mSource.getJsonObject() : null);
    toJSON(jsonObject, "ext", mExt != null ? mExt.getJsonObject() : null);
    return jsonObject;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)

Example 7 with Imp

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne.

@Test
public void whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.useExternalBrowser = true;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
    assertEquals(1, actualImp.clickBrowser.intValue());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) Test(org.junit.Test)

Example 8 with Imp

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndBannerType_ImpWithValidBannerObject.

@Test
public void whenAppendParametersAndBannerType_ImpWithValidBannerObject() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    adConfiguration.setPbAdSlot("12345");
    PrebidRenderingSettings.addStoredBidResponse("bidderTest", "123456");
    PrebidRenderingSettings.setStoredAuctionResponse("storedResponse");
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    BidRequest actualBidRequest = adRequestInput.getBidRequest();
    BidRequest expectedBidRequest = getExpectedBidRequest(adConfiguration, actualBidRequest.getId());
    assertEquals(expectedBidRequest.getJsonObject().toString(), actualBidRequest.getJsonObject().toString());
    Imp actualImp = actualBidRequest.getImp().get(0);
    assertNotNull(actualImp.banner);
    assertTrue(actualImp.banner.getFormats().containsAll(expectedBidRequest.getImp().get(0).banner.getFormats()));
    assertNull(actualImp.video);
    assertEquals(1, actualImp.secure.intValue());
    assertEquals(0, actualImp.instl.intValue());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 9 with Imp

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method getExpectedImp.

private Imp getExpectedImp(AdConfiguration adConfiguration, String uuid) {
    Imp imp = new Imp();
    imp.displaymanager = BasicParameterBuilder.DISPLAY_MANAGER_VALUE;
    imp.displaymanagerver = PrebidRenderingSettings.SDK_VERSION;
    if (!adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.VAST)) {
        imp.secure = 1;
    }
    // Send 1 for interstitial/interstitial video and 0 for banners
    boolean isInterstitial = adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.VAST) || adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.INTERSTITIAL);
    imp.instl = isInterstitial ? 1 : 0;
    // 0 == embedded, 1 == native
    imp.clickBrowser = !PrebidRenderingSettings.useExternalBrowser && mBrowserActivityAvailable ? 0 : 1;
    imp.id = uuid;
    imp.getExt().put("prebid", Prebid.getJsonObjectForImp(adConfiguration));
    if (adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.VAST)) {
        imp.video = getExpectedVideoImpValues(imp, adConfiguration);
    } else {
        imp.banner = getExpectedBannerImpValues(imp, adConfiguration);
    }
    final String pbAdSlot = adConfiguration.getPbAdSlot();
    if (pbAdSlot != null) {
        JSONObject context = new JSONObject();
        JSONObject data = new JSONObject();
        Utils.addValue(data, "adslot", pbAdSlot);
        Utils.addValue(context, "data", data);
        imp.getExt().put("context", context);
    }
    return imp;
}
Also used : JSONObject(org.json.JSONObject) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)

Example 10 with Imp

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method getExpectedBidRequest.

private BidRequest getExpectedBidRequest(AdConfiguration adConfiguration, String uuid) {
    BidRequest bidRequest = new BidRequest();
    bidRequest.setId(uuid);
    boolean isVideo = adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.VAST);
    bidRequest.getExt().put("prebid", Prebid.getJsonObjectForBidRequest(PrebidRenderingSettings.getAccountId(), isVideo));
    // if coppaEnabled - set 1, else No coppa is sent
    if (PrebidRenderingSettings.isCoppaEnabled) {
        bidRequest.getRegs().coppa = 1;
    }
    Imp imp = getExpectedImp(adConfiguration, uuid);
    bidRequest.getImp().add(imp);
    Source source = bidRequest.getSource();
    source.setTid(uuid);
    source.getExt().put(KEY_OM_PARTNER_NAME, OmAdSessionManager.PARTNER_NAME);
    source.getExt().put(KEY_OM_PARTNER_VERSION, OmAdSessionManager.PARTNER_VERSION);
    bidRequest.getUser();
    return bidRequest;
}
Also used : Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) Source(org.prebid.mobile.rendering.models.openrtb.bidRequests.source.Source) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest)

Aggregations

Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)13 Test (org.junit.Test)9 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)8 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)8 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)6 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)5 JSONObject (org.json.JSONObject)3 ArrayList (java.util.ArrayList)1 JSONArray (org.json.JSONArray)1 App (org.prebid.mobile.rendering.models.openrtb.bidRequests.App)1 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)1 Regs (org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 Format (org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format)1 Source (org.prebid.mobile.rendering.models.openrtb.bidRequests.source.Source)1