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

Support for NURL and ADM as backup #2112

Merged
merged 1 commit into from
Feb 8, 2018
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
11 changes: 9 additions & 2 deletions modules/optimaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { registerBidder } from 'src/adapters/bidderFactory';
export const ENDPOINT = '//mg-bid.optimatic.com/adrequest/';

export const spec = {

version: '1.0.4',

code: 'optimatic',

supportedMediaTypes: ['video'],
Expand Down Expand Up @@ -33,7 +36,7 @@ export const spec = {
} catch (e) {
response = null;
}
if (!response || !bid || !bid.adm || !bid.price) {
if (!response || !bid || (!bid.adm && !bid.nurl) || !bid.price) {
utils.logWarn(`No valid bids from ${spec.code} bidder`);
return [];
}
Expand All @@ -43,14 +46,18 @@ export const spec = {
bidderCode: spec.code,
cpm: bid.price,
creativeId: bid.id,
vastXml: bid.adm,
width: size.width,
height: size.height,
mediaType: 'video',
currency: response.cur,
ttl: 300,
netRevenue: true
};
if (bid.nurl) {
bidResponse.vastUrl = bid.nurl;
} else if (bid.adm) {
bidResponse.vastXml = bid.adm;
}
return bidResponse;
}
};
Expand Down
42 changes: 40 additions & 2 deletions test/spec/modules/optimaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('OptimaticBidAdapter', () => {
expect(bidResponse.length).to.equal(0);
});

it('should return no bids if the response "adm" is missing', () => {
it('should return no bids if the response "nurl" and "adm" are missing', () => {
const serverResponse = {seatbid: [{bid: [{price: 5.01}]}]};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
expect(bidResponse.length).to.equal(0);
Expand All @@ -118,7 +118,7 @@ describe('OptimaticBidAdapter', () => {
expect(bidResponse.length).to.equal(0);
});

it('should return a valid bid response', () => {
it('should return a valid bid response with just "adm"', () => {
const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, adm: '<VAST></VAST>'}]}], cur: 'USD'};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
let o = {
Expand All @@ -136,5 +136,43 @@ describe('OptimaticBidAdapter', () => {
};
expect(bidResponse).to.deep.equal(o);
});

it('should return a valid bid response with just "nurl"', () => {
const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, nurl: 'https://mg-bid-win.optimatic.com/win/134eb262-948a-463e-ad93-bc8b622d399c?wp=${AUCTION_PRICE}'}]}], cur: 'USD'};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
let o = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: serverResponse.seatbid[0].bid[0].price,
creativeId: serverResponse.seatbid[0].bid[0].id,
vastUrl: serverResponse.seatbid[0].bid[0].nurl,
width: 640,
height: 480,
mediaType: 'video',
currency: 'USD',
ttl: 300,
netRevenue: true
};
expect(bidResponse).to.deep.equal(o);
});

it('should return a valid bid response with "nurl" when both nurl and adm exist', () => {
const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, adm: '<VAST></VAST>', nurl: 'https://mg-bid-win.optimatic.com/win/134eb262-948a-463e-ad93-bc8b622d399c?wp=${AUCTION_PRICE}'}]}], cur: 'USD'};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
let o = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: serverResponse.seatbid[0].bid[0].price,
creativeId: serverResponse.seatbid[0].bid[0].id,
vastUrl: serverResponse.seatbid[0].bid[0].nurl,
width: 640,
height: 480,
mediaType: 'video',
currency: 'USD',
ttl: 300,
netRevenue: true
};
expect(bidResponse).to.deep.equal(o);
});
});
});