Search in sources :

Example 1 with App

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();
}
Also used : App(org.prebid.mobile.rendering.models.openrtb.bidRequests.App) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) JSONObject(org.json.JSONObject) Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) ArrayList(java.util.ArrayList) Regs(org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) Test(org.junit.Test)

Example 2 with App

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());
}
Also used : App(org.prebid.mobile.rendering.models.openrtb.bidRequests.App) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) ContentObject(org.prebid.mobile.ContentObject) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 3 with App

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));
    }
}
Also used : App(org.prebid.mobile.rendering.models.openrtb.bidRequests.App) Set(java.util.Set)

Aggregations

App (org.prebid.mobile.rendering.models.openrtb.bidRequests.App)3 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 JSONObject (org.json.JSONObject)1 ContentObject (org.prebid.mobile.ContentObject)1 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)1 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)1 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)1 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)1 Regs (org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1