From e4f79af53bad55a8f448a2145d2288e0754c5939 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 29 Aug 2019 14:27:07 +0530 Subject: [PATCH 01/28] lemmaBidAdapter.js Added lemma bid adapter file --- modules/lemmaBidAdapter.js | 406 +++++++++++++++++++++++++++++++++++++ 1 file changed, 406 insertions(+) create mode 100644 modules/lemmaBidAdapter.js diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js new file mode 100644 index 00000000000..b64dc040344 --- /dev/null +++ b/modules/lemmaBidAdapter.js @@ -0,0 +1,406 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; + +var BIDDER_CODE = 'lemma'; +var LOG_WARN_PREFIX = 'LEMMA: '; +var ENDPOINT = '//ads.lemmatechnologies.com/lemma/servad'; +var DEFAULT_CURRENCY = 'USD'; +var AUCTION_TYPE = 2; +var DEFAULT_TMAX = 300; +var DEFAULT_NET_REVENUE = false; + +export var spec = { + + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + + isBidRequestValid: bid => { + if (bid && bid.params) { + if (utils.isStr(bid.params.pubId) || !bid.params.pubId) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be string. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); + return false; + } + if (!bid.params.adunitId) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: adUnitId is mandatory. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); + return false; + } + // video ad validation + if (bid.params.hasOwnProperty('video')) { + if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, mimes is mandatory and must specify atlease 1 mime value. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid)); + return false; + } + } + return true; + } + return false; + }, + buildRequests: (bidRequests, bidderRequest) => { + var refererInfo; + if (bidderRequest && bidderRequest.refererInfo) { + refererInfo = bidderRequest.refererInfo; + } + var conf = _initConf(refererInfo); + const request = oRTBTemplate(bidRequests, conf); + if (request.imp.length == 0) { + return; + } + setOtherParams(bidderRequest, request); + const endPoint = endPointURL(bidRequests); + return { + method: 'POST', + url: endPoint, + data: JSON.stringify(request), + }; + }, + interpretResponse: (response, request) => { + return parseRTBResponse(request, response.body); + }, +}; + +function _initConf(refererInfo) { + var conf = {}; + conf.pageURL = utils.getTopWindowUrl(); + if (refererInfo && refererInfo.referer) { + conf.refURL = refererInfo.referer; + } else { + conf.refURL = ''; + } + return conf; +} + +function parseRTBResponse(request, response) { + var bidResponses = []; + try { + if (cfn(response.seatbid).length > 0) { + var currency = cfn(response.curr) || DEFAULT_CURRENCY; + var seatbid = cfn(response.seatbid); + seatbid.forEach(seatbidder => { + var bidder = cfn(seatbidder.bid); + bidder.forEach(bid => { + var req = parse(request.data); + var newBid = { + requestId: bid.impid, + cpm: parseFloat(bid.price).toFixed(2), + width: bid.w, + height: bid.h, + creativeId: bid.crid, + currency: currency, + netRevenue: DEFAULT_NET_REVENUE, + ttl: 300, + referrer: req.site.ref, + ad: bid.adm + }; + if (bid.dealid) { + newBid.dealId = bid.dealid; + } + if (req.imp && req.imp.length > 0) { + newBid.mediaType = req.mediaType; + req.imp.forEach(robj => { + if (bid.impid === robj.id) { + switch (newBid.mediaType) { + case BANNER: + break; + case VIDEO: + newBid.width = bid.hasOwnProperty('w') ? bid.w : robj.video.w; + newBid.height = bid.hasOwnProperty('h') ? bid.h : robj.video.h; + newBid.vastXml = bid.adm; + break; + } + } + }); + } + bidResponses.push(newBid); + }); + }); + } + } catch (error) { + utils.logError(LOG_WARN_PREFIX, 'ERROR ', error); + } + return bidResponses; +} + +function oRTBTemplate(bidRequests, conf) { + try { + var oRTBObject = { + id: '' + new Date().getTime(), + at: AUCTION_TYPE, + tmax: DEFAULT_TMAX, + cur: [DEFAULT_CURRENCY], + imp: _getImpressionArray(bidRequests), + user: {}, + ext: {} + }; + var bid = bidRequests[0]; + var app = _getAppObject(bid); + var site = _getSiteObject(bid, conf); + var device = _getDeviceObject(bid); + if (cfn(app) != '') { + oRTBObject.app = app; + } + if (cfn(site) != '') { + oRTBObject.site = site; + } + if (cfn(device) != '') { + oRTBObject.device = device; + } + return oRTBObject; + } catch (ex) { + utils.logError(LOG_WARN_PREFIX, 'ERROR ', ex); + } +} + +function _getImpressionArray(request) { + var impArray = []; + var map = request.map(bid => _getImpressionObject(bid)); + if (cfn(map).length > 0) { + map.forEach(o => { + if (cfn(o) != '') { + impArray.push(o); + } + }); + } + return impArray; +} + +function endPointURL(request) { + var params = request && request[0].params ? request[0].params : null; + if (cfn(params) != '') { + var pubId = cfn(params.pubId) != '' ? params.pubId : 0; + var adunitId = cfn(params.adunitId) != '' ? params.adunitId : 0; + return ENDPOINT + '?pid=' + pubId + '&aid=' + adunitId; + } + return null; +} + +function _getDomain(url) { + var a = document.createElement('a'); + a.setAttribute('href', url); + return a.hostname; +} + +function _getSiteObject(request, conf) { + var params = request && request.params ? request.params : null; + if (cfn(params) != '') { + var pubId = cfn(params.pubId) != '' ? params.pubId : '0'; + var siteId = cfn(params.siteId) != '' ? params.siteId : '0'; + var appParams = cfn(params.app); + if (!appParams) { + return { + publisher: { + id: pubId.toString() + }, + domain: _getDomain(conf.pageURL), + id: siteId.toString(), + ref: conf.refURL, + page: conf.pageURL + }; + } + } + return null; +} + +function _getAppObject(request) { + var params = request && request.params ? request.params : null; + if (cfn(params) != '') { + var pubId = cfn(params.pubId) != '' ? cfn(params.pubId) : '0'; + var appParams = cfn(params.app); + if (cfn(appParams)) { + return { + publisher: { + id: pubId.toString(), + }, + id: appParams.id, + name: appParams.name, + bundle: appParams.bundle, + storeurl: appParams.storeUrl, + domain: appParams.domain, + cat: appParams.categories, + pagecat: appParams.page_category + }; + } + } + return null; +} + +function _getDeviceObject(request) { + var params = request && request.params ? request.params : null; + if (cfn(params) != null) { + return { + dnt: utils.getDNT() ? 1 : 0, + ua: navigator.userAgent, + language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), + w: (window.screen.width || window.innerWidth), + h: (window.screen.height || window.innerHeigh), + geo: { + country: params.country, + lat: params.latitude, + lon: params.longitude, + region: params.region, + city: params.city, + zip: params.zip + }, + ip: params.ip, + devicetype: params.device_type, + ifa: params.ifa, + }; + } + return null; +} + +function setOtherParams(request, ortbRequest) { + var params = request && request.params ? request.params : null; + if (request && request.gdprConsent) { + ortbRequest.regs = { ext: { gdpr: request.gdprConsent.gdprApplies ? 1 : 0 } }; + ortbRequest.user = { ext: { consent: request.gdprConsent.consentString } }; + } + if (cfn(params) != '') { + ortbRequest.tmax = params.tmax; + ortbRequest.bcat = params.bcat; + } +} + +function _getSizes(request) { + var size = cfn(cfn(request).sizes)[0]; + if (utils.isArray(size) && cfn(size).length > 0) { + return size; + } + return null; +} + +function _getBannerRequest(bid) { + var bObj; + var adFormat = []; + if (cfn(bid.mediaType) === 'banner' || utils.deepAccess(bid, 'mediaTypes.banner')) { + var params = cfn(bid) != '' ? bid.params : null; + var bannerData = cfn(params.banner); + var sizes = _getSizes(bid); + if (cfn(sizes).length == 0) { + sizes = cfn(bid.mediaTypes.banner.sizes[0]); + } + if (cfn(sizes).length > 0) { + bObj = {}; + bObj.w = cfn(sizes[0]); + bObj.h = cfn(sizes[1]); + bObj.pos = 0; + if (cfn(bannerData) != '') { + bObj = utils.deepClone(bannerData); + } + sizes = cfn(bid.mediaTypes.banner.sizes); + if (cfn(sizes).length > 0) { + adFormat = []; + sizes.forEach(function(size) { + if (size.length > 1) { + adFormat.push({ w: size[0], h: size[1] }); + } + }); + if (adFormat.length > 0) { + bObj.format = adFormat; + } + } + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.banner.sizes missing for adunit: ' + bid.params.adunitId); + } + } + return bObj; +} + +function _getVideoRequest(bid) { + var vObj; + if (cfn(bid.mediaType) === 'video' || utils.deepAccess(bid, 'mediaTypes.video')) { + var params = cfn(bid) != '' ? bid.params : null; + var sizes = _getSizes(bid); + if (cfn(sizes).length == 0) { + sizes = cfn(bid.mediaTypes.video.playerSize); + } + if (cfn(sizes).length > 0) { + var videoData = cfn(params.video); + vObj = {}; + if (cfn(videoData) !== '') { + vObj = utils.deepClone(videoData); + } + vObj.w = cfn(sizes[0]); + vObj.h = cfn(sizes[1]); + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.video.sizes missing for adunit: ' + bid.params.adunitId); + } + } + return vObj; +} + +function _getImpressionObject(bid) { + var impression = {}; + var bObj; + var vObj; + var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : []; + var mediaTypes = ''; + var format = []; + var params = cfn(bid.params) != '' ? bid.params : null; + impression = { + id: cfn(bid.bidId), + tagid: cfn(params.adunitId).toString() != '' ? cfn(params.adunitId).toString() : undefined, + secure: window.location.protocol === 'https:' ? 1 : 0, + bidfloorcur: cfn(params.currency) != '' ? params.currency : DEFAULT_CURRENCY + }; + + if (cfn(params.bidFloor) != '') { + impression.bidfloor = cfn(params.bidFloor); + } + + if (bid.hasOwnProperty('mediaTypes')) { + for (mediaTypes in bid.mediaTypes) { + switch (mediaTypes) { + case BANNER: + bObj = _getBannerRequest(bid); + if (cfn(bObj) !== '') { + impression.banner = bObj; + } + break; + case VIDEO: + vObj = _getVideoRequest(bid); + if (cfn(vObj) !== '') { + impression.video = vObj; + } + break; + } + } + } else { + bObj = { + pos: 0, + w: sizes && sizes[0] ? sizes[0][0] : 0, + h: sizes && sizes[0] ? sizes[0][1] : 0, + }; + if (utils.isArray(sizes) && sizes.length > 1) { + sizes = sizes.splice(1, sizes.length - 1); + sizes.forEach(size => { + format.push({ + w: size[0], + h: size[1] + }); + }); + bObj.format = format; + } + impression.banner = bObj; + } + + return impression.hasOwnProperty(BANNER) || + impression.hasOwnProperty(VIDEO) ? impression : undefined; +} + +function parse(rawResp) { + try { + if (rawResp) { + return JSON.parse(rawResp); + } + } catch (ex) { + utils.logError(LOG_WARN_PREFIX, 'ERROR', ex); + } + return null; +} + +function cfn(el) { + return void 0 === el || el === null ? '' : el; +} + +registerBidder(spec); From c2e3f7f6c1a60899606f2f1ba3dbed0ccca55a17 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 29 Aug 2019 14:28:26 +0530 Subject: [PATCH 02/28] lemmaBidAdapter.md Added lemma bid adapter md file --- modules/lemmaBidAdapter.md | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 modules/lemmaBidAdapter.md diff --git a/modules/lemmaBidAdapter.md b/modules/lemmaBidAdapter.md new file mode 100644 index 00000000000..1b6c54a9e4d --- /dev/null +++ b/modules/lemmaBidAdapter.md @@ -0,0 +1,67 @@ +# Overview + +``` +Module Name: Lemma Bid Adapter +Module Type: Bidder Adapter +Maintainer: lemmadev@lemmatechnologies.com +``` + +# Description + +Connects to Lemma exchange for bids. +Lemma bid adapter supports Video, Banner formats. + +# Sample Banner Ad Unit: For Publishers +``` +var adUnits = [{ + code: 'div-lemma-ad-1', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], // required + } + }, + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'lemma', + params: { + pubId: '1', // required + adunitId: '3768', // required + latitude: 37.3230, + longitude: -122.0322, + device_type: 2, + banner: { + w: 300, + h: 250 + } + } + }] +}]; +``` + +# Sample Video Ad Unit: For Publishers +``` +var adUnits = [{ + mediaType: 'video', + sizes: [[640, 480]], + mediaTypes: { + video: { + playerSize: [640, 480], // required + context: 'instream' + } + }, + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'lemma', + params: { + pubId: '1', // required + adunitId: '3769', // required + latitude: 37.3230, + longitude: -122.0322, + device_type: 4, + video: { + mimes: ['video/mp4','video/x-flv'], // required + } + } + }] +}]; +``` From 5bf217937b1e15bbd385523339b96ac87c83c000 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 29 Aug 2019 14:30:35 +0530 Subject: [PATCH 03/28] lemmaBidAdapter_spec.js Added lemma bid adapter test spec file --- test/spec/modules/lemmaBidAdapter_spec.js | 335 ++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 test/spec/modules/lemmaBidAdapter_spec.js diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js new file mode 100644 index 00000000000..624e763ebe1 --- /dev/null +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -0,0 +1,335 @@ +import { expect } from 'chai'; +import { spec } from 'modules/lemmaBidAdapter'; +import * as utils from 'src/utils'; +const constants = require('src/constants.json'); + +describe('lemmaBidAdapter', function() { + var bidRequests; + var videoBidRequests; + var bidResponses; + beforeEach(function() { + bidRequests = [{ + bidder: 'lemma', + mediaType: 'banner', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD', + geo: { + lat: '12.3', + lon: '23.7', + } + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + videoBidRequests = [{ + code: 'video1', + mediaType: 'video', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1, + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }]; + bidResponses = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '74858439-49D7-4169-BA5D-44A046315B2F', + 'impid': '22bddb28db77d', + 'price': 1.3, + 'adm': '

