Skip to content

Commit

Permalink
Automatad Bid Adapter: register on timeout event and endpoint changes (
Browse files Browse the repository at this point in the history
…#8030)

* 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
  • Loading branch information
kanchika-kapoor committed Feb 11, 2022
1 parent 187e5e0 commit 76b9ea4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
17 changes: 10 additions & 7 deletions modules/automatadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ajax} from '../src/ajax.js'

const BIDDER = 'automatad'

const ENDPOINT_URL = 'https://rtb2.automatad.com/ortb2'
const ENDPOINT_URL = 'https://bid.atmtd.com'

const DEFAULT_BID_TTL = 30
const DEFAULT_CURRENCY = 'USD'
Expand Down Expand Up @@ -57,7 +57,7 @@ export const spec = {
const payloadString = JSON.stringify(openrtbRequest)
return {
method: 'POST',
url: ENDPOINT_URL + '/resp',
url: ENDPOINT_URL + '/request',
data: payloadString,
options: {
contentType: 'application/json',
Expand All @@ -72,6 +72,7 @@ export const spec = {
const response = (serverResponse || {}).body

if (response && response.seatbid && response.seatbid[0].bid && response.seatbid[0].bid.length) {
var bidid = response.bidid
response.seatbid.forEach(bidObj => {
bidObj.bid.forEach(bid => {
bidResponses.push({
Expand All @@ -88,6 +89,7 @@ export const spec = {
height: bid.h,
netRevenue: DEFAULT_NET_REVENUE,
nurl: bid.nurl,
bidId: bidid
})
})
})
Expand All @@ -97,11 +99,9 @@ export const spec = {

return bidResponses
},
getUserSyncs: function(syncOptions, serverResponse) {
return [{
type: 'iframe',
url: 'https://rtb2.automatad.com/ortb2/async_usersync'
}]
onTimeout: function(timeoutData) {
const timeoutUrl = ENDPOINT_URL + '/timeout'
ajax(timeoutUrl, null, JSON.stringify(timeoutData))
},
onBidWon: function(bid) {
if (!bid.nurl) { return }
Expand All @@ -116,6 +116,9 @@ export const spec = {
).replace(
/\$\{AUCTION_CURRENCY\}/,
winCurr
).replace(
/\$\{AUCTON_BID_ID\}/,
bid.bidId
).replace(
/\$\{AUCTION_ID\}/,
bid.auctionId
Expand Down
30 changes: 23 additions & 7 deletions test/spec/modules/automatadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('automatadBidAdapter', function () {
{
'bid': [
{
'bidId': '123',
'adm': '<!-- creative code -->',
'adomain': [
'someAdDomain'
Expand Down Expand Up @@ -173,14 +174,29 @@ describe('automatadBidAdapter', function () {
})
})

describe('getUserSyncs', function () {
it('should return iframe sync', function () {
let sync = spec.getUserSyncs()
expect(sync.length).to.equal(1)
expect(sync[0].type === 'iframe')
expect(typeof sync[0].url === 'string')
describe('onTimeout', function () {
const timeoutData = {
'bidId': '123',
'bidder': 'automatad',
'adUnitCode': 'div-13',
'auctionId': '1232',
'params': [
{
'siteId': 'test',
'placementId': 'test123'
}
],
'timeout': 1000
}

it('should exists and be a function', function () {
expect(spec.onTimeout).to.exist.and.to.be.a('function');
});

it('should include timeoutData', function () {
expect(spec.onTimeout(timeoutData)).to.be.undefined;
})
})
});

describe('onBidWon', function () {
let serverResponses = spec.interpretResponse(expectedResponse[0])
Expand Down

0 comments on commit 76b9ea4

Please sign in to comment.