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. #568

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 5 additions & 13 deletions src/adapters/aardvark.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ var AardvarkAdapter = function AardvarkAdapter() {
})[0];

var returnedBidIDs = {};
var placementIDmap = {};

if (rtkResponseObj.length > 0) {
rtkResponseObj.forEach(function (bid) {
Expand All @@ -68,7 +67,7 @@ var AardvarkAdapter = function AardvarkAdapter() {
return r.params.sc === bid.id;
})[0];
if (currentBid) {
var bidResponse = bidfactory.createBid(1);
var bidResponse = bidfactory.createBid(1, currentBid);
bidResponse.bidderCode = "aardvark";
bidResponse.cpm = bid.cpm;
bidResponse.ad = bid.adm;
Expand All @@ -86,19 +85,12 @@ var AardvarkAdapter = function AardvarkAdapter() {
}

//All bids are back - lets add a bid response for anything that did not receive a bid.
var initialSC = [];
bidsObj.bids.forEach(function (bid) {
initialSC.push(bid.params.sc);
placementIDmap[bid.params.sc] = bid.placementCode;
});

let difference = initialSC.filter(x => Object.keys(returnedBidIDs).indexOf(x) === -1);
let difference = bidsObj.bids.filter(x => Object.keys(returnedBidIDs).indexOf(x.params.sc) === -1);

difference.forEach(function (shortcode) {
var bidResponse = bidfactory.createBid(2);
var placementcode = placementIDmap[shortcode];
difference.forEach(function (bidRequest) {
var bidResponse = bidfactory.createBid(2, bidRequest);
bidResponse.bidderCode = "aardvark";
bidmanager.addBidResponse(placementcode, bidResponse);
bidmanager.addBidResponse(bidRequest.placementCode, bidResponse);
});


Expand Down
10 changes: 10 additions & 0 deletions test/spec/adapters/aardvark_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ describe('aardvark adapter', () => {
expect(secondPlacementCode).to.eql('bar');
});

it('should include bid request bidId as the adId', () => {
expect(firstBid).to.have.property('adId', 'bidId1');
expect(secondBid).to.have.property('adId', 'bidId2');
});

it('should have a good statusCode', () => {
expect(firstBid.getStatusCode()).to.eql(1);
expect(secondBid.getStatusCode()).to.eql(1);
Expand Down Expand Up @@ -176,6 +181,11 @@ describe('aardvark adapter', () => {
expect(secondBid.getStatusCode()).to.eql(2);
});

it('should include bid request bidId as the adId', () => {
expect(firstBid).to.have.property('adId', 'bidId1');
expect(secondBid).to.have.property('adId', 'bidId2');
});

it('should pass the correct placement code as first param', () => {
let firstPlacementCode = bidManager.addBidResponse.firstCall.args[0];
let secondPlacementCode = bidManager.addBidResponse.secondCall.args[0];
Expand Down