Skip to content

Commit

Permalink
Spotx Bid Adapter: add publisher support for cache.ignoreBidderCacheK…
Browse files Browse the repository at this point in the history
…ey (prebid#6413)

* Support ignoreBidderCacheKey in spotxBidAdapter

* Update spotxBidAdapter_spec.js

* Update spotxBidAdapter_spec.js

Co-authored-by: Nick Peceniak <npeceniak@spotx.tv>
  • Loading branch information
2 people authored and seergiioo6 committed Mar 23, 2021
1 parent ff1890d commit 5688fee
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
16 changes: 13 additions & 3 deletions modules/spotxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ export const spec = {
}
};

// If the publisher asks to ignore the bidder cache key we need to return the full vast xml
// so that it can be cached on the publishes specified server.
if (!!config.getConfig('cache') && !!config.getConfig('cache.url') && (config.getConfig('cache.ignoreBidderCacheKey') === true)) {
requestPayload['ext']['wrap_response'] = 0;
}

if (utils.getBidIdParameter('number_of_ads', bid.params)) {
requestPayload['ext']['number_of_ads'] = utils.getBidIdParameter('number_of_ads', bid.params);
}
Expand Down Expand Up @@ -336,14 +342,18 @@ export const spec = {
ttl: 360,
netRevenue: true,
channel_id: serverResponseBody.id,
cache_key: spotxBid.ext.cache_key,
vastUrl: 'https://search.spotxchange.com/ad/vast.html?key=' + spotxBid.ext.cache_key,
videoCacheKey: spotxBid.ext.cache_key,
mediaType: VIDEO,
width: spotxBid.w,
height: spotxBid.h
};

if (!!config.getConfig('cache') && !!config.getConfig('cache.url') && (config.getConfig('cache.ignoreBidderCacheKey') === true)) {
bid.vastXml = spotxBid.adm;
} else {
bid.cache_key = spotxBid.ext.cache_key;
bid.vastUrl = 'https://search.spotxchange.com/ad/vast.html?key=' + spotxBid.ext.cache_key
}

bid.meta = bid.meta || {};
if (spotxBid && spotxBid.adomain && spotxBid.adomain.length > 0) {
bid.meta.advertiserDomains = spotxBid.adomain;
Expand Down
28 changes: 26 additions & 2 deletions test/spec/modules/spotxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,32 @@ describe('the spotx adapter', function () {

expect(request.data.site.page).to.equal('prebid.js');
});

it('should set ext.wrap_response to 0 when cache url is set and ignoreBidderCacheKey is true', function() {
var request;

var origGetConfig = config.getConfig;
sinon.stub(config, 'getConfig').callsFake(function (key) {
if (key === 'cache') {
return {
url: 'prebidCacheLocation',
ignoreBidderCacheKey: true
};
}
if (key === 'cache.url') {
return 'prebidCacheLocation';
}
if (key === 'cache.ignoreBidderCacheKey') {
return true;
}
return origGetConfig.apply(config, arguments);
});

request = spec.buildRequests([bid], bidRequestObj)[0];

expect(request.data.ext.wrap_response).to.equal(0);
config.getConfig.restore();
});
});

describe('interpretResponse', function() {
Expand Down Expand Up @@ -469,7 +495,6 @@ describe('the spotx adapter', function () {
expect(responses[0].requestId).to.equal(123);
expect(responses[0].ttl).to.equal(360);
expect(responses[0].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123');
expect(responses[0].videoCacheKey).to.equal('cache123');
expect(responses[0].width).to.equal(400);
expect(responses[1].cache_key).to.equal('cache124');
expect(responses[1].channel_id).to.equal(12345);
Expand All @@ -483,7 +508,6 @@ describe('the spotx adapter', function () {
expect(responses[1].requestId).to.equal(124);
expect(responses[1].ttl).to.equal(360);
expect(responses[1].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache124');
expect(responses[1].videoCacheKey).to.equal('cache124');
expect(responses[1].width).to.equal(200);
});
});
Expand Down

0 comments on commit 5688fee

Please sign in to comment.