Skip to content
This repository was archived by the owner on Feb 13, 2021. It is now read-only.

Commit 5aa0d51

Browse files
committed
Merge pull request prebid#103 in AOLP_ADS_JS/prebid.js from release/Prebid-1.22.0 to aolgithub-master
* commit '06ac7c72658678177dfa9aaa643267c0d78754a7': Added test cases for not resolved endpoints. Added tests for testing aliases. Fixed access to Marketplace via onedisplay bidder code. Fixed issue with using aol as bidder code for aliases. Fixed review notes. Fixed reporting when marketplace params are missed. Added changelog entry. Pick up nexage endpoint if marketplace and nexage params are specified. Add aliases for AOL adapter.
2 parents 1e1c57f + 06ac7c7 commit 5aa0d51

File tree

6 files changed

+202
-61
lines changed

6 files changed

+202
-61
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
AOL Prebid 1.22.0
2+
----------------
3+
Added aliases for AOL adapter.
4+
5+
16
AOL Prebid 1.21.0
27
----------------
38
Updated to Prebid 0.23.1

adapters.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
"trion",
6969
"prebidServer",
7070
"adsupply",
71+
{
72+
"aol": {
73+
"alias": "onemobile"
74+
}
75+
},
76+
{
77+
"aol": {
78+
"alias": "onedisplay"
79+
}
80+
},
7181
{
7282
"appnexus": {
7383
"alias": "brealtime"

src/adapters/analytics/aol.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ const utils = require('../../utils');
1414

1515
const AUCTION_END = CONSTANTS.EVENTS.AUCTION_END;
1616
const BID_WON = CONSTANTS.EVENTS.BID_WON;
17-
const AOL_BIDDER_CODE = 'aol';
17+
const AOL_BIDDERS_CODES = {
18+
aol: 'aol',
19+
onemobile: 'onemobile',
20+
onedisplay: 'onedisplay'
21+
};
1822
const analyticsType = 'endpoint';
1923

2024
const serverMap = {
@@ -310,9 +314,13 @@ function initAdUnit(adUnitCode) {
310314
};
311315
}
312316

317+
function isAolBidder(bidderCode) {
318+
return AOL_BIDDERS_CODES[bidderCode];
319+
}
320+
313321
function addAolParams(adUnit, adUnitsConf, bidsReceived) {
314322
const filteredBids = bidsReceived.filter(
315-
bid => bid.bidderCode === AOL_BIDDER_CODE && bid.adUnitCode === adUnit.code
323+
bid => isAolBidder(bid.bidderCode) && bid.adUnitCode === adUnit.code
316324
);
317325
const onlyOneBid = filteredBids.length === 1;
318326
const pubapiId = (onlyOneBid) ? filteredBids[0].pubapiId : '';
@@ -321,7 +329,7 @@ function addAolParams(adUnit, adUnitsConf, bidsReceived) {
321329
adUnitsConf.forEach(adUnitConf => {
322330
if (adUnitConf.code === adUnit.code) {
323331
adUnitConf.bids.forEach(adUnitBid => {
324-
if (adUnitBid.bidder === AOL_BIDDER_CODE && adUnitBid.params.placement && adUnitBid.params.network) {
332+
if (isAolBidder(adUnitBid.bidder) && adUnitBid.params.placement && adUnitBid.params.network) {
325333
adUnit.aolParams = adUnitBid.params;
326334
adUnit.aolParams.pubapiId = pubapiId;
327335
adUnit.aolParams.currencyCode = currencyCode;

src/adapters/analytics/aolPartnersIds.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,7 @@
7272
"pubgears": 71,
7373
"adsupply": 72,
7474
"quantcast": 73,
75-
"prebidServer": 74
75+
"prebidServer": 74,
76+
"onemobile": 75,
77+
"onedisplay": 76
7678
}

src/adapters/aol.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const ajax = require('../ajax.js').ajax;
33
const bidfactory = require('../bidfactory.js');
44
const bidmanager = require('../bidmanager.js');
55
const constants = require('../constants.json');
6+
const BaseAdapter = require('./adapter.js');
67

78
$$PREBID_GLOBAL$$.aolGlobals = {
89
pixelsDropped: false
@@ -14,7 +15,6 @@ const AolAdapter = function AolAdapter() {
1415
const pubapiTemplate = template`${'protocol'}://${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'}${'bidfloor'};misc=${'misc'}`;
1516
const nexageBaseApiTemplate = template`${'protocol'}://${'host'}/bidRequest?`;
1617
const nexageGetApiTemplate = template`dcn=${'dcn'}&pos=${'pos'}&cmd=bid${'ext'}`;
17-
const BIDDER_CODE = 'aol';
1818
const MP_SERVER_MAP = {
1919
us: 'adserver-us.adtech.advertising.com',
2020
eu: 'adserver-eu.adtech.advertising.com',
@@ -25,6 +25,11 @@ const AolAdapter = function AolAdapter() {
2525
iframe: 'IFRAME',
2626
img: 'IMG'
2727
};
28+
const AOL_BIDDERS_CODES = {
29+
aol: 'aol',
30+
onemobile: 'onemobile',
31+
onedisplay: 'onedisplay'
32+
};
2833

2934
let domReady = (() => {
3035
let readyEventFired = false;
@@ -175,7 +180,7 @@ const AolAdapter = function AolAdapter() {
175180

176181
function _addErrorBidResponse(bid, response = {}) {
177182
const bidResponse = bidfactory.createBid(2, bid);
178-
bidResponse.bidderCode = BIDDER_CODE;
183+
bidResponse.bidderCode = bid.bidder;
179184
bidResponse.reason = response.nbr;
180185
bidResponse.raw = response;
181186
bidmanager.addBidResponse(bid.placementCode, bidResponse);
@@ -199,7 +204,7 @@ const AolAdapter = function AolAdapter() {
199204
cpm = bidData.price;
200205

201206
if (cpm === null || isNaN(cpm)) {
202-
utils.logError('Invalid price in bid response', BIDDER_CODE, bid);
207+
utils.logError('Invalid price in bid response', AOL_BIDDERS_CODES.aol, bid);
203208
_addErrorBidResponse(bid, response);
204209
return;
205210
}
@@ -219,7 +224,7 @@ const AolAdapter = function AolAdapter() {
219224
}
220225

221226
const bidResponse = bidfactory.createBid(1, bid);
222-
bidResponse.bidderCode = BIDDER_CODE;
227+
bidResponse.bidderCode = bid.bidder;
223228
bidResponse.ad = ad;
224229
bidResponse.cpm = cpm;
225230
bidResponse.width = bidData.w;
@@ -234,15 +239,31 @@ const AolAdapter = function AolAdapter() {
234239
bidmanager.addBidResponse(bid.placementCode, bidResponse);
235240
}
236241

242+
function _isMarketplaceBidder(bidder) {
243+
return bidder === AOL_BIDDERS_CODES.aol || bidder === AOL_BIDDERS_CODES.onedisplay;
244+
}
245+
246+
function _isNexageBidder(bidder) {
247+
return bidder === AOL_BIDDERS_CODES.aol || bidder === AOL_BIDDERS_CODES.onemobile;
248+
}
249+
237250
function _isNexageRequestPost(bid) {
238-
if (bid.params.id && bid.params.imp && bid.params.imp[0]) {
251+
if (_isNexageBidder(bid.bidder) && bid.params.id && bid.params.imp && bid.params.imp[0]) {
239252
let imp = bid.params.imp[0];
240253
return imp.id && imp.tagid &&
241254
((imp.banner && imp.banner.w && imp.banner.h) ||
242255
(imp.video && imp.video.mimes && imp.video.minduration && imp.video.maxduration));
243256
}
244257
}
245258

259+
function _isNexageRequestGet(bid) {
260+
return _isNexageBidder(bid.bidder) && bid.params.dcn && bid.params.pos;
261+
}
262+
263+
function _isMarketplaceRequest(bid) {
264+
return _isMarketplaceBidder(bid.bidder) && bid.params.placement && bid.params.network;
265+
}
266+
246267
function _callBids(params) {
247268
utils._each(params.bids, bid => {
248269
let apiUrl;
@@ -251,9 +272,10 @@ const AolAdapter = function AolAdapter() {
251272
withCredentials: true
252273
};
253274
let isNexageRequestPost = _isNexageRequestPost(bid);
254-
if (bid.params.placement && bid.params.network) {
255-
apiUrl = _buildMarketplaceUrl(bid);
256-
} else if(bid.params.dcn && bid.params.pos || isNexageRequestPost) {
275+
let isNexageRequestGet = _isNexageRequestGet(bid);
276+
let isMarketplaceRequest = _isMarketplaceRequest(bid);
277+
278+
if (isNexageRequestGet || isNexageRequestPost) {
257279
apiUrl = _buildNexageApiUrl(bid);
258280
if (isNexageRequestPost) {
259281
data = bid.params;
@@ -263,7 +285,10 @@ const AolAdapter = function AolAdapter() {
263285
options.method = 'POST';
264286
options.contentType = 'application/json';
265287
}
288+
} else if (isMarketplaceRequest) {
289+
apiUrl = _buildMarketplaceUrl(bid);
266290
}
291+
267292
if (apiUrl) {
268293
ajax(apiUrl, response => {
269294
// Needs to be here in case bidderSettings are defined after requestBids() is called
@@ -279,15 +304,15 @@ const AolAdapter = function AolAdapter() {
279304
showCpmAdjustmentWarning = false; // warning is shown at most once
280305

281306
if (!response && response.length <= 0) {
282-
utils.logError('Empty bid response', BIDDER_CODE, bid);
307+
utils.logError('Empty bid response', AOL_BIDDERS_CODES.aol, bid);
283308
_addErrorBidResponse(bid, response);
284309
return;
285310
}
286311

287312
try {
288313
response = JSON.parse(response);
289314
} catch (e) {
290-
utils.logError('Invalid JSON in bid response', BIDDER_CODE, bid);
315+
utils.logError('Invalid JSON in bid response', AOL_BIDDERS_CODES.aol, bid);
291316
_addErrorBidResponse(bid, response);
292317
return;
293318
}
@@ -299,9 +324,12 @@ const AolAdapter = function AolAdapter() {
299324
});
300325
}
301326

302-
return {
303-
callBids: _callBids
304-
};
327+
return Object.assign(BaseAdapter.createNew(AOL_BIDDERS_CODES.aol), {
328+
callBids: _callBids,
329+
createNew: function () {
330+
return new AolAdapter();
331+
}
332+
});
305333
};
306334

307335
module.exports = AolAdapter;

0 commit comments

Comments
 (0)