Skip to content

Commit 6833118

Browse files
hybrid-aiSantiago Carabone
authored and
Santiago Carabone
committed
Vox Bid Addapter: add schain, floors, userid support (prebid#10109)
* vox bid adapter: add schain, floors, userid support * vox bid adapter: add schain, floors, userid support * vox bid adapter: add schain, floors, userid support * vox bid adapter: add schain, floors, userid support * vox bid adapter: add schain, floors, userid support
1 parent 31aa446 commit 6833118

File tree

2 files changed

+109
-5
lines changed

2 files changed

+109
-5
lines changed

modules/voxBidAdapter.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js';
44
import {find} from '../src/polyfill.js';
55
import {auctionManager} from '../src/auctionManager.js';
66
import {Renderer} from '../src/Renderer.js';
7+
import {config} from '../src/config.js'
8+
9+
const { getConfig } = config;
710

811
const BIDDER_CODE = 'vox';
912
const SSP_ENDPOINT = 'https://ssp.hybrid.ai/auction/prebid';
1013
const VIDEO_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';
1114
const TTL = 60;
1215

1316
function buildBidRequests(validBidRequests) {
14-
return _map(validBidRequests, function(validBidRequest) {
15-
const params = validBidRequest.params;
17+
return _map(validBidRequests, function(bid) {
18+
const currency = getConfig('currency.adServerCurrency');
19+
const floorInfo = bid.getFloor ? bid.getFloor({
20+
currency: currency || 'USD'
21+
}) : {};
22+
23+
const params = bid.params;
1624
const bidRequest = {
17-
bidId: validBidRequest.bidId,
25+
floorInfo,
26+
schain: bid.schain,
27+
userId: bid.userId,
28+
bidId: bid.bidId,
1829
// TODO: fix transactionId leak: https://github.com/prebid/Prebid.js/issues/9781
19-
transactionId: validBidRequest.transactionId,
20-
sizes: validBidRequest.sizes,
30+
transactionId: bid.transactionId,
31+
sizes: bid.sizes,
2132
placement: params.placement,
2233
placeId: params.placementId,
2334
imageUrl: params.imageUrl

test/spec/modules/voxBidAdapter_spec.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from 'chai'
22
import { spec } from 'modules/voxBidAdapter.js'
3+
import {config} from 'src/config.js'
34

45
function getSlotConfigs(mediaTypes, params) {
56
return {
@@ -175,6 +176,98 @@ describe('VOX Adapter', function() {
175176
expect(bid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459')
176177
})
177178
})
179+
it('should not set userid if not specified', function () {
180+
const request = spec.buildRequests(validBidRequests, bidderRequest)
181+
const data = JSON.parse(request.data)
182+
data.bidRequests.forEach(bid => {
183+
expect(bid.userId).to.be.undefined
184+
})
185+
})
186+
187+
it('should set userid if specified', function () {
188+
const requests = validBidRequests.map(bid => ({
189+
...bid,
190+
userId: {
191+
tdid: 'TDID_USER_ID',
192+
pubcid: 'PUBID_USER_ID'
193+
}
194+
}))
195+
const request = spec.buildRequests(requests, bidderRequest)
196+
const data = JSON.parse(request.data)
197+
data.bidRequests.forEach(bid => {
198+
expect(bid.userId.tdid).to.equal('TDID_USER_ID')
199+
expect(bid.userId.pubcid).to.equal('PUBID_USER_ID')
200+
})
201+
})
202+
203+
it('should not set schain if not specified', function () {
204+
const request = spec.buildRequests(validBidRequests, bidderRequest)
205+
const data = JSON.parse(request.data)
206+
data.bidRequests.forEach(bid => {
207+
expect(bid.schain).to.be.undefined
208+
})
209+
})
210+
211+
it('should set schain if not specified', function () {
212+
const requests = validBidRequests.map(bid => ({
213+
...bid,
214+
schain: {
215+
validation: 'strict',
216+
config: {
217+
ver: '1.0'
218+
}
219+
}
220+
}))
221+
const request = spec.buildRequests(requests, bidderRequest)
222+
const data = JSON.parse(request.data)
223+
data.bidRequests.forEach(bid => {
224+
expect(bid.schain.validation).to.equal('strict')
225+
expect(bid.schain.config.ver).to.equal('1.0')
226+
})
227+
})
228+
229+
describe('price floors', function () {
230+
it('should be empty if floors module not configured', function () {
231+
const request = spec.buildRequests(validBidRequests, bidderRequest)
232+
const data = JSON.parse(request.data)
233+
data.bidRequests.forEach(bid => {
234+
expect(bid.floorInfo).to.be.empty
235+
})
236+
})
237+
238+
it('should add correct floor values', function () {
239+
const expectedFloors = [ 2, 2.7, 1.4 ]
240+
const validBidRequests = expectedFloors.map(getBidWithFloor)
241+
const request = spec.buildRequests(validBidRequests, bidderRequest)
242+
const data = JSON.parse(request.data)
243+
expectedFloors.forEach((floor, index) => {
244+
expect(data.bidRequests[index].floorInfo.floor).to.equal(floor)
245+
expect(data.bidRequests[index].floorInfo.currency).to.equal('USD')
246+
})
247+
})
248+
249+
it('should request floor price in adserver currency', function () {
250+
const configCurrency = 'DKK'
251+
config.setConfig({ currency: { adServerCurrency: configCurrency } })
252+
const request = spec.buildRequests([ getBidWithFloor() ], bidderRequest)
253+
const data = JSON.parse(request.data)
254+
data.bidRequests.forEach(bid => {
255+
expect(bid.floorInfo.currency).to.equal(configCurrency)
256+
})
257+
})
258+
259+
function getBidWithFloor(floor) {
260+
return {
261+
...validBidRequests[0],
262+
getFloor: ({ currency }) => {
263+
return {
264+
currency: currency,
265+
floor
266+
}
267+
}
268+
}
269+
}
270+
})
178271

179272
describe('GDPR params', function() {
180273
describe('when there are not consent management platform', function() {

0 commit comments

Comments
 (0)