Skip to content

Commit 081cf74

Browse files
ankurpatel18isoc-sarvanan
authored and
Chris Pabst
committed
AdbookPSP adapter updated with support of multiple Private Auction GAM Orders (prebid#7924)
Co-authored-by: Ankur <[email protected]>
1 parent 0958f52 commit 081cf74

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

modules/adbookpspBidAdapter.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ function impBidsToPrebidBids(
363363
}
364364

365365
const impToPrebidBid =
366-
(bidderRequestBody, bidResponseCurrency, referrer, targetingMap) => (bid) => {
366+
(bidderRequestBody, bidResponseCurrency, referrer, targetingMap) => (bid, bidIndex) => {
367367
try {
368368
const bidRequest = findBidRequest(bidderRequestBody, bid);
369369

@@ -377,7 +377,7 @@ const impToPrebidBid =
377377
let prebidBid = {
378378
ad: bid.adm,
379379
adId: bid.adid,
380-
adserverTargeting: targetingMap[bid.impid],
380+
adserverTargeting: targetingMap[bidIndex],
381381
adUnitCode: bidRequest.tagid,
382382
bidderRequestId: bidderRequestBody.id,
383383
bidId: bid.id,
@@ -408,6 +408,9 @@ const impToPrebidBid =
408408
};
409409
}
410410

411+
if (deepAccess(bid, 'ext.pa_win') === true) {
412+
prebidBid.auctionWinner = true;
413+
}
411414
return prebidBid;
412415
} catch (error) {
413416
logError(`${BIDDER_CODE}: Error while building bid`, error);
@@ -429,29 +432,43 @@ function buildTargetingMap(bids) {
429432
const values = impIds.reduce((result, id) => {
430433
result[id] = {
431434
lineItemIds: [],
435+
orderIds: [],
432436
dealIds: [],
433437
adIds: [],
438+
adAndOrderIndexes: []
434439
};
435440

436441
return result;
437442
}, {});
438443

439-
bids.forEach((bid) => {
440-
values[bid.impid].lineItemIds.push(bid.ext.liid);
441-
values[bid.impid].dealIds.push(bid.dealid);
442-
values[bid.impid].adIds.push(bid.adid);
444+
bids.forEach((bid, bidIndex) => {
445+
let impId = bid.impid;
446+
values[impId].lineItemIds.push(bid.ext.liid);
447+
values[impId].dealIds.push(bid.dealid);
448+
values[impId].adIds.push(bid.adid);
449+
450+
if (deepAccess(bid, 'ext.ordid')) {
451+
values[impId].orderIds.push(bid.ext.ordid);
452+
bid.ext.ordid.split(TARGETING_VALUE_SEPARATOR).forEach((ordid, ordIndex) => {
453+
let adIdIndex = values[impId].adIds.indexOf(bid.adid);
454+
values[impId].adAndOrderIndexes.push(adIdIndex + '_' + ordIndex)
455+
})
456+
}
443457
});
444458

445459
const targetingMap = {};
446460

447-
for (const id of impIds) {
448-
targetingMap[id] = {
461+
bids.forEach((bid, bidIndex) => {
462+
let id = bid.impid;
463+
464+
targetingMap[bidIndex] = {
449465
hb_liid_adbookpsp: values[id].lineItemIds.join(TARGETING_VALUE_SEPARATOR),
450466
hb_deal_adbookpsp: values[id].dealIds.join(TARGETING_VALUE_SEPARATOR),
467+
hb_ad_ord_adbookpsp: values[id].adAndOrderIndexes.join(TARGETING_VALUE_SEPARATOR),
451468
hb_adid_c_adbookpsp: values[id].adIds.join(TARGETING_VALUE_SEPARATOR),
469+
hb_ordid_adbookpsp: values[id].orderIds.join(TARGETING_VALUE_SEPARATOR),
452470
};
453-
}
454-
471+
})
455472
return targetingMap;
456473
}
457474

test/spec/modules/adbookpspBidAdapter_spec.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,11 @@ describe('adbookpsp bid adapter', () => {
504504
ad: '<div>ad</div>',
505505
adId: '5',
506506
adserverTargeting: {
507+
hb_ad_ord_adbookpsp: '0_0', // the value to the left of the underscore represents the index of the ad id and the number to the right represents the order index
507508
hb_adid_c_adbookpsp: '5',
508509
hb_deal_adbookpsp: 'werwetwerw',
509510
hb_liid_adbookpsp: '2342345',
511+
hb_ordid_adbookpsp: '567843',
510512
},
511513
referrer: 'http://prebid-test-page.io:8080/banner.html',
512514
lineItemId: '2342345',
@@ -516,9 +518,11 @@ describe('adbookpsp bid adapter', () => {
516518
adId: '10',
517519
adUnitCode: 'div-gpt-ad-837465923534-0',
518520
adserverTargeting: {
521+
hb_ad_ord_adbookpsp: '0_0',
519522
hb_adid_c_adbookpsp: '10',
520523
hb_deal_adbookpsp: 'dsfxcxcvxc',
521524
hb_liid_adbookpsp: '2121221',
525+
hb_ordid_adbookpsp: '5678234',
522526
},
523527
bidId: 'bid4321',
524528
bidderRequestId: '999ccceeee11',
@@ -556,14 +560,18 @@ describe('adbookpsp bid adapter', () => {
556560

557561
expect(bids).to.have.length(2);
558562
expect(bids[0].adserverTargeting).to.deep.equal({
563+
hb_ad_ord_adbookpsp: '0_0',
564+
hb_adid_c_adbookpsp: '5',
559565
hb_deal_adbookpsp: 'werwetwerw',
560566
hb_liid_adbookpsp: '2342345',
561-
hb_adid_c_adbookpsp: '5',
567+
hb_ordid_adbookpsp: '567843',
562568
});
563569
expect(bids[1].adserverTargeting).to.deep.equal({
570+
hb_ad_ord_adbookpsp: '0_0',
571+
hb_adid_c_adbookpsp: '10',
564572
hb_deal_adbookpsp: 'dsfxcxcvxc',
565573
hb_liid_adbookpsp: '2121221',
566-
hb_adid_c_adbookpsp: '10',
574+
hb_ordid_adbookpsp: '5678234',
567575
});
568576
});
569577

@@ -580,9 +588,11 @@ describe('adbookpsp bid adapter', () => {
580588
expect(bids).to.have.length(2);
581589
for (const bid of bids) {
582590
expect(bid.adserverTargeting).to.deep.equal({
591+
hb_ad_ord_adbookpsp: '0_0,1_0',
592+
hb_adid_c_adbookpsp: '5,10',
583593
hb_deal_adbookpsp: 'werwetwerw,dsfxcxcvxc',
584594
hb_liid_adbookpsp: '2342345,2121221',
585-
hb_adid_c_adbookpsp: '5,10',
595+
hb_ordid_adbookpsp: '567843,5678234',
586596
});
587597
}
588598
});
@@ -670,9 +680,11 @@ describe('adbookpsp bid adapter', () => {
670680
);
671681

672682
expect(bids[0].adserverTargeting).to.deep.equal({
683+
hb_ad_ord_adbookpsp: '0_0',
673684
hb_adid_c_adbookpsp: '10',
674685
hb_deal_adbookpsp: 'dsfxcxcvxc',
675686
hb_liid_adbookpsp: '2121221',
687+
hb_ordid_adbookpsp: '5678234',
676688
});
677689
});
678690

@@ -1279,6 +1291,7 @@ const exchangeResponse = {
12791291
nurl: 'http://win.example.url',
12801292
ext: {
12811293
liid: '2342345',
1294+
ordid: '567843',
12821295
},
12831296
cat: ['IAB2-1', 'IAB2-2', 'IAB2-3'],
12841297
adomain: ['advertiser.com'],
@@ -1301,6 +1314,7 @@ const exchangeResponse = {
13011314
nurl: 'http://win.example.url',
13021315
ext: {
13031316
liid: '2121221',
1317+
ordid: '5678234',
13041318
},
13051319
cat: ['IAB2-3'],
13061320
adomain: ['advertiser.com', 'campaign.advertiser.com'],

0 commit comments

Comments
 (0)