Skip to content

Commit

Permalink
AdkernelAdn: meta fields support (#6899)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckbo3hrk authored Jun 1, 2021
1 parent d7a1418 commit d779cdc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
30 changes: 28 additions & 2 deletions modules/adkernelAdnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,49 @@ function buildBid(tag) {
requestId: tag.impid,
bidderCode: spec.code,
cpm: tag.bid,
width: tag.w,
height: tag.h,
creativeId: tag.crid,
currency: 'USD',
ttl: 720,
netRevenue: true
};
if (tag.w) {
bid.width = tag.w;
}
if (tag.h) {
bid.height = tag.h;
}
if (tag.tag) {
bid.ad = tag.tag;
bid.mediaType = BANNER;
} else if (tag.vast_url) {
bid.vastUrl = tag.vast_url;
bid.mediaType = VIDEO;
}
fillBidMeta(bid, tag);
return bid;
}

function fillBidMeta(bid, tag) {
if (utils.isStr(tag.agencyName)) {
utils.deepSetValue(bid, 'meta.agencyName', tag.agencyName);
}
if (utils.isNumber(tag.advertiserId)) {
utils.deepSetValue(bid, 'meta.advertiserId', tag.advertiserId);
}
if (utils.isStr(tag.advertiserName)) {
utils.deepSetValue(bid, 'meta.advertiserName', tag.advertiserName);
}
if (utils.isArray(tag.advertiserDomains)) {
utils.deepSetValue(bid, 'meta.advertiserDomains', tag.advertiserDomains);
}
if (utils.isStr(tag.primaryCatId)) {
utils.deepSetValue(bid, 'meta.primaryCatId', tag.primaryCatId);
}
if (utils.isArray(tag.secondaryCatIds)) {
utils.deepSetValue(bid, 'meta.secondaryCatIds', tag.secondaryCatIds);
}
}

function getBidFloor(bid, mediaType, sizes) {
var floor;
var size = sizes.length === 1 ? sizes[0] : '*';
Expand Down
19 changes: 17 additions & 2 deletions test/spec/modules/adkernelAdnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,25 @@ describe('AdkernelAdn adapter', function () {
bid: 5.0,
tag: '<!-- tag goes here -->',
w: 300,
h: 250
h: 250,
advertiserId: 777,
advertiserName: 'advertiser',
agencyName: 'agency',
advertiserDomains: ['example.com'],
primaryCatId: 'IAB1-1',
}, {
id: 'ad-unit-2',
impid: '31d798477126c4',
crid: '108_21226',
bid: 2.5,
tag: '<!-- tag goes here -->',
w: 300,
h: 250
h: 250,
advertiserId: 777,
advertiserName: 'advertiser',
agencyName: 'agency',
advertiserDomains: ['example.com'],
secondaryCatIds: ['IAB1-4', 'IAB8-16', 'IAB25-5']
}, {
id: 'video_wrapper',
impid: '57d602ad1c9545',
Expand Down Expand Up @@ -375,6 +385,11 @@ describe('AdkernelAdn adapter', function () {
expect(resp).to.have.property('mediaType', 'banner');
expect(resp).to.have.property('ad');
expect(resp.ad).to.have.string('<!-- tag goes here -->');
expect(resp.meta.advertiserId).to.be.eql(777);
expect(resp.meta.advertiserName).to.be.eql('advertiser');
expect(resp.meta.agencyName).to.be.eql('agency');
expect(resp.meta.advertiserDomains).to.be.eql(['example.com']);
expect(resp.meta.primaryCatId).to.be.eql('IAB1-1');
});

it('should return fully-initialized video bid-response', function () {
Expand Down

0 comments on commit d779cdc

Please sign in to comment.