Skip to content

Commit

Permalink
Adrino Bid Adapter: banner support added (prebid#9860)
Browse files Browse the repository at this point in the history
* banner support added

* test name change

* not my test failed

* not my test failed

---------

Co-authored-by: Tomasz Mielcarz <tomasz.mielcarz@adrino.pl>
  • Loading branch information
2 people authored and jorgeluisrocha committed May 18, 2023
1 parent 7907213 commit 32d6023
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
15 changes: 11 additions & 4 deletions modules/adrinoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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}`);
Expand All @@ -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);
},

Expand All @@ -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,
Expand Down
52 changes: 50 additions & 2 deletions test/spec/modules/adrinoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -54,7 +54,46 @@ describe('adrinoBidAdapter', function () {
});
});

describe('buildRequests', function () {
describe('buildBannerRequest', 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-2',
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: {
Expand All @@ -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',
Expand Down

0 comments on commit 32d6023

Please sign in to comment.