Skip to content

Commit

Permalink
Automatad Bid Adapter: make placementId param optional (#8269)
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

* added bid meta with advertiserDomains

* endpoint url changes

* added format changes

* macro substitution change added

* make placementId optional

* lint the code
  • Loading branch information
Kanchika - Automatad authored May 3, 2022
1 parent 49118b8 commit 0a5fc05
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 24 deletions.
35 changes: 24 additions & 11 deletions modules/automatadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const spec = {

isBidRequestValid: function (bid) {
// will receive request bid. check if have necessary params for bidding
return (bid && bid.hasOwnProperty('params') && bid.params.hasOwnProperty('siteId') && bid.params.hasOwnProperty('placementId') && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty('banner'))
return (bid && bid.hasOwnProperty('params') && bid.params.hasOwnProperty('siteId') && bid.params.siteId != null && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty('banner') && typeof bid.mediaTypes.banner == 'object')
},

buildRequests: function (validBidRequests, bidderRequest) {
Expand All @@ -29,16 +29,29 @@ export const spec = {
const siteId = validBidRequests[0].params.siteId

const impressions = validBidRequests.map(bidRequest => {
return {
id: bidRequest.bidId,
adUnitCode: bidRequest.adUnitCode,
placement: bidRequest.params.placementId,
banner: {
format: bidRequest.sizes.map(sizeArr => ({
w: sizeArr[0],
h: sizeArr[1],
}))
},
if (bidRequest.params.hasOwnProperty('placementId')) {
return {
id: bidRequest.bidId,
adUnitCode: bidRequest.adUnitCode,
placement: bidRequest.params.placementId,
banner: {
format: bidRequest.sizes.map(sizeArr => ({
w: sizeArr[0],
h: sizeArr[1],
}))
},
}
} else {
return {
id: bidRequest.bidId,
adUnitCode: bidRequest.adUnitCode,
banner: {
format: bidRequest.sizes.map(sizeArr => ({
w: sizeArr[0],
h: sizeArr[1],
}))
},
}
}
})

Expand Down
4 changes: 2 additions & 2 deletions modules/automatadBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var adUnits = [
bids: [{
bidder: 'automatad',
params: {
siteId: 'someValue',
placementId: 'someValue'
siteId: 'someValue', // required
placementId: 'someValue' // optional
}
}]
}
Expand Down
39 changes: 28 additions & 11 deletions test/spec/modules/automatadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@ import { newBidder } from 'src/adapters/bidderFactory.js'
describe('automatadBidAdapter', function () {
const adapter = newBidder(spec)

let bidRequest = {
let bidRequestRequiredParams = {
bidder: 'automatad',
params: {siteId: '123ad'},
mediaTypes: {
banner: {
sizes: [[300, 600]],
}
},
adUnitCode: 'some-ad-unit-code',
transactionId: '1465569e-52cc-4c36-88a1-7174cfef4b44',
sizes: [[300, 600]],
bidId: '123abc',
bidderRequestId: '3213887463c059',
auctionId: 'abc-123',
src: 'client',
bidRequestsCount: 1
}

let bidRequestAllParams = {
bidder: 'automatad',
params: {siteId: '123ad', placementId: '123abc345'},
mediaTypes: {
Expand Down Expand Up @@ -59,10 +77,14 @@ describe('automatadBidAdapter', function () {
})

describe('isBidRequestValid', function () {
let inValidBid = Object.assign({}, bidRequest)
let inValidBid = Object.assign({}, bidRequestRequiredParams)
delete inValidBid.params
it('should return true if all params present', function () {
expect(spec.isBidRequestValid(bidRequest)).to.equal(true)
expect(spec.isBidRequestValid(bidRequestAllParams)).to.equal(true)
})

it('should return true if only required params present', function() {
expect(spec.isBidRequestValid(bidRequestRequiredParams)).to.equal(true)
})

it('should return false if any parameter missing', function () {
Expand All @@ -71,7 +93,7 @@ describe('automatadBidAdapter', function () {
})

describe('buildRequests', function () {
let req = spec.buildRequests([ bidRequest ], { refererInfo: { } })
let req = spec.buildRequests([ bidRequestRequiredParams ], { refererInfo: { } })
let rdata

it('should return request object', function () {
Expand All @@ -87,21 +109,16 @@ describe('automatadBidAdapter', function () {
expect(rdata.imp.length).to.equal(1)
})

it('should include placement', function () {
it('should include siteId', function () {
let r = rdata.imp[0]
expect(r.placement !== null).to.be.true
expect(r.siteId !== null).to.be.true
})

it('should include media types', function () {
let r = rdata.imp[0]
expect(r.media_types !== null).to.be.true
})

it('should include all publisher params', function () {
let r = rdata.imp[0]
expect(r.siteID !== null && r.placementID !== null).to.be.true
})

it('should include adunit code', function () {
let r = rdata.imp[0]
expect(r.adUnitCode !== null).to.be.true
Expand Down

0 comments on commit 0a5fc05

Please sign in to comment.