Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Implemented passing key values feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhukovsky committed Jul 11, 2017
1 parent be01333 commit 28a32c9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/adapters/aol.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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({
Expand Down
16 changes: 16 additions & 0 deletions test/spec/adapters/aol_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 28a32c9

Please sign in to comment.