Skip to content

Commit

Permalink
Seedtag : add requestCount to bid request (#6958)
Browse files Browse the repository at this point in the history
* add requestCount per adunit to the bidRequest

* use internal bidderRequestsCount

* fix unit test
  • Loading branch information
ybootin authored Jun 7, 2021
1 parent d1ec22e commit fb72300
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
52 changes: 25 additions & 27 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,34 @@ function hasMandatoryVideoParams(bid) {
videoParams.playerSize.length > 0;
}

function buildBidRequests(validBidRequests) {
return utils._map(validBidRequests, function(validBidRequest) {
const params = validBidRequest.params;
const mediaTypes = utils._map(
Object.keys(validBidRequest.mediaTypes),
function(pbjsType) {
return mediaTypesMap[pbjsType];
}
);
function buildBidRequest(validBidRequest) {
const params = validBidRequest.params;
const mediaTypes = utils._map(
Object.keys(validBidRequest.mediaTypes),
function (pbjsType) {
return mediaTypesMap[pbjsType];
}
);

const bidRequest = {
id: validBidRequest.bidId,
transactionId: validBidRequest.transactionId,
sizes: validBidRequest.sizes,
supplyTypes: mediaTypes,
adUnitId: params.adUnitId,
placement: params.placement,
};
const bidRequest = {
id: validBidRequest.bidId,
transactionId: validBidRequest.transactionId,
sizes: validBidRequest.sizes,
supplyTypes: mediaTypes,
adUnitId: params.adUnitId,
placement: params.placement,
requestCount: validBidRequest.bidderRequestsCount || 1 // FIXME : in unit test the parameter bidderRequestsCount is undefined
};

if (params.adPosition) {
bidRequest.adPosition = params.adPosition;
}
if (params.adPosition) {
bidRequest.adPosition = params.adPosition;
}

if (hasVideoMediaType(validBidRequest)) {
bidRequest.videoParams = getVideoParams(validBidRequest)
}
if (hasVideoMediaType(validBidRequest)) {
bidRequest.videoParams = getVideoParams(validBidRequest)
}

return bidRequest;
})
return bidRequest;
}

/**
Expand Down Expand Up @@ -160,7 +159,6 @@ export const spec = {
code: BIDDER_CODE,
aliases: [SEEDTAG_ALIAS],
supportedMediaTypes: [BANNER, VIDEO],

/**
* Determines whether or not the given bid request is valid.
*
Expand All @@ -187,7 +185,7 @@ export const spec = {
timeout: bidderRequest.timeout,
version: '$prebid.version$',
connectionType: getConnectionType(),
bidRequests: buildBidRequests(validBidRequests)
bidRequests: utils._map(validBidRequests, buildBidRequest)
};

if (payload.cmp) {
Expand Down
2 changes: 2 additions & 0 deletions test/spec/modules/seedtagBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ describe('Seedtag Adapter', function() {
expect(bannerBid.sizes[0][1]).to.equal(250)
expect(bannerBid.sizes[1][0]).to.equal(300)
expect(bannerBid.sizes[1][1]).to.equal(600)
expect(bannerBid.requestCount).to.equal(1)
})
it('should request an InStream Video', function() {
const videoBid = bidRequests[1]
Expand All @@ -307,6 +308,7 @@ describe('Seedtag Adapter', function() {
expect(videoBid.sizes[0][1]).to.equal(250)
expect(videoBid.sizes[1][0]).to.equal(300)
expect(videoBid.sizes[1][1]).to.equal(600)
expect(videoBid.requestCount).to.equal(1)
})
})
})
Expand Down

0 comments on commit fb72300

Please sign in to comment.