lemma"Connecting Advertisers and Publishers directly"

', + 'adomain': ['amazon.com'], + 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', + 'cid': '22918', + 'crid': 'v55jutrh', + 'h': 250, + 'w': 300, + 'ext': {} + }] + }] + } + }; + }); + describe('implementation', function() { + describe('Bid validations', function() { + it('valid bid case', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + it('invalid bid case', function() { + var isValid = spec.isBidRequestValid(); + expect(isValid).to.equal(false); + }); + it('invalid bid case: pubId not passed', function() { + var validBid = { + bidder: 'lemma', + params: { + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: pubId is not number', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: '301', + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: adunitId is not passed', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: 1001 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: video bid request mimes is not passed', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1, + video: { + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + validBid.params.video.mimes = []; + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + }); + describe('Request formation', function() { + it('buildRequests function should not modify original bidRequests object', function() { + var originalBidRequests = utils.deepClone(bidRequests); + var request = spec.buildRequests(bidRequests); + expect(bidRequests).to.deep.equal(originalBidRequests); + }); + it('Endpoint checking', function() { + var request = spec.buildRequests(bidRequests); + expect(request.url).to.equal('//ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); + expect(request.method).to.equal('POST'); + }); + it('Request params check', function() { + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id + expect(data.imp[0].tagid).to.equal('1'); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + }); + it('Request params check without mediaTypes object', function() { + var bidRequests = [{ + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(600); // height + }); + it('Request params check: without tagId', function() { + delete bidRequests[0].params.adunitId; + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id + expect(data.imp[0].tagid).to.equal(undefined); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + }); + it('Request params multi size format object check', function() { + var bidRequests = [{ + bidder: 'lemma', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + /* case 1 - size passed in adslot */ + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + /* case 2 - size passed in adslot as well as in sizes array */ + bidRequests[0].sizes = [ + [300, 600], + [300, 250] + ]; + bidRequests[0].mediaTypes = { + banner: { + sizes: [ + [300, 600], + [300, 250] + ] + } + }; + request = spec.buildRequests(bidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(600); // height + /* case 3 - size passed in sizes but not in adslot */ + bidRequests[0].params.adunitId = 1; + bidRequests[0].sizes = [ + [300, 250], + [300, 600] + ]; + bidRequests[0].mediaTypes = { + banner: { + sizes: [ + [300, 250], + [300, 600] + ] + } + }; + request = spec.buildRequests(bidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(250); // height + }); + it('Request params currency check', function() { + var bidRequest = [{ + bidder: 'lemma', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + /* case 1 - + currency specified in adunits + output: imp[0] use currency specified in bidRequests[0].params.currency + */ + var request = spec.buildRequests(bidRequest); + var data = JSON.parse(request.data); + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + /* case 2 - + currency specified in adunit + output: imp[0] use default currency - USD + */ + delete bidRequest[0].params.currency; + request = spec.buildRequests(bidRequest); + data = JSON.parse(request.data); + expect(data.imp[0].bidfloorcur).to.equal('USD'); + }); + it('Request params check for video ad', function() { + var request = spec.buildRequests(videoBidRequests); + var data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0].tagid).to.equal('1'); + expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); + expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); + expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); + expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + }); + describe('Response checking', function() { + it('should check for valid response values', function() { + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + var response = spec.interpretResponse(bidResponses, request); + expect(response).to.be.an('array').with.length.above(0); + expect(response[0].requestId).to.equal(bidResponses.body.seatbid[0].bid[0].impid); + expect(response[0].cpm).to.equal((bidResponses.body.seatbid[0].bid[0].price).toFixed(2)); + expect(response[0].width).to.equal(bidResponses.body.seatbid[0].bid[0].w); + expect(response[0].height).to.equal(bidResponses.body.seatbid[0].bid[0].h); + if (bidResponses.body.seatbid[0].bid[0].crid) { + expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].crid); + } else { + expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].id); + } + expect(response[0].dealId).to.equal(bidResponses.body.seatbid[0].bid[0].dealid); + expect(response[0].currency).to.equal('USD'); + expect(response[0].netRevenue).to.equal(false); + expect(response[0].ttl).to.equal(300); + }); + }); + }); + }); +}); From 691066690e3d0ccaea616a6e6691d08792695f0f Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 29 Aug 2019 15:08:26 +0530 Subject: [PATCH 04/28] Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types --- modules/lemmaBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index b64dc040344..cc84f14f4b1 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -226,7 +226,7 @@ function _getAppObject(request) { function _getDeviceObject(request) { var params = request && request.params ? request.params : null; - if (cfn(params) != null) { + if (cfn(params) != '') { return { dnt: utils.getDNT() ? 1 : 0, ua: navigator.userAgent, From cdea5c60fc5e99394ffe5a5da85e73460bdf2db1 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Mon, 16 Sep 2019 11:34:17 +0530 Subject: [PATCH 05/28] Update lemmaBidAdapter.js Fixed review changes --- modules/lemmaBidAdapter.js | 115 ++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 60 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index cc84f14f4b1..ed97b1db052 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -17,7 +17,7 @@ export var spec = { isBidRequestValid: bid => { if (bid && bid.params) { - if (utils.isStr(bid.params.pubId) || !bid.params.pubId) { + if (!utils.isNumber(bid.params.pubId)) { utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be string. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); return false; } @@ -73,11 +73,11 @@ function _initConf(refererInfo) { function parseRTBResponse(request, response) { var bidResponses = []; try { - if (cfn(response.seatbid).length > 0) { - var currency = cfn(response.curr) || DEFAULT_CURRENCY; - var seatbid = cfn(response.seatbid); + if (response.seatbid) { + var currency = response.curr || DEFAULT_CURRENCY; + var seatbid = response.seatbid; seatbid.forEach(seatbidder => { - var bidder = cfn(seatbidder.bid); + var bidder = seatbidder.bid; bidder.forEach(bid => { var req = parse(request.data); var newBid = { @@ -136,13 +136,13 @@ function oRTBTemplate(bidRequests, conf) { var app = _getAppObject(bid); var site = _getSiteObject(bid, conf); var device = _getDeviceObject(bid); - if (cfn(app) != '') { + if (app) { oRTBObject.app = app; } - if (cfn(site) != '') { + if (site) { oRTBObject.site = site; } - if (cfn(device) != '') { + if (device) { oRTBObject.device = device; } return oRTBObject; @@ -154,9 +154,9 @@ function oRTBTemplate(bidRequests, conf) { function _getImpressionArray(request) { var impArray = []; var map = request.map(bid => _getImpressionObject(bid)); - if (cfn(map).length > 0) { + if (map) { map.forEach(o => { - if (cfn(o) != '') { + if (o) { impArray.push(o); } }); @@ -166,9 +166,9 @@ function _getImpressionArray(request) { function endPointURL(request) { var params = request && request[0].params ? request[0].params : null; - if (cfn(params) != '') { - var pubId = cfn(params.pubId) != '' ? params.pubId : 0; - var adunitId = cfn(params.adunitId) != '' ? params.adunitId : 0; + if (params) { + var pubId = params.pubId ? params.pubId : 0; + var adunitId = params.adunitId ? params.adunitId : 0; return ENDPOINT + '?pid=' + pubId + '&aid=' + adunitId; } return null; @@ -182,10 +182,10 @@ function _getDomain(url) { function _getSiteObject(request, conf) { var params = request && request.params ? request.params : null; - if (cfn(params) != '') { - var pubId = cfn(params.pubId) != '' ? params.pubId : '0'; - var siteId = cfn(params.siteId) != '' ? params.siteId : '0'; - var appParams = cfn(params.app); + if (params) { + var pubId = params.pubId ? params.pubId : '0'; + var siteId = params.siteId ? params.siteId : '0'; + var appParams = params.app; if (!appParams) { return { publisher: { @@ -203,10 +203,10 @@ function _getSiteObject(request, conf) { function _getAppObject(request) { var params = request && request.params ? request.params : null; - if (cfn(params) != '') { - var pubId = cfn(params.pubId) != '' ? cfn(params.pubId) : '0'; - var appParams = cfn(params.app); - if (cfn(appParams)) { + if (params) { + var pubId = params.pubId ? params.pubId : 0; + var appParams = params.app; + if (appParams) { return { publisher: { id: pubId.toString(), @@ -226,7 +226,7 @@ function _getAppObject(request) { function _getDeviceObject(request) { var params = request && request.params ? request.params : null; - if (cfn(params) != '') { + if (params) { return { dnt: utils.getDNT() ? 1 : 0, ua: navigator.userAgent, @@ -255,16 +255,15 @@ function setOtherParams(request, ortbRequest) { ortbRequest.regs = { ext: { gdpr: request.gdprConsent.gdprApplies ? 1 : 0 } }; ortbRequest.user = { ext: { consent: request.gdprConsent.consentString } }; } - if (cfn(params) != '') { + if (params) { ortbRequest.tmax = params.tmax; ortbRequest.bcat = params.bcat; } } function _getSizes(request) { - var size = cfn(cfn(request).sizes)[0]; - if (utils.isArray(size) && cfn(size).length > 0) { - return size; + if (request.sizes && utils.isArray(request.sizes[0]) && request.sizes[0].length > 0) { + return request.sizes[0]; } return null; } @@ -272,23 +271,23 @@ function _getSizes(request) { function _getBannerRequest(bid) { var bObj; var adFormat = []; - if (cfn(bid.mediaType) === 'banner' || utils.deepAccess(bid, 'mediaTypes.banner')) { - var params = cfn(bid) != '' ? bid.params : null; - var bannerData = cfn(params.banner); - var sizes = _getSizes(bid); - if (cfn(sizes).length == 0) { - sizes = cfn(bid.mediaTypes.banner.sizes[0]); + if (bid.mediaType === 'banner' || utils.deepAccess(bid, 'mediaTypes.banner')) { + var params = bid ? bid.params : null; + var bannerData = params.banner; + var sizes = _getSizes(bid) || []; + if (sizes && sizes.length == 0) { + sizes = bid.mediaTypes.banner.sizes[0]; } - if (cfn(sizes).length > 0) { + if (sizes && sizes.length > 0) { bObj = {}; - bObj.w = cfn(sizes[0]); - bObj.h = cfn(sizes[1]); + bObj.w = sizes[0]; + bObj.h = sizes[1]; bObj.pos = 0; - if (cfn(bannerData) != '') { + if (bannerData) { bObj = utils.deepClone(bannerData); } - sizes = cfn(bid.mediaTypes.banner.sizes); - if (cfn(sizes).length > 0) { + sizes = bid.mediaTypes.banner.sizes; + if (sizes.length > 0) { adFormat = []; sizes.forEach(function(size) { if (size.length > 1) { @@ -308,20 +307,20 @@ function _getBannerRequest(bid) { function _getVideoRequest(bid) { var vObj; - if (cfn(bid.mediaType) === 'video' || utils.deepAccess(bid, 'mediaTypes.video')) { - var params = cfn(bid) != '' ? bid.params : null; - var sizes = _getSizes(bid); - if (cfn(sizes).length == 0) { - sizes = cfn(bid.mediaTypes.video.playerSize); + if (bid.mediaType === 'video' || utils.deepAccess(bid, 'mediaTypes.video')) { + var params = bid ? bid.params : null; + var sizes = _getSizes(bid) || []; + if (sizes && sizes.length == 0) { + sizes = bid.mediaTypes && bid.mediaTypes.video ? bid.mediaTypes.video.playerSize : []; } - if (cfn(sizes).length > 0) { - var videoData = cfn(params.video); + if (sizes && sizes.length > 0) { + var videoData = params.video; vObj = {}; - if (cfn(videoData) !== '') { + if (videoData) { vObj = utils.deepClone(videoData); } - vObj.w = cfn(sizes[0]); - vObj.h = cfn(sizes[1]); + vObj.w = sizes[0]; + vObj.h = sizes[1]; } else { utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.video.sizes missing for adunit: ' + bid.params.adunitId); } @@ -336,16 +335,16 @@ function _getImpressionObject(bid) { var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : []; var mediaTypes = ''; var format = []; - var params = cfn(bid.params) != '' ? bid.params : null; + var params = bid && bid.params ? bid.params : null; impression = { - id: cfn(bid.bidId), - tagid: cfn(params.adunitId).toString() != '' ? cfn(params.adunitId).toString() : undefined, + id: bid.bidId, + tagid: params.adunitId ? params.adunitId.toString() : undefined, secure: window.location.protocol === 'https:' ? 1 : 0, - bidfloorcur: cfn(params.currency) != '' ? params.currency : DEFAULT_CURRENCY + bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY }; - if (cfn(params.bidFloor) != '') { - impression.bidfloor = cfn(params.bidFloor); + if (params.bidFloor) { + impression.bidfloor = params.bidFloor; } if (bid.hasOwnProperty('mediaTypes')) { @@ -353,13 +352,13 @@ function _getImpressionObject(bid) { switch (mediaTypes) { case BANNER: bObj = _getBannerRequest(bid); - if (cfn(bObj) !== '') { + if (bObj) { impression.banner = bObj; } break; case VIDEO: vObj = _getVideoRequest(bid); - if (cfn(vObj) !== '') { + if (vObj) { impression.video = vObj; } break; @@ -399,8 +398,4 @@ function parse(rawResp) { return null; } -function cfn(el) { - return void 0 === el || el === null ? '' : el; -} - registerBidder(spec); From 8b0c2e68bfacb94f2ec2a20722a72afb604b0dea Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Mon, 16 Sep 2019 11:35:42 +0530 Subject: [PATCH 06/28] Update lemmaBidAdapter.md Correct parameter value. --- modules/lemmaBidAdapter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lemmaBidAdapter.md b/modules/lemmaBidAdapter.md index 1b6c54a9e4d..80c1a52b9d6 100644 --- a/modules/lemmaBidAdapter.md +++ b/modules/lemmaBidAdapter.md @@ -24,7 +24,7 @@ var adUnits = [{ bids: [{ bidder: 'lemma', params: { - pubId: '1', // required + pubId: 1, // required adunitId: '3768', // required latitude: 37.3230, longitude: -122.0322, @@ -53,7 +53,7 @@ var adUnits = [{ bids: [{ bidder: 'lemma', params: { - pubId: '1', // required + pubId: 1, // required adunitId: '3769', // required latitude: 37.3230, longitude: -122.0322, From 9f0d7874dae46742114121ffced828481746d703 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 6 Feb 2020 18:52:36 +0530 Subject: [PATCH 07/28] Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance --- modules/lemmaBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index ed97b1db052..b27cfdcb134 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -4,7 +4,7 @@ import { BANNER, VIDEO } from '../src/mediaTypes'; var BIDDER_CODE = 'lemma'; var LOG_WARN_PREFIX = 'LEMMA: '; -var ENDPOINT = '//ads.lemmatechnologies.com/lemma/servad'; +var ENDPOINT = 'https://ads.lemmatechnologies.com/lemma/servad'; var DEFAULT_CURRENCY = 'USD'; var AUCTION_TYPE = 2; var DEFAULT_TMAX = 300; @@ -61,7 +61,7 @@ export var spec = { function _initConf(refererInfo) { var conf = {}; - conf.pageURL = utils.getTopWindowUrl(); + conf.pageURL = (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href; if (refererInfo && refererInfo.referer) { conf.refURL = refererInfo.referer; } else { From 512db741a40deddc7981b5312441c38e80159058 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 6 Feb 2020 18:58:02 +0530 Subject: [PATCH 08/28] Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance --- test/spec/modules/lemmaBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index 624e763ebe1..3f359cc5e9e 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -151,7 +151,7 @@ describe('lemmaBidAdapter', function() { }); it('Endpoint checking', function() { var request = spec.buildRequests(bidRequests); - expect(request.url).to.equal('//ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); + expect(request.url).to.equal('https://ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); expect(request.method).to.equal('POST'); }); it('Request params check', function() { From dc454c28c60408b9f989b5b629353ed8e46bfbd5 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 6 Feb 2020 19:01:00 +0530 Subject: [PATCH 09/28] Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance --- modules/lemmaBidAdapter.md | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/lemmaBidAdapter.md b/modules/lemmaBidAdapter.md index 80c1a52b9d6..29e72e028b9 100644 --- a/modules/lemmaBidAdapter.md +++ b/modules/lemmaBidAdapter.md @@ -42,7 +42,6 @@ var adUnits = [{ ``` var adUnits = [{ mediaType: 'video', - sizes: [[640, 480]], mediaTypes: { video: { playerSize: [640, 480], // required From cd97952973a16ffc38d63e4c74e619f860fb604f Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 5 Nov 2020 14:43:39 +0530 Subject: [PATCH 10/28] Update lemmaBidAdapter.js Added user sync support into bid adapter. --- modules/lemmaBidAdapter.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index b27cfdcb134..0b45f1d24dd 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -5,10 +5,13 @@ import { BANNER, VIDEO } from '../src/mediaTypes'; var BIDDER_CODE = 'lemma'; var LOG_WARN_PREFIX = 'LEMMA: '; var ENDPOINT = 'https://ads.lemmatechnologies.com/lemma/servad'; +var USER_SYNC = "https://sync.lemmatechnologies.com/js/usersync.html?" var DEFAULT_CURRENCY = 'USD'; var AUCTION_TYPE = 2; var DEFAULT_TMAX = 300; var DEFAULT_NET_REVENUE = false; +var pubId = 0; +var adunitId = 0; export var spec = { @@ -57,6 +60,29 @@ export var spec = { interpretResponse: (response, request) => { return parseRTBResponse(request, response.body); }, + getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { + let syncurl = USER_SYNC + "pid=" + pubId; + + // Attaching GDPR Consent Params in UserSync url + if (gdprConsent) { + syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + } + + // CCPA + if (uspConsent) { + syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); + } + + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: syncurl + }]; + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Please enable iframe based user sync.'); + } + }, }; function _initConf(refererInfo) { @@ -167,8 +193,8 @@ function _getImpressionArray(request) { function endPointURL(request) { var params = request && request[0].params ? request[0].params : null; if (params) { - var pubId = params.pubId ? params.pubId : 0; - var adunitId = params.adunitId ? params.adunitId : 0; + pubId = params.pubId ? params.pubId : 0; + adunitId = params.adunitId ? params.adunitId : 0; return ENDPOINT + '?pid=' + pubId + '&aid=' + adunitId; } return null; @@ -183,7 +209,7 @@ function _getDomain(url) { function _getSiteObject(request, conf) { var params = request && request.params ? request.params : null; if (params) { - var pubId = params.pubId ? params.pubId : '0'; + pubId = params.pubId ? params.pubId : '0'; var siteId = params.siteId ? params.siteId : '0'; var appParams = params.app; if (!appParams) { @@ -204,7 +230,7 @@ function _getSiteObject(request, conf) { function _getAppObject(request) { var params = request && request.params ? request.params : null; if (params) { - var pubId = params.pubId ? params.pubId : 0; + pubId = params.pubId ? params.pubId : 0; var appParams = params.app; if (appParams) { return { From 9fddb97e8a276eaa28516ebca02fb065f009a41d Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Tue, 10 Nov 2020 10:27:47 +0530 Subject: [PATCH 11/28] updated include modules file extension. updated include modules js file extension. --- modules/lemmaBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index 81568cfef45..db64916f426 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils'; +import * as utils from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; From 9ef28f3092ff89a61171017439d354620b82ee07 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Tue, 10 Nov 2020 11:01:06 +0530 Subject: [PATCH 12/28] Update lemmaBidAdapter_spec.js Added unit test for user sync feature. --- test/spec/modules/lemmaBidAdapter_spec.js | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index a236ac17d71..0de307cbe3a 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -331,5 +331,39 @@ describe('lemmaBidAdapter', function() { }); }); }); + describe('getUserSyncs', function() { + const syncurl_iframe = 'https://sync.lemmatechnologies.com/js/usersync.html?pid=1001'; + let sandbox; + beforeEach(function() { + sandbox = sinon.sandbox.create(); + }); + afterEach(function() { + sandbox.restore(); + }); + + it('execute as per config', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: syncurl_iframe + }]); + }); + + it('CCPA/USP', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&us_privacy=1NYN` + }]); + }); + + it('GDPR', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: truev}, {}, { gdprApplies: false, consentString: 'foo' }, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=0&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: true, consentString: undefined }, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=` + }]); + }); + }); }); }); From 7802da85e7edab6f2d2babff0f981382bdecf0ff Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Wed, 11 Nov 2020 12:08:18 +0530 Subject: [PATCH 13/28] Update lemmaBidAdapter.js Fixed format error. --- modules/lemmaBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index db64916f426..5941802f97d 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -5,7 +5,7 @@ import { BANNER, VIDEO } from '../src/mediaTypes.js'; var BIDDER_CODE = 'lemma'; var LOG_WARN_PREFIX = 'LEMMA: '; var ENDPOINT = 'https://ads.lemmatechnologies.com/lemma/servad'; -var USER_SYNC = "https://sync.lemmatechnologies.com/js/usersync.html?" +var USER_SYNC = 'https://sync.lemmatechnologies.com/js/usersync.html?'; var DEFAULT_CURRENCY = 'USD'; var AUCTION_TYPE = 2; var DEFAULT_TMAX = 300; @@ -61,7 +61,7 @@ export var spec = { return parseRTBResponse(request, response.body); }, getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { - let syncurl = USER_SYNC + "pid=" + pubId; + let syncurl = USER_SYNC + 'pid=' + pubId; // Attaching GDPR Consent Params in UserSync url if (gdprConsent) { From 0a647998a49cd57e2cca579f360744f81cfae4c5 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Wed, 11 Nov 2020 12:11:12 +0530 Subject: [PATCH 14/28] Update lemmaBidAdapter_spec.js Fixed format error and typo error. --- test/spec/modules/lemmaBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index 0de307cbe3a..a00c25d126c 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -357,7 +357,7 @@ describe('lemmaBidAdapter', function() { expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, undefined)).to.deep.equal([{ type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=foo` }]); - expect(spec.getUserSyncs({ iframeEnabled: truev}, {}, { gdprApplies: false, consentString: 'foo' }, undefined)).to.deep.equal([{ + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: false, consentString: 'foo' }, undefined)).to.deep.equal([{ type: 'iframe', url: `${syncurl_iframe}&gdpr=0&gdpr_consent=foo` }]); expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: true, consentString: undefined }, undefined)).to.deep.equal([{ From 8ac2aedde20222dae12a4d2ebc092bd1f6e2555d Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Fri, 20 Nov 2020 14:01:00 +0530 Subject: [PATCH 15/28] Set mediaType key value into bid object Set mediaType key value into the bid object. --- modules/lemmaBidAdapter.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index 5941802f97d..76152a253da 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -122,9 +122,9 @@ function parseRTBResponse(request, response) { newBid.dealId = bid.dealid; } if (req.imp && req.imp.length > 0) { - newBid.mediaType = req.mediaType; req.imp.forEach(robj => { if (bid.impid === robj.id) { + _checkMediaType(bid.adm, newBid); switch (newBid.mediaType) { case BANNER: break; @@ -147,6 +147,17 @@ function parseRTBResponse(request, response) { return bidResponses; } +function checkMediaType(adm, newBid) { + // Create a regex here to check the strings + var admStr = ''; + var videoRegex = new RegExp(/VAST\s+version/); + if (adm.indexOf('span class="PubAPIAd"') >= 0) { + newBid.mediaType = VIDEO; + } else { + newBid.mediaType = BANNER; + } +} + function oRTBTemplate(bidRequests, conf) { try { var oRTBObject = { @@ -424,4 +435,13 @@ function parse(rawResp) { return null; } +function _checkMediaType(adm, newBid) { + // Create a regex here to check the strings + var videoRegex = new RegExp(/VAST.*version/); + if (videoRegex.test(adm)) { + newBid.mediaType = VIDEO; + } else { + newBid.mediaType = BANNER; + } +} registerBidder(spec); From 2074a6ff6fe88b2316bfd4c88aeb7c7e85b946bc Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Fri, 20 Nov 2020 14:34:17 +0530 Subject: [PATCH 16/28] Update lemmaBidAdapter.js remove duplicate function --- modules/lemmaBidAdapter.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index 76152a253da..2e1b0af323c 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -147,17 +147,6 @@ function parseRTBResponse(request, response) { return bidResponses; } -function checkMediaType(adm, newBid) { - // Create a regex here to check the strings - var admStr = ''; - var videoRegex = new RegExp(/VAST\s+version/); - if (adm.indexOf('span class="PubAPIAd"') >= 0) { - newBid.mediaType = VIDEO; - } else { - newBid.mediaType = BANNER; - } -} - function oRTBTemplate(bidRequests, conf) { try { var oRTBObject = { From 7b1f3ace273ae8da955bc12a2b7bce208f5d3e59 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Wed, 25 Nov 2020 16:18:09 +0530 Subject: [PATCH 17/28] Update lemmaBidAdapter.js Remove non supported code. --- modules/lemmaBidAdapter.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index 2e1b0af323c..f6915d6ee5e 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -62,18 +62,7 @@ export var spec = { }, getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { let syncurl = USER_SYNC + 'pid=' + pubId; - - // Attaching GDPR Consent Params in UserSync url - if (gdprConsent) { - syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); - syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); - } - - // CCPA - if (uspConsent) { - syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); - } - + if (syncOptions.iframeEnabled) { return [{ type: 'iframe', @@ -277,10 +266,6 @@ function _getDeviceObject(request) { function setOtherParams(request, ortbRequest) { var params = request && request.params ? request.params : null; - if (request && request.gdprConsent) { - ortbRequest.regs = { ext: { gdpr: request.gdprConsent.gdprApplies ? 1 : 0 } }; - ortbRequest.user = { ext: { consent: request.gdprConsent.consentString } }; - } if (params) { ortbRequest.tmax = params.tmax; ortbRequest.bcat = params.bcat; From 923da84d2d28388f893e38f897f9a7ab46dde6b8 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Tue, 1 Dec 2020 10:21:41 +0530 Subject: [PATCH 18/28] Update lemmaBidAdapter_spec.js Remove GDPR test cases. --- test/spec/modules/lemmaBidAdapter_spec.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index a00c25d126c..a22f5650e50 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -346,24 +346,6 @@ describe('lemmaBidAdapter', function() { type: 'iframe', url: syncurl_iframe }]); }); - - it('CCPA/USP', function() { - expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ - type: 'iframe', url: `${syncurl_iframe}&us_privacy=1NYN` - }]); - }); - - it('GDPR', function() { - expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, undefined)).to.deep.equal([{ - type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=foo` - }]); - expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: false, consentString: 'foo' }, undefined)).to.deep.equal([{ - type: 'iframe', url: `${syncurl_iframe}&gdpr=0&gdpr_consent=foo` - }]); - expect(spec.getUserSyncs({ iframeEnabled: true }, {}, { gdprApplies: true, consentString: undefined }, undefined)).to.deep.equal([{ - type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=` - }]); - }); }); }); }); From 7ee232d125043e04c5d7a70c672faf38d18ba7ba Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Tue, 30 Mar 2021 13:10:18 +0530 Subject: [PATCH 19/28] Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function --- modules/lemmaBidAdapter.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index 926761e5ab2..310cca3ba1c 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -84,6 +84,30 @@ function _initConf(refererInfo) { return conf; } +function _setFloor(impObj, bid) { + let bidFloor = -1; + // get lowest floor from floorModule + if (typeof bid.getFloor === 'function') { + [BANNER, VIDEO].forEach(mediaType => { + if (impObj.hasOwnProperty(mediaType)) { + let floorInfo = bid.getFloor({ currency: impObj.bidfloorcur, mediaType: mediaType, size: '*' }); + if (typeof floorInfo === 'object' && floorInfo.currency === impObj.bidfloorcur && !isNaN(parseInt(floorInfo.floor))) { + let mediaTypeFloor = parseFloat(floorInfo.floor); + bidFloor = (bidFloor == -1 ? mediaTypeFloor : Math.min(mediaTypeFloor, bidFloor)) + } + } + }); + } + // get highest from impObj.bidfllor and floor from floor module + // as we are using Math.max, it is ok if we have not got any floor from floorModule, then value of bidFloor will be -1 + if (impObj.bidfloor) { + bidFloor = Math.max(bidFloor, impObj.bidfloor) + } + + // assign value only if bidFloor is > 0 + impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : UNDEFINED); +} + function parseRTBResponse(request, response) { var bidResponses = []; try { @@ -352,11 +376,9 @@ function _getImpressionObject(bid) { secure: window.location.protocol === 'https:' ? 1 : 0, bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY }; - - if (params.bidFloor) { - impression.bidfloor = params.bidFloor; - } - + + _setFloor(impression, bid); + if (bid.hasOwnProperty('mediaTypes')) { for (mediaTypes in bid.mediaTypes) { switch (mediaTypes) { From 393f28d03112438ff5d47f07d1960481c1c2b3a8 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Wed, 31 Mar 2021 17:43:30 +0530 Subject: [PATCH 20/28] Update lemmaBidAdapter.js correct undefined keyword name. --- modules/lemmaBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index 310cca3ba1c..db476360a13 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -105,7 +105,7 @@ function _setFloor(impObj, bid) { } // assign value only if bidFloor is > 0 - impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : UNDEFINED); + impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : undefined); } function parseRTBResponse(request, response) { From d3d442606197f2ff5e1723abe1441fab699e5278 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Wed, 31 Mar 2021 17:48:21 +0530 Subject: [PATCH 21/28] Update lemmaBidAdapter_spec.js Added test coverage floor value --- test/spec/modules/lemmaBidAdapter_spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index a22f5650e50..370bd77f20b 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -161,6 +161,7 @@ describe('lemmaBidAdapter', function() { expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id expect(data.imp[0].tagid).to.equal('1'); // tagid expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.floor); }); it('Request params check without mediaTypes object', function() { var bidRequests = [{ @@ -192,6 +193,7 @@ describe('lemmaBidAdapter', function() { expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id expect(data.imp[0].tagid).to.equal(undefined); // tagid expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.floor); }); it('Request params multi size format object check', function() { var bidRequests = [{ From fecf386f9eb5e8c7992baefb8d43922a3081b8fc Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 1 Apr 2021 07:57:54 +0530 Subject: [PATCH 22/28] Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. --- modules/lemmaBidAdapter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index db476360a13..ec658097821 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -376,9 +376,7 @@ function _getImpressionObject(bid) { secure: window.location.protocol === 'https:' ? 1 : 0, bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY }; - _setFloor(impression, bid); - if (bid.hasOwnProperty('mediaTypes')) { for (mediaTypes in bid.mediaTypes) { switch (mediaTypes) { From 56ec057af76b33ab3d408d74bd6c4011a5543d44 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 1 Apr 2021 14:50:26 +0530 Subject: [PATCH 23/28] Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. --- test/spec/modules/lemmaBidAdapter_spec.js | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index 370bd77f20b..d6da74e13f5 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -23,6 +23,7 @@ describe('lemmaBidAdapter', function() { pubId: 1001, adunitId: 1, currency: 'AUD', + bidFloor: 1.3, geo: { lat: '12.3', lon: '23.7', @@ -46,6 +47,7 @@ describe('lemmaBidAdapter', function() { params: { pubId: 1001, adunitId: 1, + bidFloor: 1.3, video: { mimes: ['video/mp4', 'video/x-flv'], skippable: true, @@ -311,6 +313,77 @@ describe('lemmaBidAdapter', function() { expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); }); + describe('setting imp.floor using floorModule', function() { + /* + Use the minimum value among floor from floorModule per mediaType + If params.bidFloor is set then take max(floor, min(floors from floorModule)) + set imp.bidfloor only if it is more than 0 + */ + + let newRequest; + let floorModuleTestData; + let getFloor = function(req) { + return floorModuleTestData[req.mediaType]; + }; + + beforeEach(() => { + floorModuleTestData = { + 'banner': { + 'currency': 'USD', + 'floor': 1.50 + }, + 'video': { + 'currency': 'USD', + 'floor': 2.00 + } + }; + newRequest = utils.deepClone(bidRequests); + newRequest[0].getFloor = getFloor; + }); + + it('bidfloor should be undefined if calculation is <= 0', function() { + floorModuleTestData.banner.floor = 0; // lowest of them all + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(undefined); + }); + + it('ignore floormodule o/p if floor is not number', function() { + floorModuleTestData.banner.floor = 'INR'; + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(2); // video will be lowest now + }); + + it('ignore floormodule o/p if currency is not matched', function() { + floorModuleTestData.banner.currency = 'INR'; + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(2); // video will be lowest now + }); + + it('bidFloor is not passed, use minimum from floorModule', function() { + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(1.5); + }); + + it('bidFloor is passed as 1, use min of fllorModule as it is highest', function() { + newRequest[0].params.bidFloor = '1.0';// yes, we want it as a string + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(1.5); + }); + }); describe('Response checking', function() { it('should check for valid response values', function() { var request = spec.buildRequests(bidRequests); From 08559404f9dee98e75ed3a5fcfdb99d9c185df9f Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:22:06 +0530 Subject: [PATCH 24/28] Update lemmaBidAdapter_spec.js --- test/spec/modules/lemmaBidAdapter_spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index d6da74e13f5..99b9b20f388 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -356,7 +356,7 @@ describe('lemmaBidAdapter', function() { let request = spec.buildRequests(newRequest); let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.bidfloor).to.equal(2); // video will be lowest now + expect(data.bidfloor).to.equal(undefined); // video will be lowest now }); it('ignore floormodule o/p if currency is not matched', function() { @@ -365,7 +365,7 @@ describe('lemmaBidAdapter', function() { let request = spec.buildRequests(newRequest); let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.bidfloor).to.equal(2); // video will be lowest now + expect(data.bidfloor).to.equal(undefined); // video will be lowest now }); it('bidFloor is not passed, use minimum from floorModule', function() { @@ -373,7 +373,7 @@ describe('lemmaBidAdapter', function() { let request = spec.buildRequests(newRequest); let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.bidfloor).to.equal(1.5); + expect(data.bidfloor).to.equal(undefined); }); it('bidFloor is passed as 1, use min of fllorModule as it is highest', function() { From e4307c73c9458e20cbbb613a491a1f946272fda9 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:41:26 +0530 Subject: [PATCH 25/28] Update lemmaBidAdapter.js --- modules/lemmaBidAdapter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index ec658097821..b3e20204de8 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -376,7 +376,9 @@ function _getImpressionObject(bid) { secure: window.location.protocol === 'https:' ? 1 : 0, bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY }; - _setFloor(impression, bid); + if(params.bidFloor){ + impression.bidfloor = params.bidFloor; + } if (bid.hasOwnProperty('mediaTypes')) { for (mediaTypes in bid.mediaTypes) { switch (mediaTypes) { @@ -412,7 +414,7 @@ function _getImpressionObject(bid) { } impression.banner = bObj; } - + _setFloor(impression, bid); return impression.hasOwnProperty(BANNER) || impression.hasOwnProperty(VIDEO) ? impression : undefined; } From 1eac5b77445a08798dc87e95681465fbec8a3f57 Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:44:51 +0530 Subject: [PATCH 26/28] Update lemmaBidAdapter.js Fixed lint issue. --- modules/lemmaBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js index b3e20204de8..c7440743d2c 100644 --- a/modules/lemmaBidAdapter.js +++ b/modules/lemmaBidAdapter.js @@ -376,7 +376,7 @@ function _getImpressionObject(bid) { secure: window.location.protocol === 'https:' ? 1 : 0, bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY }; - if(params.bidFloor){ + if (params.bidFloor) { impression.bidfloor = params.bidFloor; } if (bid.hasOwnProperty('mediaTypes')) { From 5b3a0438a4f4b18f118e27ad77a97ae39c4fef2e Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:55:26 +0530 Subject: [PATCH 27/28] Update lemmaBidAdapter_spec.js Fixed test cases. --- test/spec/modules/lemmaBidAdapter_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index 99b9b20f388..cdd05d5e1b8 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -163,7 +163,7 @@ describe('lemmaBidAdapter', function() { expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id expect(data.imp[0].tagid).to.equal('1'); // tagid expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.floor); + expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.bidFloor); }); it('Request params check without mediaTypes object', function() { var bidRequests = [{ @@ -195,7 +195,7 @@ describe('lemmaBidAdapter', function() { expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id expect(data.imp[0].tagid).to.equal(undefined); // tagid expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.floor); + expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.bidFloor); }); it('Request params multi size format object check', function() { var bidRequests = [{ @@ -376,12 +376,12 @@ describe('lemmaBidAdapter', function() { expect(data.bidfloor).to.equal(undefined); }); - it('bidFloor is passed as 1, use min of fllorModule as it is highest', function() { + it('bidFloor is passed as 1, use min of floorModule as it is highest', function() { newRequest[0].params.bidFloor = '1.0';// yes, we want it as a string let request = spec.buildRequests(newRequest); let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.bidfloor).to.equal(1.5); + expect(data.bidfloor).to.equal(1); }); }); describe('Response checking', function() { From 806ed23cbce265a4db9c937f38e7fd443a21f3bb Mon Sep 17 00:00:00 2001 From: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Date: Fri, 2 Apr 2021 14:27:03 +0530 Subject: [PATCH 28/28] Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. --- test/spec/modules/lemmaBidAdapter_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index cdd05d5e1b8..a3a70a39731 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -329,11 +329,11 @@ describe('lemmaBidAdapter', function() { beforeEach(() => { floorModuleTestData = { 'banner': { - 'currency': 'USD', + 'currency': 'AUD', 'floor': 1.50 }, 'video': { - 'currency': 'USD', + 'currency': 'AUD', 'floor': 2.00 } }; @@ -373,7 +373,7 @@ describe('lemmaBidAdapter', function() { let request = spec.buildRequests(newRequest); let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.bidfloor).to.equal(undefined); + expect(data.bidfloor).to.equal(1.5); }); it('bidFloor is passed as 1, use min of floorModule as it is highest', function() { @@ -381,7 +381,7 @@ describe('lemmaBidAdapter', function() { let request = spec.buildRequests(newRequest); let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.bidfloor).to.equal(1); + expect(data.bidfloor).to.equal(1.5); }); }); describe('Response checking', function() {