Skip to content

Commit

Permalink
Adhese Bid Adapter: Configurable vast as url (prebid#7659)
Browse files Browse the repository at this point in the history
* adpod category support test

* Revert "adpod category support test"

This reverts commit 70a3cf2.

* adpod category support test

* Revert "adpod category support test"

This reverts commit 70a3cf2.

* Adhese bid adapter: make the vastContentAsUrl setting configurable

Co-authored-by: Tim Sturtewagen <tim@adhese.com>
Co-authored-by: Paweł L <pawel.lankocz@adhese.eu>
Co-authored-by: westerschmal <30859973+westerschmal@users.noreply.github.com>
  • Loading branch information
4 people authored and Chris Pabst committed Jan 10, 2022
1 parent abe45a4 commit 1c1ed18
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
9 changes: 7 additions & 2 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';

const BIDDER_CODE = 'adhese';
const GVLID = 553;
Expand All @@ -20,11 +21,15 @@ export const spec = {
if (validBidRequests.length === 0) {
return null;
}

const { gdprConsent, refererInfo } = bidderRequest;

const adheseConfig = config.getConfig('adhese');
const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {};
const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {};
const commonParams = { ...gdprParams, ...refererParams };
const globalCustomParams = (adheseConfig && adheseConfig.globalTargets) ? cleanTargets(adheseConfig.globalTargets) : {};
const commonParams = { ...globalCustomParams, ...gdprParams, ...refererParams };
const vastContentAsUrl = !(adheseConfig && adheseConfig.vastContentAsUrl == false);

const slots = validBidRequests.map(bid => ({
slotname: bidToSlotName(bid),
Expand All @@ -34,7 +39,7 @@ export const spec = {
const payload = {
slots: slots,
parameters: commonParams,
vastContentAsUrl: true,
vastContentAsUrl: vastContentAsUrl,
user: {
ext: {
eids: getEids(validBidRequests),
Expand Down
28 changes: 27 additions & 1 deletion test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import {spec} from 'modules/adheseBidAdapter.js';
import {config} from 'src/config.js';

const BID_ID = 456;
const TTL = 360;
Expand Down Expand Up @@ -131,12 +132,21 @@ describe('AdheseAdapter', function () {
expect(JSON.parse(req.data)).to.not.have.key('eids');
});

it('should request vast content as url', function () {
it('should request vast content as url by default', function () {
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).vastContentAsUrl).to.equal(true);
});

it('should request vast content as markup when configured', function () {
sinon.stub(config, 'getConfig').withArgs('adhese').returns({ vastContentAsUrl: false });

let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).vastContentAsUrl).to.equal(false);
config.getConfig.restore();
});

it('should include bids', function () {
let bid = minimalBid();
let req = spec.buildRequests([ bid ], bidderRequest);
Expand All @@ -155,6 +165,22 @@ describe('AdheseAdapter', function () {

expect(req.url).to.equal('https://ads-demo.adhese.com/json');
});

it('should include params specified in the config', function () {
sinon.stub(config, 'getConfig').withArgs('adhese').returns({ globalTargets: { 'tl': [ 'all' ] } });
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).parameters).to.deep.include({ 'tl': [ 'all' ] });
config.getConfig.restore();
});

it('should give priority to bid params over config params', function () {
sinon.stub(config, 'getConfig').withArgs('adhese').returns({ globalTargets: { 'xt': ['CONFIG_CONSENT_STRING'] } });
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).parameters).to.deep.include({ 'xt': [ 'CONSENT_STRING' ] });
config.getConfig.restore();
});
});

describe('interpretResponse', () => {
Expand Down

0 comments on commit 1c1ed18

Please sign in to comment.