From 76b9ea452ef080843d472b9f78b93a7c210b3434 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Sat, 12 Feb 2022 03:18:59 +0530 Subject: [PATCH] Automatad Bid Adapter: register on timeout event and endpoint changes (#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 --- modules/automatadBidAdapter.js | 17 ++++++----- test/spec/modules/automatadBidAdapter_spec.js | 30 ++++++++++++++----- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 2cfcfbe98b4..726bbef9bd6 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -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' @@ -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', @@ -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({ @@ -88,6 +89,7 @@ export const spec = { height: bid.h, netRevenue: DEFAULT_NET_REVENUE, nurl: bid.nurl, + bidId: bidid }) }) }) @@ -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 } @@ -116,6 +116,9 @@ export const spec = { ).replace( /\$\{AUCTION_CURRENCY\}/, winCurr + ).replace( + /\$\{AUCTON_BID_ID\}/, + bid.bidId ).replace( /\$\{AUCTION_ID\}/, bid.auctionId diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 9d828bad4c3..4a15209822b 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -30,6 +30,7 @@ describe('automatadBidAdapter', function () { { 'bid': [ { + 'bidId': '123', 'adm': '', 'adomain': [ 'someAdDomain' @@ -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])