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

Automatad Bid Adapter: make placementId param optional #8269

Merged
merged 38 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ea042d0
added automatad bid adapter
Mar 23, 2020
c2a3ab6
added automatad bid adapter readme
Mar 23, 2020
2d98d8f
added automatad bidder adapter unit test
Mar 23, 2020
9b84d57
updated maintainer email id for automatad adapter
Mar 23, 2020
85611aa
refactored automatadBidAdapter js
Mar 23, 2020
8ef416c
refactored automatadBidAdapter unit test
Mar 23, 2020
70e3956
refactored automatadBidAdapter unit test
Mar 23, 2020
1d1d2cd
added usersync code to automatad bid adapter
Mar 23, 2020
8c4c2a8
Added unit test for onBidWon in automatadBidAdapter_spec
Mar 29, 2020
ce62f83
removed trailing spaces
Mar 29, 2020
f359711
removed trailing space
Mar 29, 2020
3856574
Merge branch 'master' of https://github.com/kanchika-automatad/Prebid.js
Mar 29, 2020
3897bce
changes for getUserSync function
Mar 30, 2020
88d84a1
lint error fixes
Mar 30, 2020
c1305a0
updated usersync url
Mar 30, 2020
581472a
additional test for onBidWon function added
Mar 30, 2020
6a2bf79
added ajax stub in test
Apr 6, 2020
6652aea
Merge remote-tracking branch 'upstream/master'
May 19, 2020
53e7379
updated winurl params
May 19, 2020
c8c7b35
lint fixes
May 19, 2020
0684cb9
Merge remote-tracking branch 'upstream/master'
Aug 4, 2020
17725dc
added adunitCode in bid request
Aug 4, 2020
56c6f56
added test for adunit code
Aug 6, 2020
033cf50
Merge remote-tracking branch 'upstream/master'
Aug 25, 2020
d68d9a6
add placement in impression object
Aug 26, 2020
8abfb3c
Merge remote-tracking branch 'upstream/master'
Sep 4, 2020
935b550
added code to interpret multiple bid response in seatbid
Sep 4, 2020
a98e385
Merge branch 'master' of https://github.com/prebid/Prebid.js
Apr 1, 2021
a044a2c
added bid meta with advertiserDomains
Apr 1, 2021
4022cb5
Merge branch 'prebid:master' into master
Feb 8, 2022
5b8ce78
endpoint url changes
Feb 9, 2022
925139d
added format changes
Feb 9, 2022
07454e2
macro substitution change added
Feb 9, 2022
57f59fe
Merge branch 'prebid:master' into master
Mar 22, 2022
d54033d
Merge branch 'prebid:master' into master
Mar 30, 2022
a7bfe0f
make placementId optional
Mar 30, 2022
a7c4786
lint the code
Mar 31, 2022
c2308da
Merge branch 'prebid:master' into master
Apr 8, 2022
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
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