Skip to content

Commit

Permalink
Automatad Bid Adapter: Support multiple bids in response (prebid#5699)
Browse files Browse the repository at this point in the history
* added automatad bid adapter

* added automatad bid adapter readme

* added automatad bidder adapter unit test

* updated maintainer email id for automatad adapter

* refactored automatadBidAdapter js

* refactored automatadBidAdapter unit test

* refactored automatadBidAdapter unit test

* added usersync code to automatad bid adapter

* Added unit test for onBidWon in automatadBidAdapter_spec

* removed trailing spaces

* removed trailing space

* changes for getUserSync function

* lint error fixes

* updated usersync url

* additional test for onBidWon function added

* added ajax stub in test

* updated winurl params

* lint fixes

* added adunitCode in bid request

* added test for adunit code

* add placement in impression object

* added code to interpret multiple bid response in seatbid
  • Loading branch information
kanchika-kapoor authored and BrightMountainMediaInc committed Sep 14, 2020
1 parent b7fe3d9 commit fa354dc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
30 changes: 16 additions & 14 deletions modules/automatadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,22 @@ export const spec = {
const bidResponses = []
const response = (serverResponse || {}).body

if (response && response.seatbid && response.seatbid.length === 1 && response.seatbid[0].bid && response.seatbid[0].bid.length) {
response.seatbid[0].bid.forEach(bid => {
bidResponses.push({
requestId: bid.impid,
cpm: bid.price,
ad: bid.adm,
adDomain: bid.adomain[0],
currency: DEFAULT_CURRENCY,
ttl: DEFAULT_BID_TTL,
creativeId: bid.crid,
width: bid.w,
height: bid.h,
netRevenue: DEFAULT_NET_REVENUE,
nurl: bid.nurl,
if (response && response.seatbid && response.seatbid[0].bid && response.seatbid[0].bid.length) {
response.seatbid.forEach(bidObj => {
bidObj.bid.forEach(bid => {
bidResponses.push({
requestId: bid.impid,
cpm: bid.price,
ad: bid.adm,
adDomain: bid.adomain[0],
currency: DEFAULT_CURRENCY,
ttl: DEFAULT_BID_TTL,
creativeId: bid.crid,
width: bid.w,
height: bid.h,
netRevenue: DEFAULT_NET_REVENUE,
nurl: bid.nurl,
})
})
})
} else {
Expand Down
50 changes: 50 additions & 0 deletions test/spec/modules/automatadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,56 @@ describe('automatadBidAdapter', function () {
expect(result).to.be.an('array').that.is.not.empty
})

it('should interpret multiple bids in seatbid', function () {
let multipleBidResponse = [{
'body': {
'id': 'abc-321',
'seatbid': [
{
'bid': [
{
'adm': '<!-- creative code -->',
'adomain': [
'someAdDomain'
],
'crid': 123,
'h': 600,
'id': 'bid1',
'impid': 'imp1',
'nurl': 'https://example/win',
'price': 0.5,
'w': 300
}
]
}, {
'bid': [
{
'adm': '<!-- creative code -->',
'adomain': [
'someAdDomain'
],
'crid': 321,
'h': 600,
'id': 'bid1',
'impid': 'imp2',
'nurl': 'https://example/win',
'price': 0.5,
'w': 300
}
]
}
]
}
}]
let result = spec.interpretResponse(multipleBidResponse[0]).map(bid => {
const {requestId} = bid;
return [ requestId ];
});

assert.equal(result.length, 2);
assert.deepEqual(result, [[ 'imp1' ], [ 'imp2' ]]);
})

it('handles empty bid response', function () {
let response = {
body: ''
Expand Down

0 comments on commit fa354dc

Please sign in to comment.