Skip to content

Commit

Permalink
update minuteMediaBidAdapter - support missing params (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
YakirLavi authored Jul 10, 2023
1 parent cab1f79 commit b8b69f8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
19 changes: 17 additions & 2 deletions modules/minutemediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ function generateBidParameters(bid, bidderRequest) {
bidObject.placementId = placementId;
}

const mimes = deepAccess(bid, `mediaTypes.${mediaType}.mimes`);
if (mimes) {
bidObject.mimes = mimes;
}
const api = deepAccess(bid, `mediaTypes.${mediaType}.api`);
if (api) {
bidObject.api = api;
}

const sua = deepAccess(bid, `ortb2.device.sua`);
if (sua) {
bidObject.sua = sua;
Expand Down Expand Up @@ -358,6 +367,11 @@ function generateBidParameters(bid, bidderRequest) {
bidObject.linearity = linearity;
}

const protocols = deepAccess(bid, `mediaTypes.video.protocols`);
if (protocols) {
bidObject.protocols = protocols;
}

const plcmt = deepAccess(bid, `mediaTypes.video.plcmt`);
if (plcmt) {
bidObject.plcmt = plcmt;
Expand Down Expand Up @@ -398,7 +412,8 @@ function generateGeneralParams(generalObject, bidderRequest) {
dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0,
device_type: getDeviceType(navigator.userAgent),
ua: navigator.userAgent,
session_id: getBidIdParameter('bidderRequestId', generalObject),
is_wrapper: !!generalBidParams.isWrapper,
session_id: generalBidParams.sessionId || getBidIdParameter('bidderRequestId', generalObject),
tmax: timeout
}

Expand Down Expand Up @@ -441,7 +456,7 @@ function generateGeneralParams(generalObject, bidderRequest) {

if (bidderRequest && bidderRequest.refererInfo) {
generalParams.referrer = deepAccess(bidderRequest, 'refererInfo.ref');
generalParams.page_url = deepAccess(bidderRequest, 'refererInfo.page') || window.location.href
generalParams.page_url = deepAccess(bidderRequest, 'refererInfo.page') || deepAccess(window, 'location.href');
}

return generalParams
Expand Down
41 changes: 36 additions & 5 deletions test/spec/modules/minutemediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,32 @@ describe('minutemediaAdapter', function () {
bidderCode: 'minutemedia',
}
const placementId = '12345678';
const api = [1, 2];
const mimes = ['application/javascript', 'video/mp4', 'video/quicktime'];
const protocols = [2, 3, 5, 6];

it('sends the placementId to ENDPOINT via POST', function () {
bidRequests[0].params.placementId = placementId;
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bids[0].placementId).to.equal(placementId);
});

it('sends bid request to ENDPOINT via POST', function () {
it('sends the plcmt to ENDPOINT via POST', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.url).to.equal(ENDPOINT);
expect(request.method).to.equal('POST');
expect(request.data.bids[0].plcmt).to.equal(1);
});

it('sends the plcmt to ENDPOINT via POST', function () {
it('sends the is_wrapper parameter to ENDPOINT via POST', function() {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bids[0].plcmt).to.equal(1);
expect(request.data.params).to.be.an('object');
expect(request.data.params).to.have.property('is_wrapper');
expect(request.data.params.is_wrapper).to.equal(false);
});

it('sends bid request to ENDPOINT via POST', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.url).to.equal(ENDPOINT);
expect(request.method).to.equal('POST');
});

it('sends bid request to TEST ENDPOINT via POST', function () {
Expand All @@ -133,6 +143,27 @@ describe('minutemediaAdapter', function () {
expect(request.data.bids[0].bidId).to.equal('299ffc8cca0b87');
});

it('should send the correct supported api array', function () {
bidRequests[0].mediaTypes.video.api = api;
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bids[0].api).to.be.an('array');
expect(request.data.bids[0].api).to.eql([1, 2]);
});

it('should send the correct mimes array', function () {
bidRequests[1].mediaTypes.banner.mimes = mimes;
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bids[1].mimes).to.be.an('array');
expect(request.data.bids[1].mimes).to.eql(['application/javascript', 'video/mp4', 'video/quicktime']);
});

it('should send the correct protocols array', function () {
bidRequests[0].mediaTypes.video.protocols = protocols;
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bids[0].protocols).to.be.an('array');
expect(request.data.bids[0].protocols).to.eql([2, 3, 5, 6]);
});

it('should send the correct sizes array', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bids[0].sizes).to.be.an('array');
Expand Down

0 comments on commit b8b69f8

Please sign in to comment.