Skip to content

Commit

Permalink
No bid version 1.2.5 (#5137)
Browse files Browse the repository at this point in the history
* Enable supplyChain support

* Added support for COPPA

* Added support for video ad type

* Fix lint errors

* Fix lint

* Removed "useless condition"

* Using ddepAccess and fixed version to 1.2.5

* Fix lint

* Fixed vidoe test
  • Loading branch information
redaguermas authored Apr 22, 2020
1 parent 1e1a720 commit e8d3119
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 14 deletions.
51 changes: 37 additions & 14 deletions modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as utils from '../src/utils.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
const BIDDER_CODE = 'nobid';
window.nobidVersion = '1.2.4';
window.nobidVersion = '1.2.5';
window.nobid = window.nobid || {};
window.nobid.bidResponses = window.nobid.bidResponses || {};
window.nobid.timeoutTotal = 0;
Expand Down Expand Up @@ -156,9 +156,6 @@ function nobidBuildRequests(bids, bidderRequest) {
} else {
a.g = {};
}
if (adunitObject.companion) {
a.c = adunitObject.companion;
}
if (adunitObject.div) {
removeByAttrValue(adunits, 'd', adunitObject.div);
}
Expand All @@ -171,9 +168,11 @@ function nobidBuildRequests(bids, bidderRequest) {
if (adunitObject.placementId) {
a.pid = adunitObject.placementId;
}
/* {"BIDDER_ID":{"WxH":"TAG_ID", "WxH":"TAG_ID"}} */
if (adunitObject.rtb) {
a.rtb = adunitObject.rtb;
if (adunitObject.ad_type) {
a.at = adunitObject.ad_type;
}
if (adunitObject.params) {
a.params = adunitObject.params;
}
adunits.push(a);
return adunits;
Expand All @@ -197,10 +196,24 @@ function nobidBuildRequests(bids, bidderRequest) {
var sizes = bid.sizes;
siteId = (typeof bid.params['siteId'] != 'undefined' && bid.params['siteId']) ? bid.params['siteId'] : siteId;
var placementId = bid.params['placementId'];
if (siteId && bid.params && bid.params.tags) {
newAdunit({div: divid, sizes: sizes, rtb: bid.params.tags, siteId: siteId, placementId: placementId}, adunits);
} else if (siteId) {
newAdunit({div: divid, sizes: sizes, siteId: siteId, placementId: placementId}, adunits);

var adType = 'banner';
const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video');
const context = utils.deepAccess(bid, 'mediaTypes.video.context');
if (bid.mediaType === VIDEO || (videoMediaType && context === 'instream')) {
adType = 'video';
}

if (siteId) {
newAdunit({
div: divid,
sizes: sizes,
siteId: siteId,
placementId: placementId,
ad_type: adType,
params: bid.params
},
adunits);
}
}
if (siteId) {
Expand Down Expand Up @@ -246,8 +259,18 @@ function nobidInterpretResponse(response, bidRequest) {
netRevenue: true,
ttl: 300,
ad: bid.adm,
mediaType: BANNER
mediaType: bid.atype || BANNER,
};
if (bid.vastUrl) {
bidResponse.vastUrl = bid.vastUrl;
}
if (bid.vastXml) {
bidResponse.vastXml = bid.vastXml;
}
if (bid.videoCacheKey) {
bidResponse.videoCacheKey = bid.videoCacheKey;
}

bidResponses.push(bidResponse);
}
return bidResponses;
Expand All @@ -266,7 +289,7 @@ window.nobid.renderTag = function(doc, id, win) {
}
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
supportedMediaTypes: [BANNER, VIDEO],
/**
* Determines whether or not the given bid request is valid.
*
Expand Down
89 changes: 89 additions & 0 deletions test/spec/modules/nobidBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,95 @@ describe('Nobid Adapter', function () {
});
});

describe('isVideoBidRequestValid', function () {
let bid = {
bidder: 'nobid',
params: {
siteId: 2,
video: {
skippable: true,
playback_methods: ['auto_play_sound_off'],
position: 'atf',
mimes: ['video/x-flv', 'video/mp4', 'video/x-ms-wmv', 'application/x-shockwave-flash', 'application/javascript'],
minduration: 1,
maxduration: 30,
frameworks: [1, 2, 3, 4, 5, 6]
}
},
adUnitCode: 'adunit-code',
sizes: [[640, 480]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
mediaTypes: {
video: {
context: 'instream'
}
}
};
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
let bidRequests = [
{
bidder: 'nobid',
params: {
siteId: SITE_ID,
video: {
skippable: true,
playback_methods: ['auto_play_sound_off'],
position: 'atf',
mimes: ['video/x-flv', 'video/mp4', 'video/x-ms-wmv', 'application/x-shockwave-flash', 'application/javascript'],
minduration: 1,
maxduration: 30,
frameworks: [1, 2, 3, 4, 5, 6]
}
},
adUnitCode: 'adunit-code',
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
}
}
];

let bidderRequest = {
refererInfo: {referer: REFERER}
}

it('should add source and version to the tag', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.sid).to.equal(SITE_ID);
expect(payload.l).to.exist.and.to.equal(encodeURIComponent(REFERER));
expect(payload.a).to.exist;
expect(payload.t).to.exist;
expect(payload.tz).to.exist;
expect(payload.r).to.exist;
expect(payload.lang).to.exist;
expect(payload.ref).to.exist;
expect(payload.a[0].d).to.exist.and.to.equal('adunit-code');
expect(payload.a[0].at).to.exist.and.to.equal('video');
expect(payload.a[0].params.video).to.exist;
expect(payload.a[0].params.video.skippable).to.exist.and.to.equal(true);
expect(payload.a[0].params.video.playback_methods).to.exist.and.to.contain('auto_play_sound_off');
expect(payload.a[0].params.video.position).to.exist.and.to.equal('atf');
expect(payload.a[0].params.video.mimes).to.exist.and.to.contain('video/x-flv');
expect(payload.a[0].params.video.minduration).to.exist.and.to.equal(1);
expect(payload.a[0].params.video.maxduration).to.exist.and.to.equal(30);
expect(payload.a[0].params.video.frameworks[0]).to.exist.and.to.equal(1);
expect(payload.a[0].params.video.frameworks[1]).to.exist.and.to.equal(2);
expect(payload.a[0].params.video.frameworks[2]).to.exist.and.to.equal(3);
expect(payload.a[0].params.video.frameworks[3]).to.exist.and.to.equal(4);
expect(payload.a[0].params.video.frameworks[4]).to.exist.and.to.equal(5);
expect(payload.a[0].params.video.frameworks[5]).to.exist.and.to.equal(6);
});
});

describe('buildRequests', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
Expand Down

0 comments on commit e8d3119

Please sign in to comment.