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

Added miltibid support for GroupM #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const USER_SYNC_URL_IMAGE = 'https://image8.pubmatic.com/AdServer/ImgSync?p=';
const DEFAULT_CURRENCY = 'USD';
const AUCTION_TYPE = 1;
const GROUPM_ALIAS = {code: 'groupm', gvlid: 98};
const MARKETPLACE_PARTNERS = ['groupm']
const UNDEFINED = undefined;
const DEFAULT_WIDTH = 0;
const DEFAULT_HEIGHT = 0;
Expand Down Expand Up @@ -1065,6 +1066,12 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: (validBidRequests, bidderRequest) => {
if (bidderRequest && MARKETPLACE_PARTNERS.includes(bidderRequest.bidderCode)) {
// We have got the buildRequests function call for Marketplace Partners
logInfo('For all publishers using ' + bidderRequest.bidderCode + ' bidder, the PubMatic bidder will also be enabled so PubMatic server will respond back with the bids that needs to be submitted for PubMatic and ' + bidderRequest.bidderCode + ' in the network call sent by PubMatic bidder. Hence we do not want to create a network call for ' + bidderRequest.bidderCode + '. This way we are trying to save a network call from browser.');
return;
}

var refererInfo;
if (bidderRequest && bidderRequest.refererInfo) {
refererInfo = bidderRequest.refererInfo;
Expand Down Expand Up @@ -1287,6 +1294,13 @@ export const spec = {
};
}

// if from the server-response the bid.ext.marketplace is set then
// submit the bid to Prebid as marketplace name
if (bid.ext && !!bid.ext.marketplace && MARKETPLACE_PARTNERS.includes(bid.ext.marketplace)) {
newBid.bidderCode = bid.ext.marketplace;
newBid.bidder = bid.ext.marketplace;
}

bidResponses.push(newBid);
});
});
Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3901,4 +3901,40 @@ describe('PubMatic adapter', function () {
expect(data.imp[0]['video']['battr']).to.equal(undefined);
});
});

describe('GroupM params', function() {
let sandbox, utilsMock, newBidRequests, newBidResponses;
beforeEach(() => {
utilsMock = sinon.mock(utils);
sandbox = sinon.sandbox.create();
sandbox.spy(utils, 'logInfo');
newBidRequests = utils.deepClone(bidRequests)
newBidRequests[0].bidder = 'groupm';
newBidResponses = utils.deepClone(bidResponses);
newBidResponses.body.seatbid[0].bid[0].ext.marketplace = 'groupm'
});

afterEach(() => {
utilsMock.restore();
sandbox.restore();
})

it('Should log info when bidder is groupm and return', function () {
let request = spec.buildRequests(newBidRequests, {bidderCode: 'groupm',
auctionId: 'new-auction-id'
});
sinon.assert.calledOnce(utils.logInfo);
expect(request).to.equal(undefined);
});

it('Should add bidder code & bidder as groupm for marketplace groupm response', function () {
let request = spec.buildRequests(newBidRequests, {
auctionId: 'new-auction-id'
});
let response = spec.interpretResponse(newBidResponses, request);
expect(response).to.be.an('array').with.length.above(0);
expect(response[0].bidderCode).to.equal('groupm');
expect(response[0].bidder).to.equal('groupm');
});
});
});