From 6e8aa3aa550c54ee3347c04ccf600d5c9138cfe3 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Tue, 25 May 2021 21:57:13 +0300 Subject: [PATCH 01/15] Video support for Kubient adapter --- modules/kubientBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 8f6ea53ecce..986007ea71b 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,5 +1,5 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER} from '../src/mediaTypes.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; const BIDDER_CODE = 'kubient'; @@ -9,7 +9,7 @@ const VENDOR_ID = 794; export const spec = { code: BIDDER_CODE, gvlid: VENDOR_ID, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [ BANNER, VIDEO ], isBidRequestValid: function (bid) { return !!(bid && bid.params); }, From f2efc9bff3ae0e098f1a621ef600418423ff1364 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Wed, 26 May 2021 17:56:42 +0300 Subject: [PATCH 02/15] remove sizes, add banner and video objects to adSlot --- modules/kubientBidAdapter.js | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 986007ea71b..6536d2000ab 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -18,24 +18,40 @@ export const spec = { return; } const result = validBidRequests.map(function (bid) { - let data = { + var adSlot = { + bidId: bid.bidId, + zoneId: bid.params.zoneid || '', + floor: bid.params.floor || 0.0 + } + + if (bid.mediaTypes.banner) { + adSlot.banner = bid.mediaTypes.banner + } else if (bid.mediaTypes.video) { + adSlot.video = bid.mediaTypes.video + } + + if (bid.schain) { + adSlot.schain = bid.schain; + } + + var data = { v: VERSION, requestId: bid.bidderRequestId, - adSlots: [{ - bidId: bid.bidId, - zoneId: bid.params.zoneid || '', - floor: bid.params.floor || 0.0, - sizes: bid.sizes || [], - schain: bid.schain || {}, - mediaTypes: bid.mediaTypes - }], - referer: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : null, + adSlots: [adSlot], tmax: bidderRequest.timeout, gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, - consent: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) ? bidderRequest.gdprConsent.consentString : null, consentGiven: kubientGetConsentGiven(bidderRequest.gdprConsent), uspConsent: bidderRequest.uspConsent - }; + } + + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + data.referer = bidderRequest.refererInfo.referer + } + + if (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) { + data.consent = bidderRequest.gdprConsent.consentString + } + return { method: 'POST', url: END_POINT, From d520a738795b32f49e6d872b3449f0504222d7dc Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Wed, 26 May 2021 18:04:09 +0300 Subject: [PATCH 03/15] else if is wrong because banner and video object can be defined at the same time --- modules/kubientBidAdapter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 6536d2000ab..da778d78f0c 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -26,7 +26,9 @@ export const spec = { if (bid.mediaTypes.banner) { adSlot.banner = bid.mediaTypes.banner - } else if (bid.mediaTypes.video) { + } + + if (bid.mediaTypes.video) { adSlot.video = bid.mediaTypes.video } From fde33d3a215f6fff623c6ddb0bb4686ab82b4778 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Tue, 1 Jun 2021 18:56:52 +0300 Subject: [PATCH 04/15] =?UTF-8?q?change=20endpoint=20/pbjs=20=E2=86=92=20/?= =?UTF-8?q?kubprebidjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/kubientBidAdapter.js | 4 ++-- test/spec/modules/kubientBidAdapter_spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index da778d78f0c..fde51574e8b 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -3,8 +3,8 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; const BIDDER_CODE = 'kubient'; -const END_POINT = 'https://kssp.kbntx.ch/pbjs'; -const VERSION = '1.0'; +const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; +const VERSION = '1.1'; const VENDOR_ID = 794; export const spec = { code: BIDDER_CODE, diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 1df4370b2ba..07138f7f0a0 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -67,7 +67,7 @@ describe('KubientAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/pbjs'); + expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); }); it('Returns valid data if array of bids is valid', function () { let data = JSON.parse(serverRequest.data); From 60439503e1ab3477a4dc7fbdd8c657162b36133f Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Tue, 1 Jun 2021 18:58:10 +0300 Subject: [PATCH 05/15] change ver 1.0 -> 1.1 --- test/spec/modules/kubientBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 07138f7f0a0..ad287972457 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -18,7 +18,7 @@ describe('KubientAdapter', function () { }, transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', schain: { - ver: '1.0', + ver: '1.1', complete: 1, nodes: [ { From 7822ac447f96a229579a76305f4c219545dc6390 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 8 Jun 2021 13:36:11 +0300 Subject: [PATCH 06/15] fix --- modules/kubientBidAdapter.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 8f6ea53ecce..461f8309e0e 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -18,13 +18,22 @@ export const spec = { return; } const result = validBidRequests.map(function (bid) { + var floor = 0.0; + if (typeof bid.getFloor === 'function') { + const mediaType = (Object.keys(bid.mediaTypes).length == 1) ? Object.keys(bid.mediaTypes)[0] : '*'; + const sizes = bid.sizes || '*'; + const floorInfo = bid.getFloor({currency: 'USD', mediaType: mediaType, size: sizes}); + if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { + floor = parseFloat(floorInfo.floor); + } + } let data = { v: VERSION, requestId: bid.bidderRequestId, adSlots: [{ bidId: bid.bidId, zoneId: bid.params.zoneid || '', - floor: bid.params.floor || 0.0, + floor: floor || 0.0, sizes: bid.sizes || [], schain: bid.schain || {}, mediaTypes: bid.mediaTypes From 256ffebb23ff2802770081034d356550c1ecbdd5 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 8 Jun 2021 15:58:47 +0300 Subject: [PATCH 07/15] fixed --- modules/kubientBidAdapter.js | 13 ++- test/spec/modules/kubientBidAdapter_spec.js | 96 ++++++++++++++++++--- 2 files changed, 90 insertions(+), 19 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index fde51574e8b..fe70096c674 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -17,26 +17,26 @@ export const spec = { if (!validBidRequests || !bidderRequest) { return; } - const result = validBidRequests.map(function (bid) { + return validBidRequests.map(function (bid) { var adSlot = { bidId: bid.bidId, zoneId: bid.params.zoneid || '', floor: bid.params.floor || 0.0 - } + }; if (bid.mediaTypes.banner) { - adSlot.banner = bid.mediaTypes.banner + adSlot.banner = bid.mediaTypes.banner; } if (bid.mediaTypes.video) { - adSlot.video = bid.mediaTypes.video + adSlot.video = bid.mediaTypes.video; } if (bid.schain) { adSlot.schain = bid.schain; } - var data = { + let data = { v: VERSION, requestId: bid.bidderRequestId, adSlots: [adSlot], @@ -44,7 +44,7 @@ export const spec = { gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, consentGiven: kubientGetConsentGiven(bidderRequest.gdprConsent), uspConsent: bidderRequest.uspConsent - } + }; if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { data.referer = bidderRequest.refererInfo.referer @@ -60,7 +60,6 @@ export const spec = { data: JSON.stringify(data) }; }); - return result; }, interpretResponse: function interpretResponse(serverResponse, request) { if (!serverResponse || !serverResponse.body || !serverResponse.body.seatbid) { diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index ad287972457..64e1e2c8ad0 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect, assert } from 'chai'; import { spec } from 'modules/kubientBidAdapter.js'; describe('KubientAdapter', function () { - let bid = { + let bidBanner = { bidId: '2dd581a2b6281d', bidder: 'kubient', bidderRequestId: '145e1d6a7837c9', @@ -31,6 +31,35 @@ describe('KubientAdapter', function () { ] } }; + let bidVideo = { + bidId: '1dd581a2b6281d', + bidder: 'kubient', + bidderRequestId: '245e1d6a7837c9', + params: { + zoneid: '5676', + floor: 1.0, + }, + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d1', + mediaTypes: { + video: { + playerSize: [1280, 720] + } + }, + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e61', + schain: { + ver: '1.1', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: '0', + hp: 1, + rid: 'bidrequestid', + domain: 'example.com' + } + ] + } + }; let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let uspConsentData = '1YCC'; let bidderRequest = { @@ -48,11 +77,51 @@ describe('KubientAdapter', function () { consentString: consentString, gdprApplies: true }, - uspConsent: uspConsentData, - bids: [bid] + uspConsent: uspConsentData }; - describe('buildRequests', function () { - let serverRequests = spec.buildRequests([bid], bidderRequest); + describe('buildRequestBanner', function () { + let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequests).to.be.an('array'); + }); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest.method).to.be.a('string'); + expect(serverRequest.url).to.be.a('string'); + expect(serverRequest.data).to.be.a('string'); + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = JSON.parse(serverRequest.data); + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); + expect(data.v).to.exist.and.to.be.a('string'); + expect(data.requestId).to.exist.and.to.be.a('string'); + expect(data.referer).to.be.a('string'); + expect(data.tmax).to.exist.and.to.be.a('number'); + expect(data.gdpr).to.exist.and.to.be.within(0, 1); + expect(data.consent).to.equal(consentString); + expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); + for (let j = 0; j < data['adSlots'].length; j++) { + let adSlot = data['adSlots'][i]; + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); + expect(adSlot.bidId).to.be.a('string'); + expect(adSlot.zoneId).to.be.a('string'); + expect(adSlot.floor).to.be.a('number'); + expect(adSlot.schain).to.be.an('object'); + expect(adSlot.banner).to.be.an('object'); + } + }); + } + }); + describe('buildRequestVideo', function () { + let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequests).to.be.an('array'); }); @@ -82,13 +151,12 @@ describe('KubientAdapter', function () { expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; - expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'sizes', 'schain', 'mediaTypes'); + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'video', 'schain'); expect(adSlot.bidId).to.be.a('string'); expect(adSlot.zoneId).to.be.a('string'); expect(adSlot.floor).to.be.a('number'); - expect(adSlot.sizes).to.be.an('array'); expect(adSlot.schain).to.be.an('object'); - expect(adSlot.mediaTypes).to.be.an('object'); + expect(adSlot.video).to.be.an('object'); } }); } @@ -96,14 +164,18 @@ describe('KubientAdapter', function () { describe('isBidRequestValid', function () { it('Should return true when required params are found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; + expect(spec.isBidRequestValid(bidBanner)).to.be.true; + expect(spec.isBidRequestValid(bidVideo)).to.be.true; }); it('Should return false when required params are not found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; + expect(spec.isBidRequestValid(bidBanner)).to.be.true; + expect(spec.isBidRequestValid(bidVideo)).to.be.true; }); it('Should return false when params are not found', function () { - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.be.false; + delete bidBanner.params; + expect(spec.isBidRequestValid(bidBanner)).to.be.false; + delete bidVideo.params; + expect(spec.isBidRequestValid(bidVideo)).to.be.false; }); }); From 7722a1e74ea3f9eb1d365437613fee600fca2bfd Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 8 Jun 2021 16:42:41 +0300 Subject: [PATCH 08/15] fix-test --- test/spec/modules/kubientBidAdapter_spec.js | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 64e1e2c8ad0..f63c7552945 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -7,8 +7,13 @@ describe('KubientAdapter', function () { bidder: 'kubient', bidderRequestId: '145e1d6a7837c9', params: { - zoneid: '5678', - floor: 0.05, + zoneid: '5678' + }, + getFloor: function(params) { + return { + floor: 0.05, + currency: 'USD' + }; }, auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', mediaTypes: { @@ -36,13 +41,20 @@ describe('KubientAdapter', function () { bidder: 'kubient', bidderRequestId: '245e1d6a7837c9', params: { - zoneid: '5676', - floor: 1.0, + zoneid: '5676' + }, + getFloor: function(params) { + return { + floor: 1.0, + currency: 'USD' + }; }, auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d1', mediaTypes: { video: { - playerSize: [1280, 720] + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4'] } }, transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e61', From 2bb155199a65b6b4839f4cc4d380067b7b28f255 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 8 Jun 2021 19:09:29 +0300 Subject: [PATCH 09/15] fix --- modules/kubientBidAdapter.js | 11 ++++++++--- test/spec/modules/kubientBidAdapter_spec.js | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 15304aeefc7..b6fe4782400 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -79,7 +79,7 @@ export const spec = { serverResponse.body.seatbid.forEach(seatbid => { let bids = seatbid.bid || []; bids.forEach(bid => { - bidResponses.push({ + const bidResponse = { requestId: bid.bidId, cpm: bid.price, currency: bid.cur, @@ -88,8 +88,13 @@ export const spec = { creativeId: bid.creativeId, netRevenue: bid.netRevenue, ttl: bid.ttl, - ad: bid.adm - }); + ad: bid.adm, + meta: {} + }; + if (bid.meta && bid.meta.advertiserDomains && utils.isArray(bid.meta.advertiserDomains)) { + bidResponse.meta.advertiserDomains = bid.meta.advertiserDomains; + } + bidResponses.push(bidResponse); }); }); return bidResponses; diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index f63c7552945..ee87f4101e0 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -208,7 +208,8 @@ describe('KubientAdapter', function () { h: 250, cur: 'USD', netRevenue: false, - ttl: 360 + ttl: 360, + meta: {advertiserDomains: ['google.com', 'yahoo.com']} } ] } @@ -218,7 +219,7 @@ describe('KubientAdapter', function () { let bannerResponses = spec.interpretResponse(serverResponse); expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl'); + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl', 'meta'); expect(dataItem.requestId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].bidId); expect(dataItem.cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); expect(dataItem.ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); @@ -228,6 +229,8 @@ describe('KubientAdapter', function () { expect(dataItem.currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].cur); expect(dataItem.netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(serverResponse.body.seatbid[0].bid[0].netRevenue); expect(dataItem.ttl).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].ttl); + expect(dataItem.meta).to.exist.and.to.be.a('object'); + expect(dataItem.meta.advertiserDomains).to.exist.and.to.be.a('array').and.to.equal(serverResponse.body.seatbid[0].bid[0].meta.advertiserDomains); }); it('Should return no ad when not given a server response', function () { From 997c9bb4789fb6ef544237256b356b77753b41a9 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 8 Jun 2021 20:04:39 +0300 Subject: [PATCH 10/15] admoain --- modules/kubientBidAdapter.js | 4 ++-- test/spec/modules/kubientBidAdapter_spec.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index b6fe4782400..2d7d816cc30 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -91,8 +91,8 @@ export const spec = { ad: bid.adm, meta: {} }; - if (bid.meta && bid.meta.advertiserDomains && utils.isArray(bid.meta.advertiserDomains)) { - bidResponse.meta.advertiserDomains = bid.meta.advertiserDomains; + if (bid.meta && bid.meta.adomain && utils.isArray(bid.meta.adomain)) { + bidResponse.meta.advertiserDomains = bid.meta.adomain; } bidResponses.push(bidResponse); }); diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index ee87f4101e0..514577ac1ef 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -209,7 +209,7 @@ describe('KubientAdapter', function () { cur: 'USD', netRevenue: false, ttl: 360, - meta: {advertiserDomains: ['google.com', 'yahoo.com']} + meta: {adomain: ['google.com', 'yahoo.com']} } ] } @@ -230,7 +230,7 @@ describe('KubientAdapter', function () { expect(dataItem.netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(serverResponse.body.seatbid[0].bid[0].netRevenue); expect(dataItem.ttl).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].ttl); expect(dataItem.meta).to.exist.and.to.be.a('object'); - expect(dataItem.meta.advertiserDomains).to.exist.and.to.be.a('array').and.to.equal(serverResponse.body.seatbid[0].bid[0].meta.advertiserDomains); + expect(dataItem.meta.advertiserDomains).to.exist.and.to.be.a('array').and.to.equal(serverResponse.body.seatbid[0].bid[0].meta.adomain); }); it('Should return no ad when not given a server response', function () { From 1801d420ae3f80ff80df4cccaff88845dbe232ff Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 18 Jun 2021 20:27:43 +0300 Subject: [PATCH 11/15] fix md fileC --- modules/kubientBidAdapter.md | 67 +++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/modules/kubientBidAdapter.md b/modules/kubientBidAdapter.md index 9f3e1d5f52e..a45d26dbc31 100644 --- a/modules/kubientBidAdapter.md +++ b/modules/kubientBidAdapter.md @@ -6,21 +6,56 @@ ​ # Description ​ -Connects to Kubient KSSP demand source to fetch bids. +Connects to Kubient KSSP demand source to fetch bids. Banners and Video supported ​ -# Test Parameters +# Banner Test Parameters +``` +var adUnits = [ + { + code: 'banner-ad-unit', + mediaTypes: { + banner: { + sizes: [[300, 100]] + } + }, + bids: [{ + bidder: 'kubient', + params: { + zoneid: "5fbb948f1e22b", + } + }] + } +]; +​ +# Video Test Parameters +​ +var adUnits = [ + { + code: 'video-ad-unit', + mediaTypes: { + video: { + playerSize: [300, 250], // required + context: 'instream', // required + mimes: ['video/mp4','video/x-flv'], // required + protocols: [ 2, 3 ], // required, set at least 1 value in array + placement: 1, // optional, defaults to 2 when context = outstream + api: [ 1, 2 ], // optional + skip: 0, // optional + minduration: 5, // optional + maxduration: 30, // optional + playbackmethod: [1,3], // optional + battr: [ 13, 14 ], // optional + linearity: 1, // optional + minbitrate: 10, // optional + maxbitrate: 10 // optional + } + }, + bids: [{ + bidder: 'kubient', + params: { + zoneid: "60ad1c0b35864", + } + }] + } +]; ``` - var adUnits = [{ - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250],[728, 90]], - } - }, - bids: [{ - "bidder": "kubient", - "params": { - "zoneid": "5fbb948f1e22b", - } - }] - }]; From d77d34bdfd3d1ccb68c40c4b38de34e61c8e475e Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Mon, 28 Jun 2021 18:43:33 +0300 Subject: [PATCH 12/15] fill bidResponse.vastXml for video --- modules/kubientBidAdapter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 2d7d816cc30..feb1e9a50ed 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -94,6 +94,10 @@ export const spec = { if (bid.meta && bid.meta.adomain && utils.isArray(bid.meta.adomain)) { bidResponse.meta.advertiserDomains = bid.meta.adomain; } + if (bid.mediaType === VIDEO) { + bidResponse.mediaType = VIDEO; + bidResponse.vastXml = bid.adm; + } bidResponses.push(bidResponse); }); }); From 6756c05cc62ad267e1fffbb486b4be3d4b02e131 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Mon, 28 Jun 2021 19:20:15 +0300 Subject: [PATCH 13/15] test-added-for-mediatype --- test/spec/modules/kubientBidAdapter_spec.js | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 514577ac1ef..845db0145e5 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -1,5 +1,6 @@ import { expect, assert } from 'chai'; import { spec } from 'modules/kubientBidAdapter.js'; +import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; describe('KubientAdapter', function () { let bidBanner = { @@ -239,6 +240,57 @@ describe('KubientAdapter', function () { }); }); + describe('interpretResponse Video', function () { + it('Should interpret response', function () { + const serverResponse = { + body: + { + seatbid: [ + { + bid: [ + { + bidId: '000', + price: 1.5, + adm: '
test
', + creativeId: 'creativeId', + w: 300, + h: 250, + mediaType: VIDEO, + cur: 'USD', + netRevenue: false, + ttl: 360, + meta: {adomain: ['google.com', 'yahoo.com']} + } + ] + } + ] + } + }; + let bannerResponses = spec.interpretResponse(serverResponse); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl', 'meta', 'mediaType', 'vastXml'); + expect(dataItem.requestId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].bidId); + expect(dataItem.cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(dataItem.ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(dataItem.creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].creativeId); + expect(dataItem.width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(dataItem.height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(dataItem.currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].cur); + expect(dataItem.netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(serverResponse.body.seatbid[0].bid[0].netRevenue); + expect(dataItem.ttl).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].ttl); + expect(dataItem.meta).to.exist.and.to.be.a('object'); + expect(dataItem.meta.advertiserDomains).to.exist.and.to.be.a('array').and.to.equal(serverResponse.body.seatbid[0].bid[0].meta.adomain); + expect(dataItem.mediaType).to.exist.and.to.equal(VIDEO); + expect(dataItem.vastXml).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].adm); + }); + + it('Should return no ad when not given a server response', function () { + const ads = spec.interpretResponse(null); + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + describe('getUserSyncs', function () { it('should register the sync iframe without gdpr', function () { let syncOptions = { From ff7b9acffa894347e1f70580a7dc94d32bdceaaf Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 29 Jun 2021 18:15:11 +0300 Subject: [PATCH 14/15] fixes-for-review --- modules/kubientBidAdapter.js | 2 +- test/spec/modules/kubientBidAdapter_spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index feb1e9a50ed..ae8c471bdc8 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -11,7 +11,7 @@ export const spec = { gvlid: VENDOR_ID, supportedMediaTypes: [ BANNER, VIDEO ], isBidRequestValid: function (bid) { - return !!(bid && bid.params); + return !!(bid && bid.params && bid.params.zoneid); }, buildRequests: function (validBidRequests, bidderRequest) { if (!validBidRequests || !bidderRequest) { diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 845db0145e5..503aec9e442 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -124,8 +124,8 @@ describe('KubientAdapter', function () { for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); - expect(adSlot.bidId).to.be.a('string'); - expect(adSlot.zoneId).to.be.a('string'); + expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId); + expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid); expect(adSlot.floor).to.be.a('number'); expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); @@ -165,8 +165,8 @@ describe('KubientAdapter', function () { for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'video', 'schain'); - expect(adSlot.bidId).to.be.a('string'); - expect(adSlot.zoneId).to.be.a('string'); + expect(adSlot.bidId).to.be.a('string').and.to.equal(bidVideo.bidId); + expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidVideo.params.zoneid); expect(adSlot.floor).to.be.a('number'); expect(adSlot.schain).to.be.an('object'); expect(adSlot.video).to.be.an('object'); From cfc026d106bbbde64c528287ec16232c246b804c Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Wed, 7 Jul 2021 18:10:45 +0300 Subject: [PATCH 15/15] added-requares --- modules/kubientBidAdapter.js | 7 ++++++- test/spec/modules/kubientBidAdapter_spec.js | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index ae8c471bdc8..6751a8a567c 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -11,7 +11,12 @@ export const spec = { gvlid: VENDOR_ID, supportedMediaTypes: [ BANNER, VIDEO ], isBidRequestValid: function (bid) { - return !!(bid && bid.params && bid.params.zoneid); + return !!( + bid && + bid.params && + bid.params.zoneid && + ((!bid.mediaTypes.video) || (bid.mediaTypes.video && bid.mediaTypes.video.playerSize && bid.mediaTypes.video.mimes && bid.mediaTypes.video.protocols)) + ); }, buildRequests: function (validBidRequests, bidderRequest) { if (!validBidRequests || !bidderRequest) { diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 503aec9e442..5449de0c4de 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -55,7 +55,8 @@ describe('KubientAdapter', function () { video: { context: 'instream', playerSize: [640, 480], - mimes: ['video/mp4'] + mimes: ['video/mp4'], + protocols: [1] } }, transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e61',