Skip to content

Commit

Permalink
Smart Ad Server: Fix bug when multi bids (prebid#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacedragoon authored and dluxemburg committed Jul 17, 2018
1 parent 8c26749 commit a9a793f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
49 changes: 25 additions & 24 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,31 @@ export const spec = {
// to find which one the ad server needs

// pull requested transaction ID from bidderRequest.bids[].transactionId
var bid = validBidRequests[0];
const payload = {
siteid: bid.params.siteId,
pageid: bid.params.pageId,
formatid: bid.params.formatId,
currencyCode: config.getConfig('currency.adServerCurrency'),
bidfloor: bid.params.bidfloor || 0.0,
targeting: bid.params.target && bid.params.target != '' ? bid.params.target : undefined,
tagId: bid.adUnitCode,
sizes: bid.sizes.map(size => ({
w: size[0],
h: size[1]
})),
pageDomain: utils.getTopWindowUrl(),
transactionId: bid.transactionId,
timeout: config.getConfig('bidderTimeout'),
bidId: bid.bidId
};
const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: bid.params.domain + '/prebid/v1',
data: payloadString,
};
return validBidRequests.map(bid => {
var payload = {
siteid: bid.params.siteId,
pageid: bid.params.pageId,
formatid: bid.params.formatId,
currencyCode: config.getConfig('currency.adServerCurrency'),
bidfloor: bid.params.bidfloor || 0.0,
targeting: bid.params.target && bid.params.target != '' ? bid.params.target : undefined,
tagId: bid.adUnitCode,
sizes: bid.sizes.map(size => ({
w: size[0],
h: size[1]
})),
pageDomain: utils.getTopWindowUrl(),
transactionId: bid.transactionId,
timeout: config.getConfig('bidderTimeout'),
bidId: bid.bidId
};
var payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: bid.params.domain + '/prebid/v1',
data: payloadString,
};
});
},
/**
* Unpack the response from the server into a list of bids.
Expand Down
8 changes: 4 additions & 4 deletions test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ describe('Smart ad server bid adapter tests', () => {
}
});
const request = spec.buildRequests(DEFAULT_PARAMS);
expect(request).to.have.property('url').and.to.equal('http://prg.smartadserver.com/prebid/v1');
expect(request).to.have.property('method').and.to.equal('POST');
const requestContent = JSON.parse(request.data);
expect(request[0]).to.have.property('url').and.to.equal('http://prg.smartadserver.com/prebid/v1');
expect(request[0]).to.have.property('method').and.to.equal('POST');
const requestContent = JSON.parse(request[0].data);
expect(requestContent).to.have.property('siteid').and.to.equal('1234');
expect(requestContent).to.have.property('pageid').and.to.equal('5678');
expect(requestContent).to.have.property('formatid').and.to.equal('90');
Expand All @@ -95,7 +95,7 @@ describe('Smart ad server bid adapter tests', () => {

it('Verify parse response', () => {
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse(BID_RESPONSE, request);
const bids = spec.interpretResponse(BID_RESPONSE, request[0]);
expect(bids).to.have.lengthOf(1);
const bid = bids[0];
expect(bid.cpm).to.equal(12);
Expand Down

0 comments on commit a9a793f

Please sign in to comment.