From e49b47c35c3a074873876e1a425aedd9315a459d Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Mon, 27 Apr 2020 19:58:34 +0300 Subject: [PATCH 01/26] initial --- modules/adprimeBidAdapter.js | 102 +++++++++ modules/adprimeBidAdapter.md | 53 +++++ test/spec/modules/adprimeBidAdapter_spec.js | 221 ++++++++++++++++++++ 3 files changed, 376 insertions(+) create mode 100644 modules/adprimeBidAdapter.js create mode 100644 modules/adprimeBidAdapter.md create mode 100644 test/spec/modules/adprimeBidAdapter_spec.js diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js new file mode 100644 index 00000000000..431ebde1918 --- /dev/null +++ b/modules/adprimeBidAdapter.js @@ -0,0 +1,102 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const BIDDER_CODE = 'adprime'; +const AD_URL = 'https://delta.adprime.com/?c=o&m=multi'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || + !bid.ttl || !bid.currency) { + return false; + } + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl); + case NATIVE: + return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); + default: + return false; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + let winTop = window; + let location; + try { + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; + } catch (e) { + location = winTop.location; + utils.logMessage(e); + }; + let placements = []; + let request = { + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'placements': placements + }; + request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent + } + } + const len = validBidRequests.length; + + for (let i = 0; i < len; i++) { + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER + + placements.push({ + placementId: bid.params.placementId, + bidId: bid.bidId, + sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], + traffic: traff + }); + if (bid.schain) { + placements.schain = bid.schain; + } + } + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses) => { + return + } + +}; + +registerBidder(spec); diff --git a/modules/adprimeBidAdapter.md b/modules/adprimeBidAdapter.md new file mode 100644 index 00000000000..0c6bed68c13 --- /dev/null +++ b/modules/adprimeBidAdapter.md @@ -0,0 +1,53 @@ +# Overview + +``` +Module Name: adprime Bidder Adapter +Module Type: adprime Bidder Adapter +``` + +# Description + +Module that connects to adprime demand sources + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'adprime', + params: { + placementId: 0, + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'adprime', + params: { + placementId: 0, + traffic: 'video' + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js new file mode 100644 index 00000000000..57b8a552920 --- /dev/null +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -0,0 +1,221 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/adprimeBidAdapter.js'; + +describe('AdprimebBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'adprime', + params: { + placementId: 0, + traffic: 'banner' + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and placementId parameters present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid]); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://delta.adprime.com/?c=o&m=multi'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + let placement = data['placements'][0]; + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement.placementId).to.equal(0); + expect(placement.bidId).to.equal('23fhj33i987f'); + expect(placement.traffic).to.equal('banner'); + }); + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.width).to.equal(300); + expect(dataItem.height).to.equal(250); + expect(dataItem.ad).to.equal('Test'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); +}); From 48b53a06965f6ff1fc5a89e3f1dcbd0fdf0ecfe8 Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Mon, 27 Apr 2020 20:02:54 +0300 Subject: [PATCH 02/26] fix --- modules/adprimeBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 431ebde1918..9828fe09fa0 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -94,7 +94,7 @@ export const spec = { }, getUserSyncs: (syncOptions, serverResponses) => { - return + } }; From f33f62935b49f15ecb3b623331c29ad2294c0309 Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Thu, 30 Apr 2020 12:33:02 +0300 Subject: [PATCH 03/26] remove redundant language mod, use player sizes in video traff --- modules/adprimeBidAdapter.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 9828fe09fa0..7d28d35c66d 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -50,7 +50,6 @@ export const spec = { 'page': location.pathname, 'placements': placements }; - request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) if (bidderRequest) { if (bidderRequest.uspConsent) { request.ccpa = bidderRequest.uspConsent; @@ -63,13 +62,21 @@ export const spec = { for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER - + let sizes + if (bid.mediaTypes) { + if (bid.mediaType[BANNER] && bid.mediaType[BANNER].sizes) { + sizes = bid.mediaType[BANNER].sizes + } else if (bid.mediaType[VIDEO] && bid.mediaType[VIDEO].playerSize) { + sizes = bid.mediaType[VIDEO].playerSize + } + } placements.push({ placementId: bid.params.placementId, bidId: bid.bidId, - sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], - traffic: traff + sizes: sizes || [], + wPlayer: sizes ? sizes[0] : 0, + hPlayer: sizes ? sizes[1] : 0, + traffic: bid.params.traffic || BANNER }); if (bid.schain) { placements.schain = bid.schain; @@ -92,11 +99,6 @@ export const spec = { } return response; }, - - getUserSyncs: (syncOptions, serverResponses) => { - - } - }; registerBidder(spec); From 62e65e8f784ea4bc93e071956da29b7c3d8ac9d6 Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Thu, 30 Apr 2020 12:54:05 +0300 Subject: [PATCH 04/26] test modify --- test/spec/modules/adprimeBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index 57b8a552920..a9cd14f40fb 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -46,7 +46,7 @@ describe('AdprimebBidAdapter', function () { expect(data.host).to.be.a('string'); expect(data.page).to.be.a('string'); let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer'); expect(placement.placementId).to.equal(0); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.traffic).to.equal('banner'); From 277715d27e3e15b00ad82a624508aa7fbf39c010 Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Thu, 30 Apr 2020 13:38:35 +0300 Subject: [PATCH 05/26] fix --- modules/adprimeBidAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 7d28d35c66d..dd3035effb1 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -64,10 +64,10 @@ export const spec = { let bid = validBidRequests[i]; let sizes if (bid.mediaTypes) { - if (bid.mediaType[BANNER] && bid.mediaType[BANNER].sizes) { - sizes = bid.mediaType[BANNER].sizes - } else if (bid.mediaType[VIDEO] && bid.mediaType[VIDEO].playerSize) { - sizes = bid.mediaType[VIDEO].playerSize + if (bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { + sizes = bid.mediaTypes[BANNER].sizes + } else if (bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) { + sizes = bid.mediaTypes[VIDEO].playerSize } } placements.push({ From 5e63b96504388eab7abe392a82388fff8795996a Mon Sep 17 00:00:00 2001 From: Adprime Date: Wed, 6 May 2020 14:52:54 +0300 Subject: [PATCH 06/26] Adding Tests --- modules/adprimeBidAdapter.js | 6 +-- test/spec/modules/adprimeBidAdapter_spec.js | 59 +++++++++++++++++++-- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index dd3035effb1..d324886f7c6 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -76,11 +76,9 @@ export const spec = { sizes: sizes || [], wPlayer: sizes ? sizes[0] : 0, hPlayer: sizes ? sizes[1] : 0, - traffic: bid.params.traffic || BANNER + traffic: bid.params.traffic || BANNER, + schain: bid.schain || {} }); - if (bid.schain) { - placements.schain = bid.schain; - } } return { method: 'POST', diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index a9cd14f40fb..7524665e33f 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -1,13 +1,20 @@ import {expect} from 'chai'; import {spec} from '../../../modules/adprimeBidAdapter.js'; +import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; describe('AdprimebBidAdapter', function () { - let bid = { + const bid = { bidId: '23fhj33i987f', bidder: 'adprime', params: { placementId: 0, - traffic: 'banner' + traffic: BANNER + } + }; + + const bidderRequest = { + refererInfo: { + referer: 'test.com' } }; @@ -22,7 +29,7 @@ describe('AdprimebBidAdapter', function () { }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); + let serverRequest = spec.buildRequests([bid], bidderRequest); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -45,12 +52,54 @@ describe('AdprimebBidAdapter', function () { expect(data.secure).to.be.within(0, 1); expect(data.host).to.be.a('string'); expect(data.page).to.be.a('string'); + expect(data.gdpr).to.not.exist; + expect(data.ccpa).to.not.exist; let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer'); + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain'); expect(placement.placementId).to.equal(0); expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal('banner'); + expect(placement.traffic).to.equal(BANNER); + expect(placement.schain).to.be.an('object'); + }); + + it('Returns valid data for mediatype video', function () { + const playerSize = [300, 300]; + bid.mediaTypes = {}; + bid.params.traffic = VIDEO; + bid.mediaTypes[VIDEO] = { + playerSize + }; + serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data).to.be.an('object'); + let placement = data['placements'][0]; + expect(placement).to.be.an('object'); + expect(placement.traffic).to.equal(VIDEO); + expect(placement.wPlayer).to.equal(playerSize[0]); + expect(placement.hPlayer).to.equal(playerSize[1]); + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + bidderRequest.gdprConsent = 'test'; + serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = 'test'; + serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + it('Returns empty data if no valid requests are passed', function () { serverRequest = spec.buildRequests([]); let data = serverRequest.data; From 7864df70542c95b49385259847da8577cf65568f Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Wed, 13 May 2020 16:19:45 +0300 Subject: [PATCH 07/26] add keywords param --- modules/adprimeBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index d324886f7c6..bcf7b744f09 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -77,7 +77,8 @@ export const spec = { wPlayer: sizes ? sizes[0] : 0, hPlayer: sizes ? sizes[1] : 0, traffic: bid.params.traffic || BANNER, - schain: bid.schain || {} + schain: bid.schain || {}, + keywords: bid.params.keywords || [] }); } return { From cd556985cdff10614614f0752762b934cb12e65d Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Wed, 13 May 2020 16:23:15 +0300 Subject: [PATCH 08/26] log --- modules/adprimeBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index bcf7b744f09..f4ff9e48b55 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -70,6 +70,7 @@ export const spec = { sizes = bid.mediaTypes[VIDEO].playerSize } } + console.log(bid.params.keywords) placements.push({ placementId: bid.params.placementId, bidId: bid.bidId, From 07415af666256d1b21bc35d99b2ba33f2c23cc47 Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Wed, 13 May 2020 16:25:21 +0300 Subject: [PATCH 09/26] log --- modules/adprimeBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index f4ff9e48b55..4e34d9b68cd 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -70,7 +70,7 @@ export const spec = { sizes = bid.mediaTypes[VIDEO].playerSize } } - console.log(bid.params.keywords) + console.log("BID_PARAM",bid.params.keywords) placements.push({ placementId: bid.params.placementId, bidId: bid.bidId, From 527231b516e38820d33e53b98b26cd8dbb7aae53 Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Wed, 13 May 2020 16:27:58 +0300 Subject: [PATCH 10/26] log --- modules/adprimeBidAdapter.js | 2 +- modules/adprimeBidAdapter.md | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 4e34d9b68cd..306ab76f512 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -70,7 +70,7 @@ export const spec = { sizes = bid.mediaTypes[VIDEO].playerSize } } - console.log("BID_PARAM",bid.params.keywords) + placements.push({ placementId: bid.params.placementId, bidId: bid.bidId, diff --git a/modules/adprimeBidAdapter.md b/modules/adprimeBidAdapter.md index 0c6bed68c13..9eaedd7419c 100644 --- a/modules/adprimeBidAdapter.md +++ b/modules/adprimeBidAdapter.md @@ -25,7 +25,8 @@ Module that connects to adprime demand sources bidder: 'adprime', params: { placementId: 0, - traffic: 'banner' + traffic: 'banner', + keywords: ['cat_1', 'cat_2'] } } ] @@ -44,7 +45,8 @@ Module that connects to adprime demand sources bidder: 'adprime', params: { placementId: 0, - traffic: 'video' + traffic: 'video', + keywords: ['cat_1', 'cat_2'] } } ] From 3e29607dfd9360e01a5539f742964898819e250b Mon Sep 17 00:00:00 2001 From: Aigolkin1991 Date: Wed, 13 May 2020 16:40:41 +0300 Subject: [PATCH 11/26] fix --- test/spec/modules/adprimeBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index 7524665e33f..3508a1175a6 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -55,7 +55,7 @@ describe('AdprimebBidAdapter', function () { expect(data.gdpr).to.not.exist; expect(data.ccpa).to.not.exist; let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain'); + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords'); expect(placement.placementId).to.equal(0); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.traffic).to.equal(BANNER); From 7ee7c6a2ce443438ed1a0d795a0a3d02f67d75a0 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 14:49:14 +0300 Subject: [PATCH 12/26] add idl --- modules/adprimeBidAdapter.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 306ab76f512..dd2b1f1d7e9 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -59,10 +59,11 @@ export const spec = { } } const len = validBidRequests.length; - + for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; let sizes + let identeties = {} if (bid.mediaTypes) { if (bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { sizes = bid.mediaTypes[BANNER].sizes @@ -70,6 +71,10 @@ export const spec = { sizes = bid.mediaTypes[VIDEO].playerSize } } + + if (bid.userId && bid.userId.idl_env) { + identeties.identityLink = bid.userId.idl_env + } placements.push({ placementId: bid.params.placementId, @@ -79,7 +84,8 @@ export const spec = { hPlayer: sizes ? sizes[1] : 0, traffic: bid.params.traffic || BANNER, schain: bid.schain || {}, - keywords: bid.params.keywords || [] + keywords: bid.params.keywords || [], + identeties }); } return { From f3526ed32a1c6e86ac886f51094a82ccd109949a Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 14:49:21 +0300 Subject: [PATCH 13/26] add idl --- test/spec/modules/adprimeBidAdapter_spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index 3508a1175a6..cf4185a129b 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -106,6 +106,25 @@ describe('AdprimebBidAdapter', function () { expect(data.placements).to.be.an('array').that.is.empty; }); }); + + describe('buildRequests with user ids', function () { + bid.userId = {} + bid.userId.idl_env = 'idl_env123'; + let serverRequest = spec.buildRequests([bid], bidderRequest); + it('Return bids with user identeties', function () { + let data = serverRequest.data; + let placements = data['placements']; + expect(data).to.be.an('object'); + for (let i = 0; i < placements.length; i++) { + let placement = placements[i]; + expect(placement).to.have.property('identeties') + expect(placement.identeties).to.be.an('object') + expect(placement.identeties).to.have.property('identityLink') + expect(placement.identeties.identityLink).to.be.equal('idl_env123') + } + }); + }); + describe('interpretResponse', function () { it('Should interpret banner response', function () { const banner = { From 6b0a7763972a3f7e5c5f71ddd7b4fae36e2ba2b3 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 15:51:47 +0300 Subject: [PATCH 14/26] fix test --- test/spec/modules/adprimeBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index cf4185a129b..488c15449a3 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -45,7 +45,7 @@ describe('AdprimebBidAdapter', function () { it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'identeties', 'language', 'secure', 'host', 'page', 'placements'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); From 9adefd24db763bcbfcc71add3c56e5699c23d64b Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:02:06 +0300 Subject: [PATCH 15/26] lint --- modules/adprimeBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index dd2b1f1d7e9..d5ea3bb21ee 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -71,7 +71,6 @@ export const spec = { sizes = bid.mediaTypes[VIDEO].playerSize } } - if (bid.userId && bid.userId.idl_env) { identeties.identityLink = bid.userId.idl_env } From a5e9ef124da54bb437ea5f95ec8a63dbc7ca0145 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:03:07 +0300 Subject: [PATCH 16/26] lint --- test/spec/modules/adprimeBidAdapter_spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index 488c15449a3..f5216d8e706 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -106,7 +106,6 @@ describe('AdprimebBidAdapter', function () { expect(data.placements).to.be.an('array').that.is.empty; }); }); - describe('buildRequests with user ids', function () { bid.userId = {} bid.userId.idl_env = 'idl_env123'; @@ -124,7 +123,6 @@ describe('AdprimebBidAdapter', function () { } }); }); - describe('interpretResponse', function () { it('Should interpret banner response', function () { const banner = { From 243c0ab74c0ab8d74cf0c72b3a5e104d29615fc5 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:07:24 +0300 Subject: [PATCH 17/26] fix --- test/spec/modules/adprimeBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index f5216d8e706..fe05634baae 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -45,7 +45,7 @@ describe('AdprimebBidAdapter', function () { it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'identeties', 'language', 'secure', 'host', 'page', 'placements'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); @@ -55,7 +55,7 @@ describe('AdprimebBidAdapter', function () { expect(data.gdpr).to.not.exist; expect(data.ccpa).to.not.exist; let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords'); + expect(placement).to.have.keys('placementId', 'bidId', 'identeties', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords'); expect(placement.placementId).to.equal(0); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.traffic).to.equal(BANNER); From 3a07e28ce10a8e3939617d688d78eb563d3c8df7 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:11:04 +0300 Subject: [PATCH 18/26] lint --- modules/adprimeBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index d5ea3bb21ee..6e5c2de259f 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -59,7 +59,6 @@ export const spec = { } } const len = validBidRequests.length; - for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; let sizes From b7abd982c440c38a3efddf1b75a45a930787c957 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:12:46 +0300 Subject: [PATCH 19/26] lint --- modules/adprimeBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 6e5c2de259f..d5ea3bb21ee 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -59,6 +59,7 @@ export const spec = { } } const len = validBidRequests.length; + for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; let sizes From ab19d800ffa6bf50489027298bc486d878eb2153 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:16:01 +0300 Subject: [PATCH 20/26] lint --- modules/adprimeBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index d5ea3bb21ee..50303b82979 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -59,7 +59,7 @@ export const spec = { } } const len = validBidRequests.length; - + for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; let sizes From 7688b5b67db4493d09665ad4df7da56f94663130 Mon Sep 17 00:00:00 2001 From: Adprime <64427228+Adprime@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:16:09 +0300 Subject: [PATCH 21/26] lint From b1f569247ab738cee41eba682b94fa9992a0e973 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Mon, 1 Feb 2021 15:03:40 +0200 Subject: [PATCH 22/26] add sync --- modules/adprimeBidAdapter.js | 20 ++++++++++++++++++++ test/spec/modules/adprimeBidAdapter_spec.js | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 50303b82979..12d0410a821 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -4,6 +4,7 @@ import * as utils from '../src/utils.js'; const BIDDER_CODE = 'adprime'; const AD_URL = 'https://delta.adprime.com/?c=o&m=multi'; +const SYNC_URL = 'https://delta.adprime.com/?c=rtb&m=sync'; function isBidResponseValid(bid) { if (!bid.requestId || !bid.cpm || !bid.creativeId || @@ -104,6 +105,25 @@ export const spec = { } return response; }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncUrl = SYNC_URL + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + return [{ + type: 'image', + url: syncUrl + }]; + } + }; registerBidder(spec); diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index fe05634baae..d16b96e0c82 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -284,4 +284,14 @@ describe('AdprimebBidAdapter', function () { expect(serverResponses).to.be.an('array').that.is.empty; }); }); + describe('getUserSyncs', function () { + let userSync = spec.getUserSyncs(); + it('Returns valid URL and type', function () { + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.exist; + expect(userSync[0].url).to.exist; + expect(userSync[0].type).to.be.equal('image'); + expect(userSync[0].url).to.be.equal('https://delta.adprime.com/?c=o&m=sync'); + }); + }); }); From 3b4bba03525614a62ca8b68022f8836e3f14e7e8 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Wed, 3 Feb 2021 10:46:54 +0200 Subject: [PATCH 23/26] fix --- test/spec/modules/adprimeBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index d16b96e0c82..8627941dc80 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -291,7 +291,7 @@ describe('AdprimebBidAdapter', function () { expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://delta.adprime.com/?c=o&m=sync'); + expect(userSync[0].url).to.be.equal('https://delta.adprime.com/?c=rtb&m=sync'); }); }); }); From ceb14939718f3231303d7214d15b549fe84fd9ad Mon Sep 17 00:00:00 2001 From: Adprime Date: Wed, 4 Aug 2021 20:12:51 +0300 Subject: [PATCH 24/26] add video params, advertiserDomains and getFloor --- modules/adprimeBidAdapter.js | 78 ++++++++++++++++----- modules/adprimeBidAdapter.md | 8 +-- test/spec/modules/adprimeBidAdapter_spec.js | 37 ++++++---- 3 files changed, 85 insertions(+), 38 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 12d0410a821..57cee307b23 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -3,12 +3,12 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; const BIDDER_CODE = 'adprime'; -const AD_URL = 'https://delta.adprime.com/?c=o&m=multi'; -const SYNC_URL = 'https://delta.adprime.com/?c=rtb&m=sync'; +const AD_URL = 'https://delta.adprime.com/pbjs'; +const SYNC_URL = 'https://delta.adprime.com'; function isBidResponseValid(bid) { if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { + !bid.ttl || !bid.currency || !bid.meta) { return false; } switch (bid.mediaType) { @@ -23,12 +23,29 @@ function isBidResponseValid(bid) { } } +function getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return utils.deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0 + } +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO, NATIVE], isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); + return Boolean(bid.bidId && bid.params && bid.params.placementId); }, buildRequests: (validBidRequests = [], bidderRequest) => { @@ -43,13 +60,13 @@ export const spec = { }; let placements = []; let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements + deviceWidth: winTop.screen.width, + deviceHeight: winTop.screen.height, + language: (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + secure: 1, + host: location.host, + page: location.pathname, + placements: placements }; if (bidderRequest) { if (bidderRequest.uspConsent) { @@ -63,13 +80,34 @@ export const spec = { for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; + const { mediaTypes } = bid; + const placement = {}; let sizes let identeties = {} - if (bid.mediaTypes) { - if (bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { - sizes = bid.mediaTypes[BANNER].sizes - } else if (bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) { - sizes = bid.mediaTypes[VIDEO].playerSize + if (mediaTypes) { + if (mediaTypes[BANNER] && mediaTypes[BANNER].sizes) { + placement.adFormat = BANNER; + sizes = mediaTypes[BANNER].sizes + } else if (mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize) { + placement.adFormat = VIDEO; + sizes = mediaTypes[VIDEO].playerSize + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else { + placement.adFormat = NATIVE; + placement.native = mediaTypes[NATIVE]; } } if (bid.userId && bid.userId.idl_env) { @@ -77,15 +115,16 @@ export const spec = { } placements.push({ + ...placement, placementId: bid.params.placementId, bidId: bid.bidId, sizes: sizes || [], wPlayer: sizes ? sizes[0] : 0, hPlayer: sizes ? sizes[1] : 0, - traffic: bid.params.traffic || BANNER, schain: bid.schain || {}, keywords: bid.params.keywords || [], - identeties + identeties, + bidFloor: getBidFloor(bid) }); } return { @@ -100,6 +139,9 @@ export const spec = { for (let i = 0; i < serverResponse.body.length; i++) { let resItem = serverResponse.body[i]; if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + response.push(resItem); } } diff --git a/modules/adprimeBidAdapter.md b/modules/adprimeBidAdapter.md index 913b768d8e9..70eb8da1109 100644 --- a/modules/adprimeBidAdapter.md +++ b/modules/adprimeBidAdapter.md @@ -24,10 +24,8 @@ Module that connects to adprime demand sources { bidder: 'adprime', params: { - placementId: 0, - traffic: 'banner', + placementId: 'testBanner', keywords: ['cat_1', 'cat_2'] - } } ] @@ -45,10 +43,8 @@ Module that connects to adprime demand sources { bidder: 'adprime', params: { - placementId: 0, - traffic: 'video', + placementId: 'testVideo', keywords: ['cat_1', 'cat_2'] - } } ] diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index 8627941dc80..c28837f103a 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -6,9 +6,13 @@ describe('AdprimebBidAdapter', function () { const bid = { bidId: '23fhj33i987f', bidder: 'adprime', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, params: { - placementId: 0, - traffic: BANNER + placementId: 'testBanner' } }; @@ -40,7 +44,7 @@ describe('AdprimebBidAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://delta.adprime.com/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://delta.adprime.com/pbjs'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; @@ -55,17 +59,16 @@ describe('AdprimebBidAdapter', function () { expect(data.gdpr).to.not.exist; expect(data.ccpa).to.not.exist; let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'identeties', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords'); - expect(placement.placementId).to.equal(0); + expect(placement).to.have.keys('placementId', 'bidId', 'identeties', 'adFormat', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords', 'bidFloor'); + expect(placement.placementId).to.equal('testBanner'); expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal(BANNER); + expect(placement.adFormat).to.equal(BANNER); expect(placement.schain).to.be.an('object'); }); it('Returns valid data for mediatype video', function () { const playerSize = [300, 300]; bid.mediaTypes = {}; - bid.params.traffic = VIDEO; bid.mediaTypes[VIDEO] = { playerSize }; @@ -74,7 +77,7 @@ describe('AdprimebBidAdapter', function () { expect(data).to.be.an('object'); let placement = data['placements'][0]; expect(placement).to.be.an('object'); - expect(placement.traffic).to.equal(VIDEO); + expect(placement.adFormat).to.equal(VIDEO); expect(placement.wPlayer).to.equal(playerSize[0]); expect(placement.hPlayer).to.equal(playerSize[1]); }); @@ -137,14 +140,15 @@ describe('AdprimebBidAdapter', function () { creativeId: '2', netRevenue: true, currency: 'USD', - dealId: '1' + dealId: '1', + meta: {} }] }; let bannerResponses = spec.interpretResponse(banner); expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); expect(dataItem.requestId).to.equal('23fhj33i987f'); expect(dataItem.cpm).to.equal(0.4); expect(dataItem.width).to.equal(300); @@ -154,6 +158,7 @@ describe('AdprimebBidAdapter', function () { expect(dataItem.creativeId).to.equal('2'); expect(dataItem.netRevenue).to.be.true; expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); }); it('Should interpret video response', function () { const video = { @@ -166,7 +171,8 @@ describe('AdprimebBidAdapter', function () { creativeId: '2', netRevenue: true, currency: 'USD', - dealId: '1' + dealId: '1', + meta: {} }] }; let videoResponses = spec.interpretResponse(video); @@ -174,7 +180,7 @@ describe('AdprimebBidAdapter', function () { let dataItem = videoResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); expect(dataItem.requestId).to.equal('23fhj33i987f'); expect(dataItem.cpm).to.equal(0.5); expect(dataItem.vastUrl).to.equal('test.com'); @@ -182,6 +188,7 @@ describe('AdprimebBidAdapter', function () { expect(dataItem.creativeId).to.equal('2'); expect(dataItem.netRevenue).to.be.true; expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); }); it('Should interpret native response', function () { const native = { @@ -199,13 +206,14 @@ describe('AdprimebBidAdapter', function () { creativeId: '2', netRevenue: true, currency: 'USD', + meta: {} }] }; let nativeResponses = spec.interpretResponse(native); expect(nativeResponses).to.be.an('array').that.is.not.empty; let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') expect(dataItem.requestId).to.equal('23fhj33i987f'); expect(dataItem.cpm).to.equal(0.4); @@ -218,6 +226,7 @@ describe('AdprimebBidAdapter', function () { expect(dataItem.creativeId).to.equal('2'); expect(dataItem.netRevenue).to.be.true; expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); }); it('Should return an empty array if invalid banner response is passed', function () { const invBanner = { @@ -291,7 +300,7 @@ describe('AdprimebBidAdapter', function () { expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://delta.adprime.com/?c=rtb&m=sync'); + expect(userSync[0].url).to.be.equal('https://delta.adprime.com'); }); }); }); From 9b5831cdc6212f8e27306d581c54845690a4f9bf Mon Sep 17 00:00:00 2001 From: Adprime Date: Thu, 5 Aug 2021 11:17:51 +0300 Subject: [PATCH 25/26] add audiences param --- modules/adprimeBidAdapter.js | 1 + modules/adprimeBidAdapter.md | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index 57cee307b23..ef370301184 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -123,6 +123,7 @@ export const spec = { hPlayer: sizes ? sizes[1] : 0, schain: bid.schain || {}, keywords: bid.params.keywords || [], + audiences: bid.params.audiences || [], identeties, bidFloor: getBidFloor(bid) }); diff --git a/modules/adprimeBidAdapter.md b/modules/adprimeBidAdapter.md index 70eb8da1109..c8651ef1fd4 100644 --- a/modules/adprimeBidAdapter.md +++ b/modules/adprimeBidAdapter.md @@ -25,7 +25,8 @@ Module that connects to adprime demand sources bidder: 'adprime', params: { placementId: 'testBanner', - keywords: ['cat_1', 'cat_2'] + keywords: ['cat_1', 'cat_2'], + audiences: ['aud_1', 'aud_2'] } } ] @@ -44,7 +45,8 @@ Module that connects to adprime demand sources bidder: 'adprime', params: { placementId: 'testVideo', - keywords: ['cat_1', 'cat_2'] + keywords: ['cat_1', 'cat_2'], + audiences: ['aud_1', 'aud_2'] } } ] From 437ceb5c1040d57585b46b92f1f7f81d214759bb Mon Sep 17 00:00:00 2001 From: Adprime Date: Thu, 5 Aug 2021 11:32:11 +0300 Subject: [PATCH 26/26] fix test --- test/spec/modules/adprimeBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js index c28837f103a..53f41a6be4e 100644 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ b/test/spec/modules/adprimeBidAdapter_spec.js @@ -59,7 +59,7 @@ describe('AdprimebBidAdapter', function () { expect(data.gdpr).to.not.exist; expect(data.ccpa).to.not.exist; let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'identeties', 'adFormat', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords', 'bidFloor'); + expect(placement).to.have.keys('placementId', 'bidId', 'identeties', 'adFormat', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords', 'audiences', 'bidFloor'); expect(placement.placementId).to.equal('testBanner'); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.adFormat).to.equal(BANNER);