Skip to content

Commit c7b060b

Browse files
JonGoSonobijaiminpanchal27
authored andcommitted
Sonobi - support video and display same adunit (#3325)
* changed adapter to support video and display for ad unit * added case for sbi_ct outstream * outstream is display media type
1 parent 7990f92 commit c7b060b

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

modules/sonobiBidAdapter.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { registerBidder } from 'src/adapters/bidderFactory';
2-
import { getTopWindowLocation, parseSizesInput, logError, generateUUID, deepAccess, isEmpty } from '../src/utils';
2+
import { getTopWindowLocation, parseSizesInput, logError, generateUUID, isEmpty } from '../src/utils';
33
import { BANNER, VIDEO } from '../src/mediaTypes';
4-
import find from 'core-js/library/fn/array/find';
54
import { config } from '../src/config';
65

76
const BIDDER_CODE = 'sonobi';
@@ -104,12 +103,10 @@ export const spec = {
104103
}
105104

106105
Object.keys(bidResponse.slots).forEach(slot => {
106+
const bid = bidResponse.slots[slot];
107107
const bidId = _getBidIdFromTrinityKey(slot);
108-
const bidRequest = find(bidderRequests, bidReqest => bidReqest.bidId === bidId);
109-
const videoMediaType = deepAccess(bidRequest, 'mediaTypes.video');
110-
const mediaType = bidRequest.mediaType || (videoMediaType ? 'video' : null);
108+
const mediaType = (bid.sbi_ct === 'video') ? 'video' : null;
111109
const createCreative = _creative(mediaType);
112-
const bid = bidResponse.slots[slot];
113110
if (bid.sbi_aid && bid.sbi_mouse && bid.sbi_size) {
114111
const [
115112
width = 1,
@@ -132,8 +129,7 @@ export const spec = {
132129
bids.dealId = bid.sbi_dozer;
133130
}
134131

135-
const creativeType = bid.sbi_ct;
136-
if (creativeType && (creativeType === 'video' || creativeType === 'outstream')) {
132+
if (mediaType === 'video') {
137133
bids.mediaType = 'video';
138134
bids.vastUrl = createCreative(bidResponse.sbi_dc, bid.sbi_aid);
139135
delete bids.ad;

test/spec/modules/sonobiBidAdapter_spec.js

+33-6
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ describe('SonobiBidAdapter', function () {
242242
},
243243
'adUnitCode': 'adunit-code-2',
244244
'sizes': [[120, 600], [300, 600], [160, 600]],
245-
'bidId': '30b31c1838de1e',
246-
'mediaType': 'video'
245+
'bidId': '30b31c1838de1e'
247246
},
248247
{
249248
'bidder': 'sonobi',
@@ -274,6 +273,14 @@ describe('SonobiBidAdapter', function () {
274273
'sbi_aid': '30292e432662bd5f86d90774b944b038',
275274
'sbi_mouse': 1.25,
276275
'sbi_dozer': 'dozerkey',
276+
'sbi_ct': 'video'
277+
},
278+
'/7780971/sparks_prebid_LB_OUTSTREAM|30b31c1838de1g': {
279+
'sbi_size': '300x600',
280+
'sbi_apoc': 'remnant',
281+
'sbi_crid': '1234abcd',
282+
'sbi_aid': '30292e432662bd5f86d90774b944b038',
283+
'sbi_mouse': 1.07,
277284
},
278285
'/7780971/sparks_prebid_LB|30b31c1838de1g': {},
279286
},
@@ -313,22 +320,42 @@ describe('SonobiBidAdapter', function () {
313320
'currency': 'USD',
314321
'dealId': 'dozerkey',
315322
'aid': '30292e432662bd5f86d90774b944b038'
316-
}
323+
},
324+
{
325+
'requestId': '30b31c1838de1g',
326+
'cpm': 1.07,
327+
'width': 300,
328+
'height': 600,
329+
'ad': `<script type="text/javascript" src="https://mco-1-apex.go.sonobi.com/sbi.js?aid=30292e432662bd5f86d90774b944b038&as=null&ref=http%3A%2F%2Flocalhost%2F"></script>`,
330+
'ttl': 500,
331+
'creativeId': '1234abcd',
332+
'netRevenue': true,
333+
'currency': 'USD',
334+
'aid': '30292e432662bd5f86d90774b944b038'
335+
},
317336
];
318337

319338
it('should map bidResponse to prebidResponse', function () {
320339
const response = spec.interpretResponse(bidResponse, bidRequests);
321340
response.forEach((resp, i) => {
322341
expect(resp.requestId).to.equal(prebidResponse[i].requestId);
323342
expect(resp.cpm).to.equal(prebidResponse[i].cpm);
324-
expect(resp.width).to.equal(prebidResponse[i].width);
325-
expect(resp.height).to.equal(prebidResponse[i].height);
343+
326344
expect(resp.ttl).to.equal(prebidResponse[i].ttl);
327345
expect(resp.creativeId).to.equal(prebidResponse[i].creativeId);
328346
expect(resp.netRevenue).to.equal(prebidResponse[i].netRevenue);
329347
expect(resp.currency).to.equal(prebidResponse[i].currency);
330348
expect(resp.aid).to.equal(prebidResponse[i].aid);
331-
expect(resp.ad.indexOf('localhost')).to.be.greaterThan(0);
349+
if (resp.mediaType === 'video') {
350+
expect(resp.vastUrl.indexOf('vast.xml')).to.be.greaterThan(0);
351+
expect(resp.ad).to.be.undefined;
352+
expect(resp.width).to.be.undefined;
353+
expect(resp.height).to.be.undefined;
354+
} else {
355+
expect(resp.ad.indexOf('localhost')).to.be.greaterThan(0);
356+
expect(resp.width).to.equal(prebidResponse[i].width);
357+
expect(resp.height).to.equal(prebidResponse[i].height);
358+
}
332359
});
333360
});
334361
});

0 commit comments

Comments
 (0)