From 28a32c903c9371e9593247fb787ab24ac9f729c9 Mon Sep 17 00:00:00 2001 From: Zhukovsky Date: Wed, 5 Jul 2017 11:56:46 +0300 Subject: [PATCH] Implemented passing key values feature. --- src/adapters/aol.js | 20 +++++++++++++++++--- test/spec/adapters/aol_spec.js | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/adapters/aol.js b/src/adapters/aol.js index af6e81b924b..786321c3338 100644 --- a/src/adapters/aol.js +++ b/src/adapters/aol.js @@ -11,7 +11,7 @@ $$PREBID_GLOBAL$$.aolGlobals = { const AolAdapter = function AolAdapter() { let showCpmAdjustmentWarning = true; - const pubapiTemplate = template`${'protocol'}://${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'}${'bidfloor'};misc=${'misc'}`; + const pubapiTemplate = template`${'protocol'}://${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'}${'bidfloor'}${'keyValues'};misc=${'misc'}`; const nexageBaseApiTemplate = template`${'protocol'}://${'host'}/bidRequest?`; const nexageGetApiTemplate = template`dcn=${'dcn'}&pos=${'pos'}&cmd=bid${'ext'}`; const MP_SERVER_MAP = { @@ -155,12 +155,26 @@ const AolAdapter = function AolAdapter() { pageid: params.pageId || 0, sizeid: params.sizeId || 0, alias: params.alias || utils.getUniqueIdentifierStr(), - bidfloor: (typeof params.bidFloor !== 'undefined') - ? `;bidfloor=${params.bidFloor.toString()}` : '', + bidfloor: formatMarketplaceBidFloor(params.bidFloor), + keyValues: formatMarketplaceKeyValues(params.keyValues), misc: new Date().getTime() // cache busting }); } + function formatMarketplaceBidFloor(bidFloor) { + return (typeof bidFloor !== 'undefined') ? `;bidfloor=${bidFloor.toString()}` : ''; + } + + function formatMarketplaceKeyValues(keyValues) { + let formattedKeyValues = ''; + + utils._each(keyValues, (value, key) => { + formattedKeyValues += `;kv${key}=${encodeURIComponent(value)}`; + }); + + return formattedKeyValues; + } + function _buildNexageApiUrl(bid) { let {dcn, pos} = bid.params; let nexageApi = nexageBaseApiTemplate({ diff --git a/test/spec/adapters/aol_spec.js b/test/spec/adapters/aol_spec.js index 55f8ed249f3..3a13089295a 100644 --- a/test/spec/adapters/aol_spec.js +++ b/test/spec/adapters/aol_spec.js @@ -295,6 +295,22 @@ describe('AolAdapter', () => { })); expect(requests[0].url).to.contain('bidfloor=0.8'); }); + + it('should contain key values if keyValues param is present', () => { + adapter.callBids(createBidderRequest({ + params: { + placement: 1234567, + network: '9599.1', + keyValues: { + age: 25, + height: 3.42, + test: 'key' + } + } + })); + + expect(requests[0].url).to.contain('kvage=25;kvheight=3.42;kvtest=key'); + }); }); describe('Nexage api', () => {