diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index f93ed814a0a..10b1a872fed 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -88,8 +88,7 @@ function hasBannerMediaType(bid) { function hasMandatoryDisplayParams(bid) { const p = bid.params; return ( - !!p.publisherId && - !!p.adUnitId + !!p.publisherId ); } @@ -98,7 +97,6 @@ function hasMandatoryVideoParams(bid) { const isValid = !!bid.params.publisherId && - !!bid.params.adUnitId && hasVideoMediaType(bid) && !!videoParams.playerSize && isArray(videoParams.playerSize) && @@ -249,13 +247,14 @@ export function getTimeoutUrl(data) { const params = data[0].params[0]; const timeout = data[0].timeout; - queryParams = - '?publisherToken=' + - params.publisherId + - '&adUnitId=' + - params.adUnitId + - '&timeout=' + - timeout; + const qsParams = [ + 'publisherToken=' + params.publisherId, + 'timeout=' + timeout + ]; + if (params.adUnitId) { + qsParams.push('adUnitId=' + params.adUnitId); + } + queryParams = '?' + qsParams.join('&'); } return SEEDTAG_SSP_ONTIMEOUT_ENDPOINT + queryParams; } @@ -295,9 +294,12 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests(validBidRequests, bidderRequest) { + const publisherId = validBidRequests[0].params.publisherId; + const integrationType = validBidRequests[0].params.integrationType || 'publisherToken'; + const payload = { url: bidderRequest.refererInfo.page, - publisherToken: validBidRequests[0].params.publisherId, + publisherToken: publisherId, cmp: !!bidderRequest.gdprConsent, timeout: bidderRequest.timeout, version: '$prebid.version$', @@ -306,7 +308,8 @@ export const spec = { ttfb: ttfb(), bidRequests: _map(validBidRequests, buildBidRequest), user: { topics: [], eids: [] }, - site: {} + site: {}, + integrationType: integrationType }; if (payload.cmp) { @@ -371,6 +374,10 @@ export const spec = { payload.site.pagecat = bidderRequest.ortb2.site.pagecat } + if (bidderRequest.ortb2) { + payload.ortb = bidderRequest.ortb2; + } + const payloadString = JSON.stringify(payload); return { diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 3a448c90d78..65fc9d1a532 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -171,13 +171,13 @@ describe('Seedtag Adapter', function () { ); expect(isBidRequestValid).to.equal(false); }); - it('does not have the AdUnitId.', function () { + it('should be valid with only publisherId and no adUnitId', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, }) ); - expect(isBidRequestValid).to.equal(false); + expect(isBidRequestValid).to.equal(true); }); }); @@ -711,6 +711,47 @@ describe('Seedtag Adapter', function () { expect(data.sua).to.be.undefined; }); }); + + describe('integrationType param', function () { + it('should default to publisherToken when integrationType is not provided', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.integrationType).to.equal('publisherToken'); + }); + + it('should use the provided integrationType value', function () { + const bidRequests = JSON.parse(JSON.stringify(validBidRequests)); + bidRequests[0].params.integrationType = 'ronId'; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.integrationType).to.equal('ronId'); + }); + }); + + describe('ortb param', function () { + it('should add ortb param to payload when bidderRequest has ortb2', function () { + const ortb2 = { + site: { cat: ['IAB1'] }, + user: { data: [{ name: 'test' }] }, + bcat: ['IAB3'], + }; + bidderRequest['ortb2'] = ortb2; + + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.ortb).to.exist; + expect(data.ortb).to.deep.equal(ortb2); + }); + + it('should not add ortb param to payload when bidderRequest does not have ortb2', function () { + bidderRequest['ortb2'] = undefined; + + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.ortb).to.be.undefined; + }); + }); }) describe('interpret response method', function () { it('should return a void array, when the server response are not correct.', function () { @@ -895,7 +936,7 @@ describe('Seedtag Adapter', function () { utils.triggerPixel.restore(); }); - it('should return the correct endpoint', function () { + it('should return the correct endpoint with adUnitId', function () { const params = { publisherId: '0000', adUnitId: '11111' }; const timeout = 3000; const timeoutData = [{ params: [params], timeout }]; @@ -903,8 +944,21 @@ describe('Seedtag Adapter', function () { expect(timeoutUrl).to.equal( 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + params.publisherId + + '&timeout=' + + timeout + '&adUnitId=' + - params.adUnitId + + params.adUnitId + ); + }); + + it('should return the correct endpoint without adUnitId', function () { + const params = { publisherId: '0000' }; + const timeout = 3000; + const timeoutData = [{ params: [params], timeout }]; + const timeoutUrl = getTimeoutUrl(timeoutData); + expect(timeoutUrl).to.equal( + 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + + params.publisherId + '&timeout=' + timeout ); @@ -919,10 +973,10 @@ describe('Seedtag Adapter', function () { utils.triggerPixel.calledWith( 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + params.publisherId + - '&adUnitId=' + - params.adUnitId + '&timeout=' + - timeout + timeout + + '&adUnitId=' + + params.adUnitId ) ).to.equal(true); });