Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taboola Bid Adapter: resolve AUCTION_PRICE macro #9735

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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