Skip to content

Commit 5478c34

Browse files
ahmadlobjorgeluisrocha
authored andcommitted
Taboola Bid Adapter: resolve AUCTION_PRICE macro (prebid#9735)
* replace-macro * replace-macro * replace-macro
1 parent da26ccf commit 5478c34

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

modules/taboolaBidAdapter.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,16 @@ function getBid(bids, currency, bidResponse) {
278278
if (!bidResponse) {
279279
return;
280280
}
281-
const {
281+
let {
282282
price: cpm, nurl, crid: creativeId, adm: ad, w: width, h: height, exp: ttl, adomain: advertiserDomains, meta = {}
283283
} = bidResponse;
284284
let requestId = bids[bidResponse.impid - 1].bidId;
285285
if (advertiserDomains && advertiserDomains.length > 0) {
286286
meta.advertiserDomains = advertiserDomains
287287
}
288288

289+
ad = replaceAuctionPrice(ad, cpm);
290+
289291
return {
290292
requestId,
291293
ttl,

test/spec/modules/taboolaBidAdapter_spec.js

+101
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,107 @@ describe('Taboola Adapter', function () {
668668
const res = spec.interpretResponse(serverResponse, request);
669669
expect(res).to.deep.equal(expectedRes);
670670
});
671+
672+
it('should replace AUCTION_PRICE macro in adm', function () {
673+
const multiRequest = {
674+
bids: [
675+
{
676+
...createBidRequest(),
677+
...displayBidRequestParams
678+
},
679+
{
680+
...createBidRequest(),
681+
...displayBidRequestParams
682+
}
683+
]
684+
}
685+
const multiServerResponseWithMacro = {
686+
body: {
687+
'id': '49ffg4d58ef9a163a69fhgfghd4fad03621b9e036f24f7_15',
688+
'seatbid': [
689+
{
690+
'bid': [
691+
{
692+
'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c',
693+
'impid': '2',
694+
'price': 0.34,
695+
'adid': '2785119545551083381',
696+
'adm': 'ADM2,\\nwp:\'${AUCTION_PRICE}\'',
697+
'adomain': [
698+
'example.xyz'
699+
],
700+
'cid': '15744349',
701+
'crid': '278195503434041083381',
702+
'w': 300,
703+
'h': 250,
704+
'exp': 60,
705+
'lurl': 'http://us-trc.taboola.com/sample',
706+
'nurl': 'http://win.example.com/'
707+
},
708+
{
709+
'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c',
710+
'impid': '1',
711+
'price': 0.35,
712+
'adid': '2785119545551083381',
713+
'adm': 'ADM2,\\nwp:\'${AUCTION_PRICE}\'',
714+
'adomain': [
715+
'example.xyz'
716+
],
717+
'cid': '15744349',
718+
'crid': '278195503434041083381',
719+
'w': 300,
720+
'h': 250,
721+
'exp': 60,
722+
'lurl': 'http://us-trc.taboola.com/sample',
723+
'nurl': 'http://win.example.com/'
724+
725+
}
726+
],
727+
'seat': '14204545260'
728+
}
729+
],
730+
'bidid': 'da43860a-4644-442a-b5e0-93f268cf8d19',
731+
'cur': 'USD'
732+
}
733+
};
734+
const [bid] = multiServerResponseWithMacro.body.seatbid[0].bid;
735+
const expectedRes = [
736+
{
737+
requestId: multiRequest.bids[1].bidId,
738+
cpm: multiServerResponseWithMacro.body.seatbid[0].bid[0].price,
739+
creativeId: bid.crid,
740+
ttl: 60,
741+
netRevenue: true,
742+
currency: multiServerResponseWithMacro.body.cur,
743+
mediaType: 'banner',
744+
ad: 'ADM2,\\nwp:\'0.34\'',
745+
width: bid.w,
746+
height: bid.h,
747+
nurl: 'http://win.example.com/',
748+
meta: {
749+
'advertiserDomains': bid.adomain
750+
},
751+
},
752+
{
753+
requestId: multiRequest.bids[0].bidId,
754+
cpm: multiServerResponseWithMacro.body.seatbid[0].bid[1].price,
755+
creativeId: bid.crid,
756+
ttl: 60,
757+
netRevenue: true,
758+
currency: multiServerResponseWithMacro.body.cur,
759+
mediaType: 'banner',
760+
ad: 'ADM2,\\nwp:\'0.35\'',
761+
width: bid.w,
762+
height: bid.h,
763+
nurl: 'http://win.example.com/',
764+
meta: {
765+
'advertiserDomains': bid.adomain
766+
},
767+
}
768+
];
769+
const res = spec.interpretResponse(multiServerResponseWithMacro, multiRequest);
770+
expect(res).to.deep.equal(expectedRes);
771+
});
671772
})
672773

673774
describe('getUserSyncs', function () {

0 commit comments

Comments
 (0)