Skip to content

Commit

Permalink
Added dynamic ttl property for One Display and One Mobile. (prebid#2004)
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhukovsky authored and chanand committed Jan 18, 2018
1 parent 5464ad9 commit 859b38d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
12 changes: 8 additions & 4 deletions modules/aolBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const MP_SERVER_MAP = {
as: 'adserver-as.adtech.advertising.com'
};
const NEXAGE_SERVER = 'hb.nexage.com';
const BID_RESPONSE_TTL = 300;
const ONE_DISPLAY_TTL = 60;
const ONE_MOBILE_TTL = 3600;

$$PREBID_GLOBAL$$.aolGlobals = {
pixelsDropped: false
Expand Down Expand Up @@ -224,7 +225,7 @@ function _parseBidResponse(response, bidRequest) {
currency: response.cur,
dealId: bidData.dealid,
netRevenue: true,
ttl: BID_RESPONSE_TTL
ttl: bidRequest.ttl
};
}

Expand Down Expand Up @@ -274,21 +275,24 @@ function formatBidRequest(endpointCode, bid) {
case AOL_ENDPOINTS.DISPLAY.GET:
bidRequest = {
url: _buildMarketplaceUrl(bid),
method: 'GET'
method: 'GET',
ttl: ONE_DISPLAY_TTL
};
break;

case AOL_ENDPOINTS.MOBILE.GET:
bidRequest = {
url: _buildOneMobileGetUrl(bid),
method: 'GET'
method: 'GET',
ttl: ONE_MOBILE_TTL
};
break;

case AOL_ENDPOINTS.MOBILE.POST:
bidRequest = {
url: _buildOneMobileBaseUrl(bid),
method: 'POST',
ttl: ONE_MOBILE_TTL,
data: bid.params,
options: {
contentType: 'application/json',
Expand Down
19 changes: 15 additions & 4 deletions test/spec/modules/aolBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ let getPixels = () => {
};

describe('AolAdapter', () => {
const MARKETPLACE_URL = 'adserver-us.adtech.advertising.com/pubapi/3.0/';
const NEXAGE_URL = 'hb.nexage.com/bidRequest?';
const MARKETPLACE_URL = '//adserver-us.adtech.advertising.com/pubapi/3.0/';
const NEXAGE_URL = '//hb.nexage.com/bidRequest?';
const ONE_DISPLAY_TTL = 60;
const ONE_MOBILE_TTL = 3600;

function createCustomBidRequest({bids, params} = {}) {
var bidderRequest = getDefaultBidRequest();
Expand All @@ -98,7 +100,8 @@ describe('AolAdapter', () => {
bidderSettingsBackup = $$PREBID_GLOBAL$$.bidderSettings;
bidRequest = {
bidderCode: 'test-bidder-code',
bidId: 'bid-id'
bidId: 'bid-id',
ttl: 1234
};
bidResponse = {
body: getDefaultBidResponse()
Expand All @@ -125,7 +128,7 @@ describe('AolAdapter', () => {
currency: 'USD',
dealId: 'deal-id',
netRevenue: true,
ttl: 300
ttl: bidRequest.ttl
});
});

Expand Down Expand Up @@ -355,6 +358,13 @@ describe('AolAdapter', () => {
let [request] = spec.buildRequests(bidRequest.bids);
expect(request.url).to.contain('kvage=25;kvheight=3.42;kvtest=key');
});

it('should return request object for One Display when configuration is present', () => {
let bidRequest = getDefaultBidRequest();
let [request] = spec.buildRequests(bidRequest.bids);
expect(request.method).to.equal('GET');
expect(request.ttl).to.equal(ONE_DISPLAY_TTL);
});
});

describe('One Mobile', () => {
Expand Down Expand Up @@ -454,6 +464,7 @@ describe('AolAdapter', () => {
let [request] = spec.buildRequests(bidRequest.bids);
expect(request.url).to.contain(NEXAGE_URL);
expect(request.method).to.equal('POST');
expect(request.ttl).to.equal(ONE_MOBILE_TTL);
expect(request.data).to.deep.equal(bidConfig);
expect(request.options).to.deep.equal({
contentType: 'application/json',
Expand Down

0 comments on commit 859b38d

Please sign in to comment.