Skip to content

Commit

Permalink
support outbrain alias in zemanta adapter (#6203)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rok Sušnik authored Jan 21, 2021
1 parent e8b8be5 commit 6fc1017
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/zemantaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ const NATIVE_PARAMS = {

export const spec = {
code: BIDDER_CODE,
aliases: ['outbrain'],
supportedMediaTypes: [ NATIVE, BANNER ],
isBidRequestValid: (bid) => {
return (
!!config.getConfig('zemanta.bidderUrl') &&
(!!config.getConfig('zemanta.bidderUrl') || !!config.getConfig('outbrain.bidderUrl')) &&
!!utils.deepAccess(bid, 'params.publisher.id') &&
!!(bid.nativeParams || bid.sizes)
);
Expand All @@ -37,7 +38,7 @@ export const spec = {
const test = setOnAny(validBidRequests, 'params.test');
const publisher = setOnAny(validBidRequests, 'params.publisher');
const cur = CURRENCY;
const endpointUrl = config.getConfig('zemanta.bidderUrl');
const endpointUrl = config.getConfig('zemanta.bidderUrl') || config.getConfig('outbrain.bidderUrl');
const timeout = bidderRequest.timeout;

const imps = validBidRequests.map((bid, id) => {
Expand Down Expand Up @@ -136,7 +137,7 @@ export const spec = {
},
getUserSyncs: (syncOptions) => {
const syncs = [];
const syncUrl = config.getConfig('zemanta.usersyncUrl');
const syncUrl = config.getConfig('zemanta.usersyncUrl') || config.getConfig('outbrain.usersyncUrl');
if (syncOptions.pixelEnabled && syncUrl) {
syncs.push({
type: 'image',
Expand Down
28 changes: 28 additions & 0 deletions test/spec/modules/zemantaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ describe('Zemanta Adapter', function () {
}
expect(spec.isBidRequestValid(bid)).to.equal(false)
})
it('should succeed with outbrain config', function () {
const bid = {
bidder: 'zemanta',
params: {
publisher: {
id: 'publisher-id',
}
},
...nativeBidRequestParams,
}
config.resetConfig()
config.setConfig({
outbrain: {
bidderUrl: 'https://bidder-url.com',
}
})
expect(spec.isBidRequestValid(bid)).to.equal(true)
})
it('should fail if bidder url is not set', function () {
const bid = {
bidder: 'zemanta',
Expand Down Expand Up @@ -460,6 +478,16 @@ describe('Zemanta Adapter', function () {
const ret = spec.getUserSyncs({pixelEnabled: true})
expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}])
})
it('should return user sync if pixel enabled with outbrain config', function () {
config.resetConfig()
config.setConfig({
outbrain: {
usersyncUrl: 'https://usersync-url.com',
}
})
const ret = spec.getUserSyncs({pixelEnabled: true})
expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}])
})

it('should not return user sync if pixel disabled', function () {
const ret = spec.getUserSyncs({pixelEnabled: false})
Expand Down

0 comments on commit 6fc1017

Please sign in to comment.