diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index f60e89467990..09d631b3d184 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -20,19 +20,37 @@ export const spec = { */ isBidRequestValid: function(bid) { // check for all required bid fields - let isValid = !!( - bid && - bid.bidId && - bid.params && - bid.params.ip && - bid.params.user && - bid.params.user.buyeruid && - bid.params.definerId - ); - if (!isValid) { - utils.logWarn('Invalid bid request'); + if (!(bid && + bid.bidId && + bid.params)) { + utils.logWarn('Invalid bid request - missing required bid data'); + return false; } - return isValid; + + if (!(bid.params.user && + bid.params.user.buyeruid)) { + utils.logWarn('Invalid bid request - missing required user data'); + return false; + } + + if (!(bid.params.device && + bid.params.device.ip)) { + utils.logWarn('Invalid bid request - missing required device data'); + return false; + } + + if (!(bid.params.device.geo && + bid.params.device.geo.country)) { + utils.logWarn('Invalid bid request - missing required geo data'); + return false; + } + + if (!bid.params.definerId) { + utils.logWarn('Invalid bid request - missing required definer data'); + return false; + } + + return true; }, /** @@ -51,27 +69,23 @@ export const spec = { secure: secure, banner: buildBanner(request) }; - let isMobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0; let payload = { id: bidderRequest.auctionId, cur: [DEFAULT_CUR], imp: [impData], - site: { - mobile: isMobile, - page: bidderRequest.refererInfo.referer - }, - device: { - ua: navigator.userAgent, - ip: params.ip - }, - user: { - buyeruid: params.user.buyeruid, - uid: params.user.uid - }, + site: params.site ? params.site : {}, + device: params.device ? params.device : {}, + user: params.user ? params.user : {}, + app: params.app ? params.app : {}, ext: { definerId: params.definerId } }; + + payload.device.ua = navigator.userAgent; + payload.site.page = bidderRequest.refererInfo.referer; + payload.site.mobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0; + if (params.test) { payload.test = params.test; } diff --git a/modules/zetaBidAdapter.md b/modules/zetaBidAdapter.md index ce19b831d4d3..d99846c78227 100644 --- a/modules/zetaBidAdapter.md +++ b/modules/zetaBidAdapter.md @@ -29,7 +29,12 @@ Module that connects to Zeta's demand sources uid: 12345, buyeruid: 12345 }, - ip: '111.222.33.44', + device: { + ip: '111.222.33.44', + geo: { + country: "USA" + } + }, definerId: 1, test: 1 } diff --git a/test/spec/modules/zetaBidAdapter_spec.js b/test/spec/modules/zetaBidAdapter_spec.js index 0d11614c9264..b3380ab35db6 100644 --- a/test/spec/modules/zetaBidAdapter_spec.js +++ b/test/spec/modules/zetaBidAdapter_spec.js @@ -18,7 +18,12 @@ describe('Zeta Bid Adapter', function() { uid: 12345, buyeruid: 12345 }, - ip: '111.222.33.44', + device: { + ip: '111.222.33.44', + geo: { + country: 'USA' + } + }, definerId: 1, test: 1 }