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;
}
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());
}
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());
}
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;
}
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;
}
Aggregations