use of org.prebid.mobile.rendering.models.openrtb.bidRequests.App in project prebid-mobile-android by prebid.
the class BidRequestTest method getJsonObject.
@Test
public void getJsonObject() throws Exception {
BidRequest bidReq = new BidRequest();
App app = new App();
app.id = "auid";
bidReq.setApp(app);
Device device = new Device();
device.h = 1111;
bidReq.setDevice(device);
Imp imp = new Imp();
imp.instl = 0;
ArrayList<Imp> imps = new ArrayList<>();
imps.add(imp);
bidReq.setImp(imps);
Regs regs = new Regs();
regs.coppa = 0;
bidReq.setRegs(regs);
User user = new User();
user.keywords = "q, o";
bidReq.setUser(user);
JSONObject actualObj = bidReq.getJsonObject();
String expectedString = "{\"app\":{\"id\":\"auid\"},\"regs\":{\"coppa\":0},\"imp\":[{\"instl\":0}],\"device\":{\"h\":1111},\"user\":{\"keywords\":\"q, o\"}}";
assertEquals("got: " + actualObj.toString(), expectedString, actualObj.toString());
bidReq.getJsonObject();
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.App in project prebid-mobile-android by prebid.
the class AppInfoParameterBuilderTest method testAppendBuilderParameters.
@Test
public void testAppendBuilderParameters() throws Exception {
AdConfiguration adConfiguration = new AdConfiguration();
ContentObject contentObject = new ContentObject();
contentObject.setUrl("test.com");
adConfiguration.setAppContent(contentObject);
AppInfoParameterBuilder builder = new AppInfoParameterBuilder(adConfiguration);
AdRequestInput adRequestInput = new AdRequestInput();
final String expectedStoreurl = "https://google.play.com";
final String expectedPublisherName = "prebid";
Targeting.setPublisherName(expectedPublisherName);
Targeting.setAppStoreMarketUrl(expectedStoreurl);
builder.appendBuilderParameters(adRequestInput);
BidRequest expectedBidRequest = new BidRequest();
final App expectedApp = expectedBidRequest.getApp();
expectedApp.name = APP_NAME;
expectedApp.bundle = APP_BUNDLE;
expectedApp.storeurl = expectedStoreurl;
expectedApp.getPublisher().name = expectedPublisherName;
expectedApp.getExt().put("prebid", Prebid.getJsonObjectForApp(BasicParameterBuilder.DISPLAY_MANAGER_VALUE, PrebidRenderingSettings.SDK_VERSION));
ContentObject expectedContentObject = new ContentObject();
expectedContentObject.setUrl("test.com");
expectedApp.contentObject = expectedContentObject;
assertEquals(expectedBidRequest.getJsonObject().toString(), adRequestInput.getBidRequest().getJsonObject().toString());
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.App in project prebid-mobile-android by prebid.
the class AppInfoParameterBuilder method appendBuilderParameters.
@Override
public void appendBuilderParameters(AdRequestInput adRequestInput) {
App app = adRequestInput.getBidRequest().getApp();
app.getPublisher().id = PrebidRenderingSettings.getAccountId();
String appName = AppInfoManager.getAppName();
if (Utils.isNotBlank(appName)) {
app.name = appName;
}
String appVersion = AppInfoManager.getAppVersion();
if (Utils.isNotBlank(appVersion)) {
app.ver = appVersion;
}
String bundle = AppInfoManager.getPackageName();
if (Utils.isNotBlank(bundle)) {
app.bundle = bundle;
}
String storeUrl = Targeting.getAppStoreMarketUrl();
if (Utils.isNotBlank(storeUrl)) {
app.storeurl = storeUrl;
}
String publisherName = Targeting.getPublisherName();
if (Utils.isNotBlank(publisherName)) {
app.getPublisher().name = publisherName;
}
app.contentObject = mAdConfiguration.getAppContent();
app.getExt().put("prebid", Prebid.getJsonObjectForApp(BasicParameterBuilder.DISPLAY_MANAGER_VALUE, PrebidRenderingSettings.SDK_VERSION));
final Map<String, Set<String>> contextDataDictionary = Targeting.getContextDataDictionary();
if (!contextDataDictionary.isEmpty()) {
app.getExt().put("data", Utils.toJson(contextDataDictionary));
}
}
Aggregations