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