Skip to content

Commit

Permalink
Taboola Bid Adapter: resolve AUCTION_PRICE macro (#9735)
Browse files Browse the repository at this point in the history
* replace-macro

* replace-macro

* replace-macro
  • Loading branch information
ahmadlob authored Mar 30, 2023
1 parent 3e86ef8 commit 8455bd2
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,16 @@ function getBid(bids, currency, bidResponse) {
if (!bidResponse) {
return;
}
const {
let {
price: cpm, nurl, crid: creativeId, adm: ad, w: width, h: height, exp: ttl, adomain: advertiserDomains, meta = {}
} = bidResponse;
let requestId = bids[bidResponse.impid - 1].bidId;
if (advertiserDomains && advertiserDomains.length > 0) {
meta.advertiserDomains = advertiserDomains
}

ad = replaceAuctionPrice(ad, cpm);

return {
requestId,
ttl,
Expand Down
101 changes: 101 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,107 @@ describe('Taboola Adapter', function () {
const res = spec.interpretResponse(serverResponse, request);
expect(res).to.deep.equal(expectedRes);
});

it('should replace AUCTION_PRICE macro in adm', function () {
const multiRequest = {
bids: [
{
...createBidRequest(),
...displayBidRequestParams
},
{
...createBidRequest(),
...displayBidRequestParams
}
]
}
const multiServerResponseWithMacro = {
body: {
'id': '49ffg4d58ef9a163a69fhgfghd4fad03621b9e036f24f7_15',
'seatbid': [
{
'bid': [
{
'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c',
'impid': '2',
'price': 0.34,
'adid': '2785119545551083381',
'adm': 'ADM2,\\nwp:\'${AUCTION_PRICE}\'',
'adomain': [
'example.xyz'
],
'cid': '15744349',
'crid': '278195503434041083381',
'w': 300,
'h': 250,
'exp': 60,
'lurl': 'http://us-trc.taboola.com/sample',
'nurl': 'http://win.example.com/'
},
{
'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c',
'impid': '1',
'price': 0.35,
'adid': '2785119545551083381',
'adm': 'ADM2,\\nwp:\'${AUCTION_PRICE}\'',
'adomain': [
'example.xyz'
],
'cid': '15744349',
'crid': '278195503434041083381',
'w': 300,
'h': 250,
'exp': 60,
'lurl': 'http://us-trc.taboola.com/sample',
'nurl': 'http://win.example.com/'

}
],
'seat': '14204545260'
}
],
'bidid': 'da43860a-4644-442a-b5e0-93f268cf8d19',
'cur': 'USD'
}
};
const [bid] = multiServerResponseWithMacro.body.seatbid[0].bid;
const expectedRes = [
{
requestId: multiRequest.bids[1].bidId,
cpm: multiServerResponseWithMacro.body.seatbid[0].bid[0].price,
creativeId: bid.crid,
ttl: 60,
netRevenue: true,
currency: multiServerResponseWithMacro.body.cur,
mediaType: 'banner',
ad: 'ADM2,\\nwp:\'0.34\'',
width: bid.w,
height: bid.h,
nurl: 'http://win.example.com/',
meta: {
'advertiserDomains': bid.adomain
},
},
{
requestId: multiRequest.bids[0].bidId,
cpm: multiServerResponseWithMacro.body.seatbid[0].bid[1].price,
creativeId: bid.crid,
ttl: 60,
netRevenue: true,
currency: multiServerResponseWithMacro.body.cur,
mediaType: 'banner',
ad: 'ADM2,\\nwp:\'0.35\'',
width: bid.w,
height: bid.h,
nurl: 'http://win.example.com/',
meta: {
'advertiserDomains': bid.adomain
},
}
];
const res = spec.interpretResponse(multiServerResponseWithMacro, multiRequest);
expect(res).to.deep.equal(expectedRes);
});
})

describe('getUserSyncs', function () {
Expand Down

0 comments on commit 8455bd2

Please sign in to comment.