From 5a46099fb4614ad0c74e1589e9abe52233e7fd84 Mon Sep 17 00:00:00 2001 From: Tomasz Mielcarz Date: Thu, 27 Apr 2023 12:50:19 +0200 Subject: [PATCH 1/4] banner support added --- modules/adrinoBidAdapter.js | 15 +++++-- test/spec/modules/adrinoBidAdapter_spec.js | 52 +++++++++++++++++++++- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/modules/adrinoBidAdapter.js b/modules/adrinoBidAdapter.js index efd23761bfd..9825c5701d7 100644 --- a/modules/adrinoBidAdapter.js +++ b/modules/adrinoBidAdapter.js @@ -1,6 +1,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {triggerPixel} from '../src/utils.js'; -import {NATIVE} from '../src/mediaTypes.js'; +import {NATIVE, BANNER} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; @@ -12,7 +12,7 @@ const GVLID = 1072; export const spec = { code: BIDDER_CODE, gvlid: GVLID, - supportedMediaTypes: [NATIVE], + supportedMediaTypes: [NATIVE, BANNER], getBidderConfig: function (property) { return config.getConfig(`${BIDDER_CODE}.${property}`); @@ -24,7 +24,7 @@ export const spec = { !!(bid.params.hash) && (typeof bid.params.hash === 'string') && !!(bid.mediaTypes) && - Object.keys(bid.mediaTypes).includes(NATIVE) && + (Object.keys(bid.mediaTypes).includes(NATIVE) || Object.keys(bid.mediaTypes).includes(BANNER)) && (bid.bidder === BIDDER_CODE); }, @@ -36,13 +36,20 @@ export const spec = { for (let i = 0; i < validBidRequests.length; i++) { let requestData = { bidId: validBidRequests[i].bidId, - nativeParams: validBidRequests[i].nativeParams, placementHash: validBidRequests[i].params.hash, userId: validBidRequests[i].userId, referer: bidderRequest.refererInfo.page, userAgent: navigator.userAgent, } + if (validBidRequests[i].sizes != null && validBidRequests[i].sizes.length > 0) { + requestData.bannerParams = { sizes: validBidRequests[i].sizes }; + } + + if (validBidRequests[i].nativeParams != null) { + requestData.nativeParams = validBidRequests[i].nativeParams; + } + if (bidderRequest && bidderRequest.gdprConsent) { requestData.gdprConsent = { consentString: bidderRequest.gdprConsent.consentString, diff --git a/test/spec/modules/adrinoBidAdapter_spec.js b/test/spec/modules/adrinoBidAdapter_spec.js index 577dd3e9164..9c5a6ca6139 100644 --- a/test/spec/modules/adrinoBidAdapter_spec.js +++ b/test/spec/modules/adrinoBidAdapter_spec.js @@ -43,7 +43,7 @@ describe('adrinoBidAdapter', function () { it('should return false when unsupported media type is requested', function () { const bid = { ...validBid }; - bid.mediaTypes = { banner: { sizes: [[300, 250]] } }; + bid.mediaTypes = { video: {} }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -54,7 +54,46 @@ describe('adrinoBidAdapter', function () { }); }); - describe('buildRequests', function () { + describe('buildDisplayRequest', function () { + const bidRequest = { + bidder: 'adrino', + params: { + hash: 'abcdef123456' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [970, 250]] + } + }, + sizes: [[300, 250], [970, 250]], + userId: { criteoId: '2xqi3F94aHdwWnM3', pubcid: '3ec0b202-7697' }, + adUnitCode: 'adunit-code', + bidId: '12345678901234', + bidderRequestId: '98765432109876', + auctionId: '01234567891234', + }; + + it('should build the request correctly', function () { + const result = spec.buildRequests( + [ bidRequest ], + { refererInfo: { page: 'http://example.com/' } } + ); + expect(result.length).to.equal(1); + expect(result[0].method).to.equal('POST'); + expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bids/'); + expect(result[0].data[0].bidId).to.equal('12345678901234'); + expect(result[0].data[0].placementHash).to.equal('abcdef123456'); + expect(result[0].data[0].referer).to.equal('http://example.com/'); + expect(result[0].data[0].userAgent).to.equal(navigator.userAgent); + expect(result[0].data[0]).to.have.property('bannerParams'); + expect(result[0].data[0].bannerParams.sizes.length).to.equal(2); + expect(result[0].data[0]).to.have.property('userId'); + expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3'); + expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697'); + }); + }); + + describe('buildNativeRequest', function () { const bidRequest = { bidder: 'adrino', params: { @@ -71,6 +110,15 @@ describe('adrinoBidAdapter', function () { } } }, + nativeParams: { + title: { + required: true + }, + image: { + required: true, + sizes: [[300, 150], [300, 210]] + } + }, userId: { criteoId: '2xqi3F94aHdwWnM3', pubcid: '3ec0b202-7697' }, adUnitCode: 'adunit-code', bidId: '12345678901234', From 92a7bac7ced700273d03ce3e8cd7ba6e3d5fc04e Mon Sep 17 00:00:00 2001 From: Tomasz Mielcarz Date: Thu, 27 Apr 2023 13:21:22 +0200 Subject: [PATCH 2/4] test name change --- test/spec/modules/adrinoBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adrinoBidAdapter_spec.js b/test/spec/modules/adrinoBidAdapter_spec.js index 9c5a6ca6139..9a3775a205e 100644 --- a/test/spec/modules/adrinoBidAdapter_spec.js +++ b/test/spec/modules/adrinoBidAdapter_spec.js @@ -54,7 +54,7 @@ describe('adrinoBidAdapter', function () { }); }); - describe('buildDisplayRequest', function () { + describe('buildBannerRequest', function () { const bidRequest = { bidder: 'adrino', params: { From 28ae4d667da77395f9648f4d3076fb9b1eeab50e Mon Sep 17 00:00:00 2001 From: Tomasz Mielcarz Date: Thu, 27 Apr 2023 13:44:00 +0200 Subject: [PATCH 3/4] not my test failed --- test/spec/modules/adrinoBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adrinoBidAdapter_spec.js b/test/spec/modules/adrinoBidAdapter_spec.js index 9a3775a205e..76265c1abe2 100644 --- a/test/spec/modules/adrinoBidAdapter_spec.js +++ b/test/spec/modules/adrinoBidAdapter_spec.js @@ -67,7 +67,7 @@ describe('adrinoBidAdapter', function () { }, sizes: [[300, 250], [970, 250]], userId: { criteoId: '2xqi3F94aHdwWnM3', pubcid: '3ec0b202-7697' }, - adUnitCode: 'adunit-code', + adUnitCode: 'adunit-code-1', bidId: '12345678901234', bidderRequestId: '98765432109876', auctionId: '01234567891234', From 971a5ced8505acb385e6c25ccbfe8007972e6839 Mon Sep 17 00:00:00 2001 From: Tomasz Mielcarz Date: Thu, 27 Apr 2023 14:08:50 +0200 Subject: [PATCH 4/4] not my test failed --- test/spec/modules/adrinoBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adrinoBidAdapter_spec.js b/test/spec/modules/adrinoBidAdapter_spec.js index 76265c1abe2..72f006d4e4a 100644 --- a/test/spec/modules/adrinoBidAdapter_spec.js +++ b/test/spec/modules/adrinoBidAdapter_spec.js @@ -67,7 +67,7 @@ describe('adrinoBidAdapter', function () { }, sizes: [[300, 250], [970, 250]], userId: { criteoId: '2xqi3F94aHdwWnM3', pubcid: '3ec0b202-7697' }, - adUnitCode: 'adunit-code-1', + adUnitCode: 'adunit-code-2', bidId: '12345678901234', bidderRequestId: '98765432109876', auctionId: '01234567891234',