Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set bid response ID to bid request ID for aardvark #543

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5e52274
Facebook Audience Network adapter (#483)
johngeorgewright Aug 8, 2016
ff3c2f0
Add UnderdogMedia Adatper (#491)
baragona Aug 9, 2016
80d89d7
Add UT endpoint adapter (#507)
matthewlane Aug 12, 2016
f6ba404
getLoadTimeDistribution-sorting-fix (#510)
CLKeenan Aug 12, 2016
21528be
prevent externalOneTimeCallback from being called more than once (#505)
snapwich Aug 12, 2016
e5b9b35
Save winning bid (#480)
d6u Aug 12, 2016
d047f07
Exclude polyfill.js from code coverage (#522)
Aug 12, 2016
6bd07b5
489 timeout not tracked (#500)
therazor Aug 12, 2016
52c1be1
Pass keywords parameter to bid request (#524)
matthewlane Aug 13, 2016
73ffdc5
Set bid response ID to bid request ID (#526)
matthewlane Aug 16, 2016
ce2f08d
Remove unused imports from underdogmedia spec. (#530)
nanek Aug 17, 2016
25e15bb
Queue bid requests (#477)
Aug 17, 2016
dd1af59
Use cross-browser parseInt function (#536)
matthewlane Aug 17, 2016
2bead0c
Rubicon project fix remove ad unit iteration (#535)
Aug 17, 2016
f9045cc
bid responses have adId so remove matching to request on best effort …
Aug 17, 2016
edea78e
#494 fix. AUCTION_END event was getting emitted in multiple scenarios…
jaiminpanchal27 Aug 17, 2016
4d5a5d5
Memeglobal prebid (#504)
naamushka Aug 17, 2016
e7eb5f4
Add tests for aardvark adapter. (#529)
nanek Aug 17, 2016
bcc3356
allows multiple bids to be registered per a slot, related to #496 (#503)
snapwich Aug 17, 2016
b71006e
Add tests for triplelift adapter. (#531)
nanek Aug 17, 2016
e1cf92b
Prebid 0.12.0 release
Aug 17, 2016
a3656a0
Set bid response ID to bid request ID for aardvark.
nanek Aug 19, 2016
ddc6c11
Fix placementCode reference.
nanek Aug 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add UnderdogMedia Adatper (#491)
  • Loading branch information
baragona authored and Nate Guisinger committed Aug 9, 2016
commit ff3c2f01c25df0b698ed3406ca3f01a32c31f916
1 change: 1 addition & 0 deletions adapters.json
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
"brightcom",
"wideorbit",
"jcm",
"underdogmedia",
{
"appnexus": {
"alias": "brealtime"
75 changes: 75 additions & 0 deletions src/adapters/underdogmedia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
var bidfactory = require('../bidfactory.js');
var bidmanager = require('../bidmanager.js');
var adloader = require('../adloader.js');
var utils = require('../utils.js');

var UnderdogMediaAdapter = function UnderdogMediaAdapter() {

var getJsStaticUrl = window.location.protocol + '//rtb.udmserve.net/udm_header_lib.js';

function _callBids(params) {
if (typeof window.udm_header_lib === 'undefined') {
adloader.loadScript(getJsStaticUrl, function () { bid(params); });
} else {
bid(params);
}
}

function bid(params) {
var bids = params.bids;
for (var i = 0; i < bids.length; i++) {
var bidRequest = bids[i];
var callback = bidResponseCallback(bidRequest);
var udmBidRequest = new window.udm_header_lib.BidRequest({
sizes: bidRequest.sizes,
siteId: bidRequest.params.siteId,
bidfloor: bidRequest.params.bidfloor,
placementCode: bidRequest.placementCode,
callback: callback
});
udmBidRequest.send();
}
}

function bidResponseCallback(bid) {
return function (bidResponse) {
bidResponseAvailable(bid, bidResponse);
};
}

function bidResponseAvailable(bidRequest, bidResponse) {
if(bidResponse.bids.length > 0){
for(var i = 0; i < bidResponse.bids.length; i++){
var udm_bid = bidResponse.bids[i];
var bid = bidfactory.createBid(1);
bid.bidderCode = bidRequest.bidder;
bid.cpm = udm_bid.cpm;
bid.width = udm_bid.width;
bid.height = udm_bid.height;

if(udm_bid.ad_url !== undefined){
bid.adUrl = udm_bid.ad_url;
}
else if(udm_bid.ad_html !== undefined){
bid.ad = udm_bid.ad_html;
}else{
utils.logMessage('Underdogmedia bid is lacking both ad_url and ad_html, skipping bid');
continue;
}

bidmanager.addBidResponse(bidRequest.placementCode, bid);
}
}else{
var nobid = bidfactory.createBid(2);
nobid.bidderCode = bidRequest.bidder;
bidmanager.addBidResponse(bidRequest.placementCode, nobid);
}
}

return {
callBids: _callBids
};

};

module.exports = UnderdogMediaAdapter;
138 changes: 138 additions & 0 deletions test/spec/adapters/underdogmedia_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/* jshint -W030 */

import Adapter from '../../../src/adapters/underdogmedia';
import bidManager from '../../../src/bidmanager';
import {parse as parseURL} from 'url';
import {parse as parseQuery} from 'qs';
import {expect} from 'chai';

describe('underdog media adapter test', () => {

let adapter;
let server;

// Minimal stub implementation of underdog media header bid API
// This will prevent the need to load underdog's static library, and to make requests to underdog's server
window.udm_header_lib = {

BidRequest: function(options){
return {
send: function(){
var siteId = options.siteId;
if(siteId == 10272){
// Only bid on this particular site id
var bids = [];
for(var i = 0; i < options.sizes.length; i++){
var size = options.sizes[i];
bids.push({
cpm: 3.14,
ad_html: `Ad HTML for site ID ${siteId} size ${size[0]}x${size[1]}`,
width: size[0],
height: size[1]
});
}
options.callback({
bids: bids
});
} else {
options.callback({
bids: []
});
}

}
};
}

};

// The third bid here is an invalid site id and should return a 'no-bid'.
function request() {
adapter.callBids({
bidderCode: 'underdogmedia',
bids: [
{
bidder: 'underdogmedia',
adUnitCode: 'foo',
sizes: [[728, 90]],
params: {
siteId: '10272'
}
},
{
bidder: 'underdogmedia',
adUnitCode: 'bar',
sizes: [[300, 250]],
params: {
siteId: '10272'
}
},
{
bidder: 'underdogmedia',
adUnitCode: 'nothing',
sizes: [[160, 600]],
params: {
siteId: '31337'
}
}
]
});
}

beforeEach(() => {
adapter = new Adapter();
});

afterEach(() => {
});

describe('adding bids to the manager', () => {

let firstBid;
let secondBid;
let thirdBid;

beforeEach(() => {
sinon.stub(bidManager, 'addBidResponse');
request();
firstBid = bidManager.addBidResponse.firstCall.args[1];
secondBid = bidManager.addBidResponse.secondCall.args[1];
thirdBid = bidManager.addBidResponse.thirdCall.args[1];
});

afterEach(() => {
bidManager.addBidResponse.restore();
});

it('will add a bid object for each bid', () => {
sinon.assert.calledThrice(bidManager.addBidResponse);
});

it('will add the ad html to the bid object', () => {
expect(firstBid).to.have.property('ad', 'Ad HTML for site ID 10272 size 728x90');
expect(secondBid).to.have.property('ad', 'Ad HTML for site ID 10272 size 300x250');
expect(thirdBid).to.not.have.property('ad');
});

it('will have the right size attached', () => {
expect(firstBid).to.have.property('width', 728);
expect(firstBid).to.have.property('height', 90);
expect(secondBid).to.have.property('width', 300);
expect(secondBid).to.have.property('height', 250);
});

it('will add the CPM to the bid object', () => {
expect(firstBid).to.have.property('cpm', 3.14);
expect(secondBid).to.have.property('cpm', 3.14);
expect(thirdBid).to.not.have.property('cpm');
});

it('will add the bidder code to the bid object', () => {
expect(firstBid).to.have.property('bidderCode', 'underdogmedia');
expect(secondBid).to.have.property('bidderCode', 'underdogmedia');
expect(thirdBid).to.have.property('bidderCode', 'underdogmedia');
});

});

});