private void parseVideoCSMResponse(JSONObject ad, String adType, String notifyUrl, String creativeId) { JSONObject csm = JsonUtil.getJSONObject(ad, UTConstants.CSM); if (csm != null) { JSONArray handler = JsonUtil.getJSONArray(csm, RESPONSE_KEY_HANDLER); if (handler != null) { CSMVASTAdResponse csmVideoAd = new CSMVASTAdResponse(-1, -1, adType, null, creativeId); csmVideoAd.setAdJSONContent(ad); csmVideoAd.setAuction_id(String.valueOf(auctionID)); csmVideoAd.setTag_id(tagId); csmVideoAd.setTimeout_ms(timeout); csmVideoAd.setContentSource(UTConstants.CSM_VIDEO); adList.add(csmVideoAd); } } }
public String getCSMVASTAdResponse() { JSONObject tag = new JSONObject(); JSONArray ads = new JSONArray(); try { tag.put("uuid", getUuid()); tag.put("auction_id",getAuction_id()); tag.put("tag_id",getTag_id()); tag.put("timeout_ms",getTimeout_ms()); ads.put(getAdJSONContent()); tag.put("ads",ads); String escapedJSON = ""; try { escapedJSON= URLEncoder.encode(tag.toString(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return escapedJSON; } catch (JSONException e) { e.printStackTrace(); } return null; } }
private void handleCSMVASTAdResponse(VideoAd owner, CSMVASTAdResponse csmvastAdResponse) { if (csmvastAdResponse != null && csmvastAdResponse.getAdJSONContent() != null) { if (UTConstants.AD_TYPE_VIDEO.equalsIgnoreCase(csmvastAdResponse.getAdType())) { // @NOTE no need to fire notify URL here it is taken care by ASTMediationManager.js initiateVastAdView(owner, csmvastAdResponse); } else { continueWaterfall(ResultCode.UNABLE_TO_FILL); } } else { continueWaterfall(ResultCode.UNABLE_TO_FILL); } }
private void processMediationAd() { String tag = ((CSMVASTAdResponse) baseAdResponse).getCSMVASTAdResponse(); if (tag != null && !tag.isEmpty()) { String inject = String.format("javascript:window.processMediationAd('%s')", tag); this.injectJavaScript(inject); } }