From ea042d062c7fedc34199bd497f1ac955a9b25136 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 17:11:56 +0530 Subject: [PATCH 01/26] added automatad bid adapter --- modules/automatadBidAdapter.js | 113 +++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 modules/automatadBidAdapter.js diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js new file mode 100644 index 00000000000..7f5c9e09df3 --- /dev/null +++ b/modules/automatadBidAdapter.js @@ -0,0 +1,113 @@ +import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils'; +import {BANNER} from '../src/mediaTypes'; +import {ajax} from '../src/ajax'; + +const BIDDER = 'automatad' + +const ENDPOINT_URL = 'https://rtb2.automatad.com/ortb2'; + +const DEFAULT_BID_TTL = 30; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_NET_REVENUE = true; + +export const spec = { + code: BIDDER, + aliases: ['atd'], + supportedMediaTypes: [BANNER], + + 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')); + }, + + buildRequests: function (validBidRequests, bidderRequest) { + if (!validBidRequests || !bidderRequest) { + return; + } + + const siteId = validBidRequests[0].params.siteId; + const placementId = validBidRequests[0].params.placementId; + + const impressions = validBidRequests.map(bidRequest => ({ + id: bidRequest.bidId, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1], + })) + }, + })); + + // params from bid request + const openrtbRequest = { + id: validBidRequests[0].auctionId, + imp: impressions, + site: { + id: siteId, + placement: placementId, + domain: window.location.hostname, + page: window.location.href, + ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null, + }, + }; + + const payloadString = JSON.stringify(openrtbRequest); + return { + method: 'POST', + url: ENDPOINT_URL + '/resp', + data: payloadString, + options: { + contentType: 'application/json', + withCredentials: false, + crossOrigin: true, + }, + }; + }, + + interpretResponse: function (serverResponse, request) { + 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, + }) + }) + } else { + utils.logInfo('automatad :: no valid responses to interpret'); + } + + return bidResponses; + }, + onBidWon: function(bid) { + if (!bid.nurl) { return; } + const winUrl = bid.nurl.replace( + /\$\{AUCTION_PRICE\}/, + bid.cpm + ).replace( + /\$\{AUCTION_IMP_ID\}/, + bid.requestId + ).replace( + /\$\{AUCTION_CURRENCY\}/, + bid.currency + ).replace( + /\$\{AUCTION_ID\}/, + bid.auctionId + ); + ajax(winUrl, null) + }, + +}; +registerBidder(spec); From c2a3ab6f50653d305f2e2be0a282f07d4d4a3677 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 17:13:16 +0530 Subject: [PATCH 02/26] added automatad bid adapter readme --- modules/automatadBidAdapter.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/automatadBidAdapter.md diff --git a/modules/automatadBidAdapter.md b/modules/automatadBidAdapter.md new file mode 100644 index 00000000000..c9792f19b06 --- /dev/null +++ b/modules/automatadBidAdapter.md @@ -0,0 +1,34 @@ +# Overview + +``` +Module Name: Automatad Bid Adapter +Module Type: Bidder Adapter +Maintainer: '' +``` + +# Description + +Connects to automatad exchange for bids. + +automatad bid adapter supports Banner ads. + +# Test Parameters +``` +var adUnits = [ + { + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'automatad', + params: { + siteId: 'someValue', + placementId: 'someValue' + } + }] + } +]; +``` From 2d98d8f5a85bfdb62c290ba16759dfe044a36338 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 17:21:52 +0530 Subject: [PATCH 03/26] added automatad bidder adapter unit test --- test/spec/modules/automatadBidAdapter_spec.js | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 test/spec/modules/automatadBidAdapter_spec.js diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js new file mode 100644 index 00000000000..2eb57a6ae97 --- /dev/null +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -0,0 +1,114 @@ +import { expect } from 'chai' +import { spec, _getPlatform } from 'modules/automatadBidAdapter' +import { newBidder } from 'src/adapters/bidderFactory' + +describe('automatadBidAdapter', function () { + const adapter = newBidder(spec) + + let bidRequest = { + bidder: 'automatad', + params: {siteId: '123ad', placementId: '123abc345'}, + 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, + } + + describe('codes', function () { + it('should return a bidder code of automatad', function () { + expect(spec.code).to.equal('automatad') + }) + it('should alias atd', function () { + expect(spec.aliases.length > 0 && spec.aliases[0] === 'atd').to.be.true + }) + }) + + describe('isBidRequestValid', function () { + let inValidBid = Object.assign({}, bidRequest) + delete inValidBid.params + it('should return true if all params present', function () { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true) + }) + + it('should return false if any parameter missing', function () { + expect(spec.isBidRequestValid(inValidBid)).to.be.false + }) + }) + + describe('buildRequests', function () { + let req = spec.buildRequests([ bidRequest ], { refererInfo: { } }) + let rdata + + it('should return request object', function () { + expect(req).to.not.be.null + }) + + it('should build request data', function () { + expect(req.data).to.not.be.null + }) + + it('should include one request', function () { + rdata = JSON.parse(req.data) + expect(rdata.imp.length).to.equal(1) + }) + + 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 + }) + }) + + describe('interpretResponse', function () { + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'body': { + 'id': 'abc-123', + 'seatbid': [ + { + 'bid': [ + { + 'adm': '', + 'adomain': [ + 'someAdDomain' + ], + 'crid': 123, + 'h': 250, + 'id': 'bid1', + 'impid': '1', + 'nurl': '', + 'price': 0.3, + 'w': 300 + } + ] + } + ] + } + }]; + + let result = spec.interpretResponse(expectedResponse[0]); + expect(result).to.be.an('array').that.is.not.empty; + }); + + it('handles empty bid response', function () { + let response = { + body: '' + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}) From 9b84d5716a9b95257d573a83d18f1e0beb88cdfe Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 17:25:13 +0530 Subject: [PATCH 04/26] updated maintainer email id for automatad adapter --- modules/automatadBidAdapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/automatadBidAdapter.md b/modules/automatadBidAdapter.md index c9792f19b06..56a4b53c067 100644 --- a/modules/automatadBidAdapter.md +++ b/modules/automatadBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: Automatad Bid Adapter Module Type: Bidder Adapter -Maintainer: '' +Maintainer: tech@automatad.com ``` # Description From 85611aaa93bf8406395a6c27dc164cb5ed32731f Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 18:25:10 +0530 Subject: [PATCH 05/26] refactored automatadBidAdapter js --- modules/automatadBidAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 7f5c9e09df3..a3f571d237a 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -1,7 +1,7 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import {BANNER} from '../src/mediaTypes'; -import {ajax} from '../src/ajax'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {ajax} from '../src/ajax.js'; const BIDDER = 'automatad' From 8ef416cba622c64f12ae2a30719e830b3276c5ac Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 18:26:24 +0530 Subject: [PATCH 06/26] refactored automatadBidAdapter unit test --- test/spec/modules/automatadBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 2eb57a6ae97..67912157aee 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { spec, _getPlatform } from 'modules/automatadBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' +import { spec, _getPlatform } from 'modules/automatadBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' describe('automatadBidAdapter', function () { const adapter = newBidder(spec) From 70e395629ea449cf2392afb22c430b55fc768cf4 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 19:12:27 +0530 Subject: [PATCH 07/26] refactored automatadBidAdapter unit test --- test/spec/modules/automatadBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 67912157aee..d3f56043ea2 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec, _getPlatform } from 'modules/automatadBidAdapter.js' +import { spec } from 'modules/automatadBidAdapter.js' import { newBidder } from 'src/adapters/bidderFactory.js' describe('automatadBidAdapter', function () { From 1d1d2cdbeab44e4b61f3f9aaddacf432beabe596 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 23 Mar 2020 22:13:27 +0530 Subject: [PATCH 08/26] added usersync code to automatad bid adapter --- modules/automatadBidAdapter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index a3f571d237a..62f62bd09a8 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -91,6 +91,14 @@ export const spec = { return bidResponses; }, + getUserSyncs: function(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: 'https://rtb2.automatad.com/static/usersync/v1/async_usersync' + }]; + } + }, onBidWon: function(bid) { if (!bid.nurl) { return; } const winUrl = bid.nurl.replace( From 8c4c2a8b80f5c84c037fc997d1ef1d5ec1a47532 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 30 Mar 2020 04:28:38 +0530 Subject: [PATCH 09/26] Added unit test for onBidWon in automatadBidAdapter_spec --- test/spec/modules/automatadBidAdapter_spec.js | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index d3f56043ea2..41150a33c7e 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -22,6 +22,31 @@ describe('automatadBidAdapter', function () { src: 'client', bidRequestsCount: 1, } + + let expectedResponse = [{ + 'body': { + 'id': 'abc-123', + 'seatbid': [ + { + 'bid': [ + { + 'adm': '', + 'adomain': [ + 'someAdDomain' + ], + 'crid': 123, + 'h': 600, + 'id': 'bid1', + 'impid': '1', + 'nurl': '', + 'price': 0.5, + 'w': 300 + } + ] + } + ] + } + }] describe('codes', function () { it('should return a bidder code of automatad', function () { @@ -74,41 +99,24 @@ describe('automatadBidAdapter', function () { describe('interpretResponse', function () { it('should get the correct bid response', function () { - let expectedResponse = [{ - 'body': { - 'id': 'abc-123', - 'seatbid': [ - { - 'bid': [ - { - 'adm': '', - 'adomain': [ - 'someAdDomain' - ], - 'crid': 123, - 'h': 250, - 'id': 'bid1', - 'impid': '1', - 'nurl': '', - 'price': 0.3, - 'w': 300 - } - ] - } - ] - } - }]; - let result = spec.interpretResponse(expectedResponse[0]); expect(result).to.be.an('array').that.is.not.empty; - }); + }) it('handles empty bid response', function () { let response = { body: '' - }; + } let result = spec.interpretResponse(response); expect(result.length).to.equal(0); - }); - }); + }) + }) + describe('onBidWon', function () { + let serverResponses = spec.interpretResponse(expectedResponse[0]); + let wonbid = serverResponses[0]; + + it('Returns true is nurl is good/not blank', function () { + expect(wonbid.nurl).to.not.equal(''); + }) + }) }) From ce62f830ffbda5f98829e9616efe300c4a34b322 Mon Sep 17 00:00:00 2001 From: Kanchika - Automatad Date: Mon, 30 Mar 2020 05:09:50 +0530 Subject: [PATCH 10/26] removed trailing spaces --- test/spec/modules/automatadBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 41150a33c7e..693074bf95d 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -22,7 +22,7 @@ describe('automatadBidAdapter', function () { src: 'client', bidRequestsCount: 1, } - + let expectedResponse = [{ 'body': { 'id': 'abc-123', From f35971192f278b580fca2a55e9fd940958eb4ae7 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Mon, 30 Mar 2020 05:10:27 +0530 Subject: [PATCH 11/26] removed trailing space --- test/spec/modules/automatadBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 41150a33c7e..a867ba2259c 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -20,9 +20,9 @@ describe('automatadBidAdapter', function () { bidderRequestId: '3213887463c059', auctionId: 'abc-123', src: 'client', - bidRequestsCount: 1, + bidRequestsCount: 1 } - + let expectedResponse = [{ 'body': { 'id': 'abc-123', From 3897bce6c5a6d1a48799dec38709c28262647d42 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Mon, 30 Mar 2020 06:40:09 +0530 Subject: [PATCH 12/26] changes for getUserSync function --- modules/automatadBidAdapter.js | 6 ++---- test/spec/modules/automatadBidAdapter_spec.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 62f62bd09a8..31499c8db19 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -91,13 +91,11 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { + getUserSyncs: function(syncOptions,serverResponse) { return [{ type: 'iframe', url: 'https://rtb2.automatad.com/static/usersync/v1/async_usersync' - }]; - } + }] }, onBidWon: function(bid) { if (!bid.nurl) { return; } diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index a867ba2259c..3cd36997526 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -111,6 +111,16 @@ describe('automatadBidAdapter', function () { expect(result.length).to.equal(0); }) }) + + 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('onBidWon', function () { let serverResponses = spec.interpretResponse(expectedResponse[0]); let wonbid = serverResponses[0]; From 88d84a1e8727cf9aa52dbd37d88b973cdc703aae Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Mon, 30 Mar 2020 06:48:34 +0530 Subject: [PATCH 13/26] lint error fixes --- modules/automatadBidAdapter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 31499c8db19..86738978a5b 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -91,11 +91,11 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions,serverResponse) { - return [{ - type: 'iframe', - url: 'https://rtb2.automatad.com/static/usersync/v1/async_usersync' - }] + getUserSyncs: function(syncOptions, serverResponse) { + return [{ + type: 'iframe', + url: 'https://rtb2.automatad.com/static/usersync/v1/async_usersync' + }] }, onBidWon: function(bid) { if (!bid.nurl) { return; } From c1305a0d0f7aac1f5263e01d71eac4a0caaa6fd5 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Mon, 30 Mar 2020 08:33:19 +0530 Subject: [PATCH 14/26] updated usersync url --- modules/automatadBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 86738978a5b..6c1853ca881 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -94,7 +94,7 @@ export const spec = { getUserSyncs: function(syncOptions, serverResponse) { return [{ type: 'iframe', - url: 'https://rtb2.automatad.com/static/usersync/v1/async_usersync' + url: 'https://rtb2.automatad.com/ortb2/async_usersync' }] }, onBidWon: function(bid) { From 581472a2414826cf14155b7f62e20b7d028599e8 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Tue, 31 Mar 2020 02:34:38 +0530 Subject: [PATCH 15/26] additional test for onBidWon function added --- modules/automatadBidAdapter.js | 49 ++++++++++--------- test/spec/modules/automatadBidAdapter_spec.js | 15 +++--- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 6c1853ca881..1f46c89536d 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -1,15 +1,15 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import {BANNER} from '../src/mediaTypes.js'; -import {ajax} from '../src/ajax.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js' +import * as utils from '../src/utils.js' +import {BANNER} from '../src/mediaTypes.js' +import {ajax} from '../src/ajax.js' const BIDDER = 'automatad' -const ENDPOINT_URL = 'https://rtb2.automatad.com/ortb2'; +const ENDPOINT_URL = 'https://rtb2.automatad.com/ortb2' -const DEFAULT_BID_TTL = 30; -const DEFAULT_CURRENCY = 'USD'; -const DEFAULT_NET_REVENUE = true; +const DEFAULT_BID_TTL = 30 +const DEFAULT_CURRENCY = 'USD' +const DEFAULT_NET_REVENUE = true export const spec = { code: BIDDER, @@ -18,16 +18,16 @@ 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.hasOwnProperty('placementId') && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty('banner')) }, buildRequests: function (validBidRequests, bidderRequest) { if (!validBidRequests || !bidderRequest) { - return; + return } - const siteId = validBidRequests[0].params.siteId; - const placementId = validBidRequests[0].params.placementId; + const siteId = validBidRequests[0].params.siteId + const placementId = validBidRequests[0].params.placementId const impressions = validBidRequests.map(bidRequest => ({ id: bidRequest.bidId, @@ -37,7 +37,7 @@ export const spec = { h: sizeArr[1], })) }, - })); + })) // params from bid request const openrtbRequest = { @@ -50,9 +50,9 @@ export const spec = { page: window.location.href, ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null, }, - }; + } - const payloadString = JSON.stringify(openrtbRequest); + const payloadString = JSON.stringify(openrtbRequest) return { method: 'POST', url: ENDPOINT_URL + '/resp', @@ -62,12 +62,12 @@ export const spec = { withCredentials: false, crossOrigin: true, }, - }; + } }, interpretResponse: function (serverResponse, request) { - const bidResponses = []; - const response = (serverResponse || {}).body; + 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 => { @@ -86,10 +86,10 @@ export const spec = { }) }) } else { - utils.logInfo('automatad :: no valid responses to interpret'); + utils.logInfo('automatad :: no valid responses to interpret') } - return bidResponses; + return bidResponses }, getUserSyncs: function(syncOptions, serverResponse) { return [{ @@ -98,7 +98,7 @@ export const spec = { }] }, onBidWon: function(bid) { - if (!bid.nurl) { return; } + if (!bid.nurl) { return } const winUrl = bid.nurl.replace( /\$\{AUCTION_PRICE\}/, bid.cpm @@ -111,9 +111,10 @@ export const spec = { ).replace( /\$\{AUCTION_ID\}/, bid.auctionId - ); + ) ajax(winUrl, null) + return true }, -}; -registerBidder(spec); +} +registerBidder(spec) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 3cd36997526..a7f5e2707a8 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -99,16 +99,16 @@ describe('automatadBidAdapter', function () { describe('interpretResponse', function () { it('should get the correct bid response', function () { - let result = spec.interpretResponse(expectedResponse[0]); - expect(result).to.be.an('array').that.is.not.empty; + let result = spec.interpretResponse(expectedResponse[0]) + expect(result).to.be.an('array').that.is.not.empty }) it('handles empty bid response', function () { let response = { body: '' } - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); + let result = spec.interpretResponse(response) + expect(result.length).to.equal(0) }) }) @@ -122,11 +122,12 @@ describe('automatadBidAdapter', function () { }) describe('onBidWon', function () { - let serverResponses = spec.interpretResponse(expectedResponse[0]); - let wonbid = serverResponses[0]; + let serverResponses = spec.interpretResponse(expectedResponse[0]) + let wonbid = serverResponses[0] it('Returns true is nurl is good/not blank', function () { - expect(wonbid.nurl).to.not.equal(''); + expect(wonbid.nurl).to.not.equal('') + expect(spec.onBidWon(wonbid)).to.be.true }) }) }) From 6a2bf79d3e1107344dc1e87b5e542b00c969bda1 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Mon, 6 Apr 2020 08:03:20 +0530 Subject: [PATCH 16/26] added ajax stub in test --- modules/automatadBidAdapter.js | 5 ++++- test/spec/modules/automatadBidAdapter_spec.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 1f46c89536d..4a9e6b6a1e4 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -112,9 +112,12 @@ export const spec = { /\$\{AUCTION_ID\}/, bid.auctionId ) - ajax(winUrl, null) + spec.ajaxCall(winUrl, null) return true }, + ajaxCall: function(endpoint, data) { + ajax(endpoint, data) + }, } registerBidder(spec) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index a7f5e2707a8..788fd3aefc4 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -38,7 +38,7 @@ describe('automatadBidAdapter', function () { 'h': 600, 'id': 'bid1', 'impid': '1', - 'nurl': '', + 'nurl': 'https://example/win', 'price': 0.5, 'w': 300 } @@ -124,10 +124,21 @@ describe('automatadBidAdapter', function () { describe('onBidWon', function () { let serverResponses = spec.interpretResponse(expectedResponse[0]) let wonbid = serverResponses[0] + let ajaxStub + + beforeEach(() => { + ajaxStub = sinon.stub(spec, 'ajaxCall') + }) + + afterEach(() => { + ajaxStub.restore() + }) it('Returns true is nurl is good/not blank', function () { expect(wonbid.nurl).to.not.equal('') expect(spec.onBidWon(wonbid)).to.be.true + expect(ajaxStub.calledOnce).to.equal(true) + expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0) }) }) }) From 53e73790963b6db507155d903ed86d54b63fefd4 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Tue, 19 May 2020 21:59:40 +0530 Subject: [PATCH 17/26] updated winurl params --- modules/automatadBidAdapter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 4a9e6b6a1e4..203ac109965 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -99,15 +99,17 @@ export const spec = { }, onBidWon: function(bid) { if (!bid.nurl) { return } + const winCpm = (bid.hasOwnProperty('originalCpm'))?bid.originalCpm:bid.cpm + const winCurr = (bid.hasOwnProperty('originalCurrency') && bid.hasOwnProperty('originalCpm'))?bid.originalCurrency:bid.currency const winUrl = bid.nurl.replace( /\$\{AUCTION_PRICE\}/, - bid.cpm + winCpm ).replace( /\$\{AUCTION_IMP_ID\}/, bid.requestId ).replace( /\$\{AUCTION_CURRENCY\}/, - bid.currency + winCurr ).replace( /\$\{AUCTION_ID\}/, bid.auctionId From c8c7b355e542adb2c98b586d45ba3b9f203f658b Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Tue, 19 May 2020 22:51:51 +0530 Subject: [PATCH 18/26] lint fixes --- modules/automatadBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 203ac109965..95d225cb5f7 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -99,8 +99,8 @@ export const spec = { }, onBidWon: function(bid) { if (!bid.nurl) { return } - const winCpm = (bid.hasOwnProperty('originalCpm'))?bid.originalCpm:bid.cpm - const winCurr = (bid.hasOwnProperty('originalCurrency') && bid.hasOwnProperty('originalCpm'))?bid.originalCurrency:bid.currency + const winCpm = (bid.hasOwnProperty('originalCpm')) ? bid.originalCpm : bid.cpm + const winCurr = (bid.hasOwnProperty('originalCurrency') && bid.hasOwnProperty('originalCpm')) ? bid.originalCurrency : bid.currency const winUrl = bid.nurl.replace( /\$\{AUCTION_PRICE\}/, winCpm From 17725dc91c56966bb39a46542e7340178ee01645 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Tue, 4 Aug 2020 07:30:43 +0530 Subject: [PATCH 19/26] added adunitCode in bid request --- modules/automatadBidAdapter.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 95d225cb5f7..414cadcd405 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -29,15 +29,18 @@ export const spec = { const siteId = validBidRequests[0].params.siteId const placementId = validBidRequests[0].params.placementId - const impressions = validBidRequests.map(bidRequest => ({ - id: bidRequest.bidId, - banner: { - format: bidRequest.sizes.map(sizeArr => ({ - w: sizeArr[0], - h: sizeArr[1], - })) - }, - })) + const impressions = validBidRequests.map(bidRequest => { + return { + id: bidRequest.bidId, + adUnitCode: bidRequest.adUnitCode, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1], + })) + }, + } + }) // params from bid request const openrtbRequest = { From 56c6f56ee50b8d7c6c37049c9d9c55fbade0c02c Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Thu, 6 Aug 2020 11:10:56 +0530 Subject: [PATCH 20/26] added test for adunit code --- test/spec/modules/automatadBidAdapter_spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 788fd3aefc4..a6de8810284 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -95,6 +95,11 @@ describe('automatadBidAdapter', 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 + }) }) describe('interpretResponse', function () { From d68d9a6f29a43ee26cf0cd731678cec002d69b12 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Wed, 26 Aug 2020 11:18:56 +0530 Subject: [PATCH 21/26] add placement in impression object --- modules/automatadBidAdapter.js | 3 +-- test/spec/modules/automatadBidAdapter_spec.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 414cadcd405..e1a69a37513 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -27,12 +27,12 @@ export const spec = { } const siteId = validBidRequests[0].params.siteId - const placementId = validBidRequests[0].params.placementId 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], @@ -48,7 +48,6 @@ export const spec = { imp: impressions, site: { id: siteId, - placement: placementId, domain: window.location.hostname, page: window.location.href, ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null, diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index a6de8810284..e0341a1d255 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -86,6 +86,11 @@ describe('automatadBidAdapter', function () { expect(rdata.imp.length).to.equal(1) }) + it('should include placement', function () { + let r = rdata.imp[0] + expect(r.placement !== null).to.be.true + }) + it('should include media types', function () { let r = rdata.imp[0] expect(r.media_types !== null).to.be.true From 935b5500855f9fceb72922c8ada5d25be6ac7b39 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Fri, 4 Sep 2020 07:39:27 +0530 Subject: [PATCH 22/26] added code to interpret multiple bid response in seatbid --- modules/automatadBidAdapter.js | 30 +++++------ test/spec/modules/automatadBidAdapter_spec.js | 50 +++++++++++++++++++ 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index e1a69a37513..6b66044f5e5 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -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 { diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index e0341a1d255..fca1a464ff2 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -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': '', + 'adomain': [ + 'someAdDomain' + ], + 'crid': 123, + 'h': 600, + 'id': 'bid1', + 'impid': 'imp1', + 'nurl': 'https://example/win', + 'price': 0.5, + 'w': 300 + } + ] + }, { + 'bid': [ + { + 'adm': '', + '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: '' From a044a2cd30d1082d8145164cf4add02f324052f4 Mon Sep 17 00:00:00 2001 From: kanchika Date: Thu, 1 Apr 2021 16:39:44 +0530 Subject: [PATCH 23/26] added bid meta with advertiserDomains --- modules/automatadBidAdapter.js | 4 +++- test/spec/modules/automatadBidAdapter_spec.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 6b66044f5e5..415c52ba6d3 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -78,7 +78,9 @@ export const spec = { requestId: bid.impid, cpm: bid.price, ad: bid.adm, - adDomain: bid.adomain[0], + meta: { + advertiserDomains: bid.adomain + }, currency: DEFAULT_CURRENCY, ttl: DEFAULT_BID_TTL, creativeId: bid.crid, diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index fca1a464ff2..9d828bad4c3 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -111,6 +111,7 @@ describe('automatadBidAdapter', function () { it('should get the correct bid response', function () { let result = spec.interpretResponse(expectedResponse[0]) expect(result).to.be.an('array').that.is.not.empty + expect(result[0].meta.advertiserDomains[0]).to.equal('someAdDomain'); }) it('should interpret multiple bids in seatbid', function () { From 5b8ce78b909e8810df609df1ab77290949d5a91a Mon Sep 17 00:00:00 2001 From: kanchika Date: Wed, 9 Feb 2022 06:14:34 +0530 Subject: [PATCH 24/26] endpoint url changes --- modules/automatadBidAdapter.js | 17 +++++------ test/spec/modules/automatadBidAdapter_spec.js | 30 ++++++++++++++----- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 2cfcfbe98b4..9b4ed6c6a57 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', @@ -88,6 +88,7 @@ export const spec = { height: bid.h, netRevenue: DEFAULT_NET_REVENUE, nurl: bid.nurl, + bidId: bid.bidId }) }) }) @@ -97,11 +98,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 } @@ -117,8 +116,8 @@ export const spec = { /\$\{AUCTION_CURRENCY\}/, winCurr ).replace( - /\$\{AUCTION_ID\}/, - bid.auctionId + /\$\{AUCTON_BID_ID\}/, + bid.bidId ) spec.ajaxCall(winUrl, null) return true diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 9d828bad4c3..1021bb42a5e 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', () => { + 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', () => { + 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]) From 925139d31091fab2ca6c571724b74b46d71a9c99 Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Wed, 9 Feb 2022 14:10:12 +0530 Subject: [PATCH 25/26] added format changes --- modules/automatadBidAdapter.js | 2 +- test/spec/modules/automatadBidAdapter_spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 9b4ed6c6a57..006fb4fa807 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -88,7 +88,7 @@ export const spec = { height: bid.h, netRevenue: DEFAULT_NET_REVENUE, nurl: bid.nurl, - bidId: bid.bidId + bidId: response.bidid }) }) }) diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 1021bb42a5e..4a15209822b 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -174,7 +174,7 @@ describe('automatadBidAdapter', function () { }) }) - describe('onTimeout', () => { + describe('onTimeout', function () { const timeoutData = { 'bidId': '123', 'bidder': 'automatad', @@ -189,7 +189,7 @@ describe('automatadBidAdapter', function () { 'timeout': 1000 } - it('should exists and be a function', () => { + it('should exists and be a function', function () { expect(spec.onTimeout).to.exist.and.to.be.a('function'); }); From 07454e2932838d527524d4bed0c43b57db46b41c Mon Sep 17 00:00:00 2001 From: kanchika-automatad Date: Wed, 9 Feb 2022 21:48:35 +0530 Subject: [PATCH 26/26] macro substitution change added --- modules/automatadBidAdapter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 006fb4fa807..726bbef9bd6 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -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,7 +89,7 @@ export const spec = { height: bid.h, netRevenue: DEFAULT_NET_REVENUE, nurl: bid.nurl, - bidId: response.bidid + bidId: bidid }) }) }) @@ -118,6 +119,9 @@ export const spec = { ).replace( /\$\{AUCTON_BID_ID\}/, bid.bidId + ).replace( + /\$\{AUCTION_ID\}/, + bid.auctionId ) spec.ajaxCall(winUrl, null) return true