Skip to content

Commit

Permalink
Fix for #196
Browse files Browse the repository at this point in the history
  • Loading branch information
mkendall07 committed Apr 1, 2016
1 parent 1aa69d2 commit a13c57f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions src/bidmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,8 @@ exports.getKeyValueTargetingPairs = function (bidderCode, custBidObj) {
var keyValues = {};
var bidder_settings = pbjs.bidderSettings || {};

//1) set keys from specific bidder setting if they exist
if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) {
setKeys(keyValues, bidder_settings[bidderCode], custBidObj);
custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid;
}

//2) set keys from standard setting. NOTE: this API doesn't seeem to be in use by any Adapter currently
else if (defaultBidderSettingsMap[bidderCode]) {
setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj);
custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid;
}

//3) set the keys from "standard" setting or from prebid defaults
else if (custBidObj && bidder_settings) {
if (custBidObj && bidder_settings) {
if (!bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]) {
bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD] = {
adserverTargeting: [
Expand Down Expand Up @@ -254,6 +242,18 @@ exports.getKeyValueTargetingPairs = function (bidderCode, custBidObj) {
setKeys(keyValues, bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD], custBidObj);
}

//1) set keys from specific bidder setting if they exist
if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) {
setKeys(keyValues, bidder_settings[bidderCode], custBidObj);
custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid;
}

//2) set keys from standard setting. NOTE: this API doesn't seeem to be in use by any Adapter currently
else if (defaultBidderSettingsMap[bidderCode]) {
setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj);
custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid;
}

return keyValues;
};

Expand Down
2 changes: 1 addition & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function buildBidResponse(bidArray) {
if (bid.alwaysUseBid && bidClone.adserverTargeting) { // add the bid if alwaysUse and bid has returned
// push key into targeting
pb_targetingMap[bidClone.adUnitCode] = utils.extend(pb_targetingMap[bidClone.adUnitCode], bidClone.adserverTargeting);
} else if (bid.cpm && bid.cpm > 0) {
} if (bid.cpm && bid.cpm > 0) {
//else put into auction array if cpm > 0
bidArrayTargeting.push({
cpm: bid.cpm,
Expand Down
2 changes: 1 addition & 1 deletion test/spec/bidmanager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ var bidmanager = require('../../src/bidmanager');
}
};

var expected = {"hb_bidder": bidderCode, "hb_adid": adId,"hb_pb": 15.0 };
var expected = {"hb_bidder": bidderCode, "hb_adid": adId,"hb_pb": 15.0, "hb_size":"300x250" };
var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid);
assert.deepEqual(response, expected);

Expand Down

0 comments on commit a13c57f

Please sign in to comment.