diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index 1228fbafaad4..1cf5a0f8be7c 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -181,6 +181,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint'); const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey'); const BIDFLOOR = utils.deepAccess(validBidRequests, 'params.bidfloor'); + const BIDEXTRA = utils.deepAccess(validBidRequests, 'params.ext'); const bannerMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.banner'); const videoMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.video'); const { refererInfo } = bidderRequest; @@ -266,6 +267,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { bidder.tappxkey = TAPPXKEY; bidder.endpoint = ENDPOINT; bidder.host = hostInfo.url; + bidder.ext = (typeof BIDEXTRA == 'object') ? BIDEXTRA : undefined; imp.ext = {}; imp.ext.bidder = bidder; @@ -336,7 +338,9 @@ function buildOneRequest(validBidRequests, bidderRequest) { payload.params = params; payload.regs = regs; // < Payload - + utils.logMessage('---------------------'); + utils.logMessage(JSON.stringify(payload)); + utils.logMessage('---------------------'); return { method: 'POST', url: `https://${HOST}/${ENDPOINT}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, diff --git a/modules/tappxBidAdapter.md b/modules/tappxBidAdapter.md index e6581a67d063..a07bb2d88d14 100644 --- a/modules/tappxBidAdapter.md +++ b/modules/tappxBidAdapter.md @@ -67,4 +67,4 @@ Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90] }] } ]; -``` \ No newline at end of file +``` diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 378b391a4eb8..8197c4f44dd9 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -215,6 +215,31 @@ describe('Tappx bid adapter', function () { expect(data.imp[0].banner.w).to.be.oneOf([320, 50, 250, 480]); expect(data.imp[0].banner.h).to.be.oneOf([320, 50, 250, 480]); }); + + it('should properly build a ext optional object', function() { + let extBidRequest = c_VALIDBIDREQUESTS; + extBidRequest[0].params.ext = {'optionalData': '1234'}; + let extBidderRequest = c_BIDDERREQUEST_B; + extBidderRequest.bids[0].ext = {'optionalData': '1234'}; + + const request = spec.buildRequests(extBidRequest, extBidderRequest); + const data = JSON.parse(request[0].data); + expect(data.imp[0].ext.bidder.ext).to.be.an('object'); + expect(data.imp[0].ext.bidder.ext.optionalData).to.be.equal('1234'); + }); + + it('should ignore ext optional if is not a object', function() { + let badExtBidRequest = c_VALIDBIDREQUESTS; + badExtBidRequest[0].params.ext = 'stringValue'; + let badExtBidderRequest = c_BIDDERREQUEST_B; + badExtBidderRequest.bids[0].ext = 'stringValue'; + + const request = spec.buildRequests(badExtBidRequest, badExtBidderRequest); + const data = JSON.parse(request[0].data); + expect(data.imp[0].ext.bidder.ext).not.to.be.an('string'); + expect(data.imp[0].ext.bidder.ext).to.be.an('undefined'); + expect(data.imp[0].ext.bidder).to.not.have.property('ext') + }); }); /**