From 7a2e0e29c49e2f876b68aafe886b336fe2fe6fcb Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 4 Nov 2022 10:09:41 +0300 Subject: [PATCH] Admatic Bid Adapter: alias and bid floor features activated --- modules/admaticBidAdapter.js | 23 ++++++++++++++--------- modules/admaticBidAdapter.md | 7 ++++--- src/adloader.js | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index dc252fb2e28..b139b58da46 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -2,13 +2,13 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../s import { loadExternalScript } from '../src/adloader.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; -const BIDDER_CODE = 'admatic'; export const spec = { code: 'admatic', + aliases: [ + {code: 'adpixel'} + ], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -20,11 +20,12 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - isValid = isValidNetworkId;// && isValidTypeId; + let isValidHost = getValue(bid.params, 'host'); + isValid = isValidNetworkId && isValidHost; } if (!isValid) { - logError('AdMatic networkId parameters are required. Bid aborted.'); + logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); } return isValid; }, @@ -36,11 +37,13 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); + const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); + const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; setTimeout(() => { - loadExternalScript(SYNC_URL, BIDDER_CODE); + loadExternalScript(SYNC_URL, bidderName); }, bidderRequest.timeout); const payload = { @@ -59,14 +62,14 @@ export const spec = { imp: bids, ext: { 'cur': currency, - 'type': 'admatic' + 'bidder': bidderName } }; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: ENDPOINT_URL, + url: `https://${host}/pb?bidder=${bidderName}`, data: payloadString, options: { contentType: 'application/json' @@ -97,7 +100,7 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: 'admatic', + bidder: JSON.parse(request.data).ext.bidder, timeToRespond: 1, requestTimestamp: 1 }; @@ -109,6 +112,8 @@ export const spec = { } }; +registerBidder(spec); + function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 0496f40e881..b12aebe5f72 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -18,7 +18,8 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345 + networkId: 12345, + host: 'layer.serve.admatic.com.tr' } }] },{ @@ -27,14 +28,14 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345 + networkId: 12345, + host: 'layer.serve.admatic.com.tr' } }] }]; ``` ## UserSync example - ``` pbjs.setConfig({ userSync: { diff --git a/src/adloader.js b/src/adloader.js index add5863ddf2..5cf7af5231e 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,6 +7,7 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', + 'adpixel', 'criteo', 'outstream', 'adagio',