Search in sources :

Example 1 with Ext

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

the class Seatbid method fromJSONObject.

public static Seatbid fromJSONObject(JSONObject jsonObject) {
    Seatbid seatbid = new Seatbid();
    if (jsonObject == null) {
        return seatbid;
    }
    if (jsonObject.has("bid")) {
        JSONArray jsonArray = jsonObject.optJSONArray("bid");
        for (int i = 0; i < jsonArray.length(); i++) {
            Bid bid = Bid.fromJSONObject(jsonArray.optJSONObject(i));
            if (bid != null) {
                seatbid.mBids.add(bid);
            }
        }
    }
    seatbid.mSeat = jsonObject.optString("seat");
    seatbid.mGroup = jsonObject.optInt("group", -1);
    seatbid.mExt = new Ext();
    if (jsonObject.has("ext")) {
        seatbid.mExt.put(jsonObject.optJSONObject("ext"));
    }
    return seatbid;
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) JSONArray(org.json.JSONArray)

Example 2 with Ext

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

the class AppInfoParameterBuilderTest method whenAppendParametersAndTargetingContextDataNotEmpty_ContextDataAddedToAppExt.

@Test
public void whenAppendParametersAndTargetingContextDataNotEmpty_ContextDataAddedToAppExt() throws JSONException {
    Targeting.addContextData("context", "contextData");
    AppInfoParameterBuilder builder = new AppInfoParameterBuilder(new AdConfiguration());
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Ext appExt = adRequestInput.getBidRequest().getApp().getExt();
    assertTrue(appExt.getMap().containsKey("data"));
    JSONObject appDataJson = (JSONObject) appExt.getMap().get("data");
    assertTrue(appDataJson.has("context"));
    assertEquals("contextData", appDataJson.getJSONArray("context").get(0));
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) JSONObject(org.json.JSONObject) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Test(org.junit.Test)

Example 3 with Ext

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

the class TargetingTest method setUserExt_EqualToGetUserExt.

@Test
public void setUserExt_EqualToGetUserExt() {
    final Ext expected = new Ext();
    expected.put("external", "value");
    Targeting.setUserExt(expected);
    assertEquals(expected, Targeting.getUserExt());
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) Test(org.junit.Test)

Example 4 with Ext

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

the class BidResponse method parseJson.

private void parseJson(String json) {
    try {
        JSONObject responseJson = new JSONObject(json);
        mId = responseJson.optString("id");
        mCur = responseJson.optString("cur");
        mBidId = responseJson.optString("bidid");
        mCustomData = responseJson.optString("customdata");
        mNbr = responseJson.optInt("nbr", -1);
        if (responseJson.has("ext")) {
            mExt = new Ext();
            mExt.put(responseJson.optJSONObject("ext"));
        }
        JSONArray jsonSeatbids = responseJson.optJSONArray("seatbid");
        if (jsonSeatbids != null) {
            for (int i = 0; i < jsonSeatbids.length(); i++) {
                Seatbid seatbid = Seatbid.fromJSONObject(jsonSeatbids.optJSONObject(i));
                mSeatbids.add(seatbid);
            }
        }
        if (getWinningBid() == null) {
            mHasParseError = true;
            mParseError = "Failed to parse bids. No winning bids were found.";
            LogUtil.info(TAG, mParseError);
        }
        mCreationTime = System.currentTimeMillis();
    } catch (JSONException e) {
        mHasParseError = true;
        mParseError = "Failed to parse JSON String: " + e.getMessage();
        LogUtil.error(TAG, mParseError);
    }
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 5 with Ext

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

the class NativeEventTrackerTest method whenSetExt_ExtWasSet.

@Test
public void whenSetExt_ExtWasSet() {
    Ext ext = new Ext();
    ext.put("test", "test");
    ArrayList<NativeEventTracker.EventTrackingMethod> eventTrackingMethods = new ArrayList<>();
    eventTrackingMethods.add(NativeEventTracker.EventTrackingMethod.IMAGE);
    NativeEventTracker nativeEventTracker = new NativeEventTracker(NativeEventTracker.EventType.IMPRESSION, eventTrackingMethods);
    nativeEventTracker.setExt(ext);
    assertEquals(ext.getJsonObject().toString(), nativeEventTracker.getExt().getJsonObject().toString());
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Ext (org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext)8 Test (org.junit.Test)5 JSONArray (org.json.JSONArray)3 JSONObject (org.json.JSONObject)3 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)3 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)2 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)2 ArrayList (java.util.ArrayList)1 JSONException (org.json.JSONException)1 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)1 Geo (org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo)1