From 25fd8b8fa445cf485c426ace49369e801ae53e4b Mon Sep 17 00:00:00 2001 From: Liza Kobrazova Date: Tue, 26 Jan 2021 23:31:14 +0300 Subject: [PATCH 01/18] Fix astraoneBidAdapter --- .../gpt/astraone_in-image_example.html | 70 ++++++++++++++ .../gpt/astraone_in-image_gpt_example.html | 92 +++++++++++++++++++ modules/astraoneBidAdapter.js | 17 ++-- 3 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 integrationExamples/gpt/astraone_in-image_example.html create mode 100644 integrationExamples/gpt/astraone_in-image_gpt_example.html diff --git a/integrationExamples/gpt/astraone_in-image_example.html b/integrationExamples/gpt/astraone_in-image_example.html new file mode 100644 index 00000000000..bfd5c328230 --- /dev/null +++ b/integrationExamples/gpt/astraone_in-image_example.html @@ -0,0 +1,70 @@ + + + + + Prebid.js Banner Example + + + + + + +

Prebid.js InImage Banner Test

+ +
+ + +
+ + + diff --git a/integrationExamples/gpt/astraone_in-image_gpt_example.html b/integrationExamples/gpt/astraone_in-image_gpt_example.html new file mode 100644 index 00000000000..071510ef1e1 --- /dev/null +++ b/integrationExamples/gpt/astraone_in-image_gpt_example.html @@ -0,0 +1,92 @@ + + + + + Prebid.js Banner gbt Example + + + + + + +

Prebid.js InImage Banner gbt Test

+ +
+ + + +
+ + + + diff --git a/modules/astraoneBidAdapter.js b/modules/astraoneBidAdapter.js index 7e98c1022d2..2fec3892d27 100644 --- a/modules/astraoneBidAdapter.js +++ b/modules/astraoneBidAdapter.js @@ -31,7 +31,9 @@ function buildBid(bidData) { creativeId: bidData.content.seanceId, currency: bidData.currency, netRevenue: true, - mediaType: BANNER, + meta: { + mediaType: BANNER, + }, ttl: TTL, content: bidData.content }; @@ -62,7 +64,7 @@ function wrapAd(bid, bidData) { parentDocument.style.height = "100%"; parentDocument.style.width = "100%"; } - var _html = "${encodeURIComponent(JSON.stringify(bid))}"; + var _html = "${encodeURIComponent(JSON.stringify({...bid, content: bidData.content}))}"; window._ao_ssp.registerInImage(JSON.parse(decodeURIComponent(_html))); @@ -126,14 +128,9 @@ export const spec = { * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: function(serverResponse) { - const serverBody = serverResponse.body; - if (serverBody && utils.isArray(serverBody)) { - return utils._map(serverBody, function(bid) { - return buildBid(bid); - }); - } else { - return []; - } + const bids = serverResponse.body && serverResponse.body.bids; + + return Array.isArray(bids) ? bids.map(bid => buildBid(bid)) : [] } } From 215f6bb56110b9a3dddc9f6688557c53f33b72c9 Mon Sep 17 00:00:00 2001 From: Liza Kobrazova Date: Wed, 27 Jan 2021 10:00:03 +0300 Subject: [PATCH 02/18] Fix examples; update astraoneBidAdapter description --- .../gpt/astraone_in-image_example.html | 3 +- .../gpt/astraone_in-image_gpt_example.html | 2 +- modules/astraoneBidAdapter.md | 292 +++++++++--------- 3 files changed, 150 insertions(+), 147 deletions(-) diff --git a/integrationExamples/gpt/astraone_in-image_example.html b/integrationExamples/gpt/astraone_in-image_example.html index bfd5c328230..ff5b543cf0e 100644 --- a/integrationExamples/gpt/astraone_in-image_example.html +++ b/integrationExamples/gpt/astraone_in-image_example.html @@ -19,10 +19,9 @@ - + + }, + bids: [{ + bidder: "astraone", + params: { + placement: "inImage", + placeId: "5f477bf94d506ebe2c4240f3", + imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg" + } + }] + }]; + + var pbjs = pbjs || {}; + pbjs.que = pbjs.que || []; + + pbjs.que.push(function() { + pbjs.addAdUnits(adUnits); + pbjs.requestBids({ + bidsBackHandler: function (e) { + if (pbjs.adserverRequestSent) return; + pbjs.adserverRequestSent = true; + var params = pbjs.getAdserverTargetingForAdUnitCode("test-div"); + var iframe = document.getElementById('test-div'); + + if (params && params['hb_adid']) { + iframe.parentElement.style.position = "relative"; + iframe.style.display = "block"; + pbjs.renderAd(iframe.contentDocument, params['hb_adid']); + } + } + }); + }); + -

Prebid.js InImage Banner Test

+

Prebid.js InImage Banner Test

-
- - -
+
+ + +
@@ -109,90 +112,91 @@ var adUnits = [{ - - Prebid.js Banner Example - - - - + + Prebid.js Banner gbt Example + + + + -

Prebid.js Banner Ad Unit Test

+

Prebid.js InImage Banner gbt Test

-
- +
+ - -
+ +
``` From 15c31931396d652d35aeb63d8f94a6b4d63a1c8a Mon Sep 17 00:00:00 2001 From: Liza Kobrazova Date: Wed, 27 Jan 2021 10:33:44 +0300 Subject: [PATCH 03/18] Fix astraoneBidAdapter_spec --- test/spec/modules/astraoneBidAdapter_spec.js | 34 +++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js index e422f64b570..0e545081869 100644 --- a/test/spec/modules/astraoneBidAdapter_spec.js +++ b/test/spec/modules/astraoneBidAdapter_spec.js @@ -14,7 +14,7 @@ function getSlotConfigs(mediaTypes, params) { describe('AstraOne Adapter', function() { describe('isBidRequestValid method', function() { - const PLACE_ID = '5af45ad34d506ee7acad0c26'; + const PLACE_ID = '5f477bf94d506ebe2c4240f3'; const IMAGE_URL = 'https://creative.astraone.io/files/default_image-1-600x400.jpg'; describe('returns true', function() { @@ -176,21 +176,23 @@ describe('AstraOne Adapter', function() { describe('the bid is a banner', function() { it('should return a banner bid', function() { const serverResponse = { - body: [ - { - bidId: '2df8c0733f284e', - price: 0.5, - currency: 'USD', - content: { - content: 'html', - actionUrls: {}, - seanceId: '123123' - }, - width: 100, - height: 100, - ttl: 360 - } - ] + body: { + bids: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: { + content: 'html', + actionUrls: {}, + seanceId: '123123' + }, + width: 100, + height: 100, + ttl: 360 + } + ] + } } const bids = spec.interpretResponse(serverResponse) expect(bids.length).to.equal(1) From 6a69a67001fc75e94cc961039a9fe398409d91e2 Mon Sep 17 00:00:00 2001 From: Liza Kobrazova Date: Wed, 27 Jan 2021 21:54:46 +0300 Subject: [PATCH 04/18] Remove integration examples --- .../gpt/astraone_in-image_example.html | 69 -------------- .../gpt/astraone_in-image_gpt_example.html | 92 ------------------- 2 files changed, 161 deletions(-) delete mode 100644 integrationExamples/gpt/astraone_in-image_example.html delete mode 100644 integrationExamples/gpt/astraone_in-image_gpt_example.html diff --git a/integrationExamples/gpt/astraone_in-image_example.html b/integrationExamples/gpt/astraone_in-image_example.html deleted file mode 100644 index ff5b543cf0e..00000000000 --- a/integrationExamples/gpt/astraone_in-image_example.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Prebid.js Banner Example - - - - - - -

Prebid.js InImage Banner Test

- -
- - -
- - - diff --git a/integrationExamples/gpt/astraone_in-image_gpt_example.html b/integrationExamples/gpt/astraone_in-image_gpt_example.html deleted file mode 100644 index 9c49a31f6b8..00000000000 --- a/integrationExamples/gpt/astraone_in-image_gpt_example.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Prebid.js Banner gbt Example - - - - - - -

Prebid.js InImage Banner gbt Test

- -
- - - -
- - - - From b3f9878eec6513d03748eba76e1fcb1cd53485d0 Mon Sep 17 00:00:00 2001 From: Liza Kobrazova Date: Wed, 27 Jan 2021 21:56:43 +0300 Subject: [PATCH 05/18] Rename gbt to gpt --- modules/astraoneBidAdapter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/astraoneBidAdapter.md b/modules/astraoneBidAdapter.md index 5ed4e353e8b..e090cfe1e54 100644 --- a/modules/astraoneBidAdapter.md +++ b/modules/astraoneBidAdapter.md @@ -113,7 +113,7 @@ var adUnits = [{ - Prebid.js Banner gbt Example + Prebid.js Banner gpt Example + + + + + + ` +} + +const bidRequestMap = {} + +const createRenderer = (bid, dataToCreatePlace) => { + const renderer = new Renderer({ + targetId: bid.adUnitCode, + url: SDK_PATH, + callback() { + renderer.loaded = true + window.afp.createPlaceByData(dataToCreatePlace) + } + }) + + return renderer +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid({mediaTypes, params}) { + if (typeof params !== 'object' || typeof mediaTypes !== 'object') { + return false + } + + const {placeId, placeType, imageUrl, imageWidth, imageHeight} = params + const media = mediaTypes[mediaTypeByPlaceType[placeType]] + + if (placeId && media) { + if (mediaTypeByPlaceType[placeType] === VIDEO) { + if (!media.playerSize) { + return false + } + } else if (mediaTypeByPlaceType[placeType] === BANNER) { + if (!media.sizes) { + return false + } + } + if ([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE].includes(placeType)) { + if (imageUrl && imageWidth && imageHeight) { + return true + } + } else { + return true + } + } + return false + }, + buildRequests(validBidRequests, {refererInfo, gdprConsent}) { + const payload = { + pageUrl: IS_DEV ? TEST_PAGE_URL : refererInfo.referer, + gdprConsent: gdprConsent, + bidRequests: validBidRequests.map(validBidRequest => { + const {bidId, transactionId, sizes, params: { + placeId, placeType, imageUrl, imageWidth, imageHeight + }} = validBidRequest + bidRequestMap[bidId] = validBidRequest + const bidRequest = { + bidId, + transactionId, + sizes, + placeId, + } + if ([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE].includes(placeType)) { + Object.assign(bidRequest, { + imageUrl, + imageWidth: Math.floor(imageWidth), + imageHeight: Math.floor(imageHeight), + }) + } + return bidRequest + }) + } + + return { + method: REQUEST_METHOD, + url: SSP_ENDPOINT, + data: payload, + options: { + contentType: 'application/json' + } + } + }, + interpretResponse(serverResponse) { + let bids = serverResponse.body && serverResponse.body.bids + bids = Array.isArray(bids) ? bids : [] + + return bids.map(({bidId, cpm, width, height, creativeId, currency, netRevenue, adSettings, placeSettings}, index) => { + const bid = { + requestId: bidId, + cpm, + width, + height, + creativeId, + currency, + netRevenue, + meta: { + mediaType: mediaTypeByPlaceType[placeSettings.placeType], + }, + ttl: TTL + } + + const bidRequest = bidRequestMap[bidId] + const placeContainer = bidRequest.params.placeContainer + const dataToCreatePlace = { adSettings, placeSettings, placeContainer, isPrebid: true } + + if ([ + IN_IMAGE_BANNER_TYPE, + IN_IMAGE_MAX_BANNER_TYPE, + IN_CONTENT_BANNER_TYPE, + IN_CONTENT_STORY_TYPE, + ACTION_SCROLLER_TYPE, + ACTION_SCROLLER_LIGHT_TYPE, + ].includes(placeSettings.placeType)) { + bid.ad = wrapAd(dataToCreatePlace) + } else if ([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE].includes(placeSettings.placeType)) { + bid.vastXml = adSettings.content + bid.renderer = createRenderer(bid, dataToCreatePlace) + } + return bid + }) + } +} + +registerBidder(spec); diff --git a/modules/afpBidAdapter.md b/modules/afpBidAdapter.md new file mode 100644 index 00000000000..a1b05a1cd08 --- /dev/null +++ b/modules/afpBidAdapter.md @@ -0,0 +1,215 @@ +# Overview + + +**Module Name**: AstraLab Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: devops@astraone.io + +# Description + +You can use this adapter to get a bid from AstraLab. +Please reach out to your AstraLab account team before using this plugin to get placeId. +The code below returns a demo ad. + +About us: https://astralab.ai, https://afp.ai + +# Test Parameters +```js +var adUnits = [{ + code: 'iib-target', + mediaTypes: { + banner: { + sizes: [[0, 0]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "In-image", // or "In-image Max" + placeId: "60e7039918047b3fae304850", + placeContainer: '#iib-container', + imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", + imageWidth: 1000, + imageHeight: 524, + } + }] +}]; + +var adUnits = [{ + code: 'iib-target', + mediaTypes: { + banner: { + sizes: [[0, 0]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "In-content Banner", // or "In-content Stories" or "Action Scroller" or "Action Scroller Light" + placeId: "60e7039918047b3fae304850", + placeContainer: '#iib-container', + } + }] +}]; + +var adUnits = [{ + code: 'iib-target', + mediaTypes: { + video: { + playerSize: [[480, 320]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "In-content Video", // or "Out-content Video" + placeId: "60e7039918047b3fae304850", + placeContainer: '#iib-container', + } + }] +}]; +``` + +# Example page + +```html + + + + + Prebid.js In-image Example + + + + +

In-image

+
+
+ +
+ +
+ + + +``` +# Example page with GPT + +```html + + + + + Prebid.js In-image Example + + + + + +

In-image

+
+
+ +
+
+ +
+
+ + +``` diff --git a/modules/astraoneBidAdapter.js b/modules/astraoneBidAdapter.js deleted file mode 100644 index 2fec3892d27..00000000000 --- a/modules/astraoneBidAdapter.js +++ /dev/null @@ -1,137 +0,0 @@ -import * as utils from '../src/utils.js' -import { registerBidder } from '../src/adapters/bidderFactory.js' -import { BANNER } from '../src/mediaTypes.js' - -const BIDDER_CODE = 'astraone'; -const SSP_ENDPOINT = 'https://ssp.astraone.io/auction/prebid'; -const TTL = 60; - -function buildBidRequests(validBidRequests) { - return utils._map(validBidRequests, function(validBidRequest) { - const params = validBidRequest.params; - const bidRequest = { - bidId: validBidRequest.bidId, - transactionId: validBidRequest.transactionId, - sizes: validBidRequest.sizes, - placement: params.placement, - placeId: params.placeId, - imageUrl: params.imageUrl - }; - - return bidRequest; - }) -} - -function buildBid(bidData) { - const bid = { - requestId: bidData.bidId, - cpm: bidData.price, - width: bidData.width, - height: bidData.height, - creativeId: bidData.content.seanceId, - currency: bidData.currency, - netRevenue: true, - meta: { - mediaType: BANNER, - }, - ttl: TTL, - content: bidData.content - }; - - bid.ad = wrapAd(bid, bidData); - - return bid; -} - -function getMediaTypeFromBid(bid) { - return bid.mediaTypes && Object.keys(bid.mediaTypes)[0] -} - -function wrapAd(bid, bidData) { - return ` - - - - - - - - -
- - - `; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid(bid) { - return ( - getMediaTypeFromBid(bid) === BANNER && - !!bid.params.placeId && - !!bid.params.imageUrl && - !!bid.params.placement && - (bid.params.placement === 'inImage') - ); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests(validBidRequests, bidderRequest) { - const payload = { - url: bidderRequest.refererInfo.referer, - cmp: !!bidderRequest.gdprConsent, - bidRequests: buildBidRequests(validBidRequests) - }; - - if (payload.cmp) { - const gdprApplies = bidderRequest.gdprConsent.gdprApplies; - if (gdprApplies !== undefined) payload['ga'] = gdprApplies; - payload['cs'] = bidderRequest.gdprConsent.consentString; - } - - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: SSP_ENDPOINT, - data: payloadString, - options: { - contentType: 'application/json' - } - } - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse) { - const bids = serverResponse.body && serverResponse.body.bids; - - return Array.isArray(bids) ? bids.map(bid => buildBid(bid)) : [] - } - -} -registerBidder(spec); diff --git a/modules/astraoneBidAdapter.md b/modules/astraoneBidAdapter.md deleted file mode 100644 index e090cfe1e54..00000000000 --- a/modules/astraoneBidAdapter.md +++ /dev/null @@ -1,202 +0,0 @@ -# Overview - - -**Module Name**: AstraOne Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: prebid@astraone.io - -# Description - -You can use this adapter to get a bid from AstraOne. -Please reach out to your AstraOne account team before using this plugin to get placeId. -The code below returns a demo ad. - -About us: https://astraone.io - -# Test Parameters -```js -var adUnits = [{ - code: 'test-div', - mediaTypes: { - banner: { - sizes: [1, 1], - } - }, - bids: [{ - bidder: "astraone", - params: { - placement: "inImage", - placeId: "5f477bf94d506ebe2c4240f3", - imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg" - } - }] -}]; -``` - -# Example page - -```html - - - - - Prebid.js Banner Example - - - - - - -

Prebid.js InImage Banner Test

- -
- - -
- - - -``` -# Example page with GPT - -```html - - - - - Prebid.js Banner gpt Example - - - - - - -

Prebid.js InImage Banner gpt Test

- -
- - - -
- - -``` diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js new file mode 100644 index 00000000000..c220d052ead --- /dev/null +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -0,0 +1,302 @@ +import cloneDeep from 'lodash/cloneDeep' +import unset from 'lodash/unset' +import { expect } from 'chai' +import { BANNER, VIDEO } from '../../../src/mediaTypes.js' +import { + spec, + IN_IMAGE_BANNER_TYPE, + IN_IMAGE_MAX_BANNER_TYPE, + IN_CONTENT_BANNER_TYPE, + IN_CONTENT_VIDEO_TYPE, + OUT_CONTENT_VIDEO_TYPE, + IN_CONTENT_STORY_TYPE, + ACTION_SCROLLER_TYPE, + ACTION_SCROLLER_LIGHT_TYPE, + BIDDER_CODE, + SSP_ENDPOINT, + REQUEST_METHOD, + TEST_PAGE_URL, + IS_DEV, mediaTypeByPlaceType +} from 'modules/afpBidAdapter.js' + +const placeId = '60e7039918047b3fae304850' +const bidId = '2a67c5577ff6a5' +const transactionId = '7e8515a2-2ed9-4733-b976-6c2596a03287' +const imageUrl = 'https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png' +const placeContainer = '#container' +const imageWidth = 600 +const imageHeight = 400 +const pageUrl = IS_DEV ? TEST_PAGE_URL : 'referer' +const sizes = [[imageWidth, imageHeight]] +const bidderRequest = { + refererInfo: { referer: pageUrl }, +} +const mediaTypeBanner = { [BANNER]: {sizes: [[imageWidth, imageHeight]]} } +const mediaTypeVideo = { [VIDEO]: {playerSize: [[imageWidth, imageHeight]]} } +const commonParams = { + placeId, + placeContainer, +} +const commonParamsForInImage = Object.assign({}, commonParams, { + imageUrl, + imageWidth, + imageHeight, +}) +const configByPlaceType = { + get [IN_IMAGE_BANNER_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParamsForInImage, { + placeType: IN_IMAGE_BANNER_TYPE + }), + }) + }, + get [IN_IMAGE_MAX_BANNER_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParamsForInImage, { + placeType: IN_IMAGE_MAX_BANNER_TYPE + }), + }) + }, + get [IN_CONTENT_BANNER_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParams, { + placeType: IN_CONTENT_BANNER_TYPE + }), + }) + }, + get [IN_CONTENT_VIDEO_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeVideo, + params: Object.assign({}, commonParams, { + placeType: IN_CONTENT_VIDEO_TYPE + }), + }) + }, + get [OUT_CONTENT_VIDEO_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeVideo, + params: Object.assign({}, commonParams, { + placeType: OUT_CONTENT_VIDEO_TYPE + }), + }) + }, + get [IN_CONTENT_STORY_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParams, { + placeType: IN_CONTENT_STORY_TYPE + }), + }) + }, + get [ACTION_SCROLLER_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParams, { + placeType: ACTION_SCROLLER_TYPE + }), + }) + }, + get [ACTION_SCROLLER_LIGHT_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParams, { + placeType: ACTION_SCROLLER_LIGHT_TYPE + }), + }) + }, +} +const getTransformedConfig = ({mediaTypes, params}) => { + return { + params: params, + sizes, + bidId, + bidder: BIDDER_CODE, + mediaTypes: mediaTypes, + transactionId, + } +} +const validBidRequests = Object.values(configByPlaceType).map(config => getTransformedConfig(config)) + +describe('AFP Adapter', function() { + describe('isBidRequestValid method', function() { + describe('returns true', function() { + describe('when config has all mandatory params', () => { + Object.entries(configByPlaceType).forEach(([placeType, config]) => { + it(`and ${placeType} config has the correct value`, function() { + const isBidRequestValid = spec.isBidRequestValid(config) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + }) + describe('returns false', function() { + const checkMissingParams = (placesTypes, missingParams) => + placesTypes.forEach(placeType => + missingParams.forEach(missingParam => { + const config = configByPlaceType[placeType] + it(`${placeType} does not have the ${missingParam}.`, function() { + unset(config, missingParam) + const isBidRequestValid = spec.isBidRequestValid(config) + expect(isBidRequestValid).to.equal(false) + }) + }) + ) + + describe('when params are not correct', function() { + checkMissingParams(Object.keys(configByPlaceType), ['params.placeId', 'params.placeType']) + checkMissingParams([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE], + ['params.imageUrl', 'params.imageWidth', 'params.imageHeight']) + + it('does not have a the correct placeType.', function() { + const config = configByPlaceType[IN_IMAGE_BANNER_TYPE] + config.params.placeType = 'something' + const isBidRequestValid = spec.isBidRequestValid(config) + expect(isBidRequestValid).to.equal(false) + }) + }) + describe('when video mediaType object is not correct.', function() { + checkMissingParams([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE], + [`mediaTypes.${VIDEO}.playerSize`, `mediaTypes.${VIDEO}`]) + checkMissingParams([ + IN_IMAGE_BANNER_TYPE, + IN_IMAGE_MAX_BANNER_TYPE, + IN_CONTENT_BANNER_TYPE, + IN_CONTENT_STORY_TYPE, + ACTION_SCROLLER_TYPE, + ACTION_SCROLLER_LIGHT_TYPE + ], [`mediaTypes.${BANNER}.sizes`, `mediaTypes.${BANNER}`]) + }) + }) + }) + + describe('buildRequests method', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + + it('Url should be correct', function() { + expect(request.url).to.equal(SSP_ENDPOINT) + }) + + it('Method should be correct', function() { + expect(request.method).to.equal(REQUEST_METHOD) + }) + + describe('Common data request should be correct', function() { + it('pageUrl should be correct', function() { + expect(request.data.pageUrl).to.equal(pageUrl) + }) + it('bidRequests should be array', function() { + expect(Array.isArray(request.data.bidRequests)).to.equal(true) + }) + + request.data.bidRequests.forEach((bid, index) => { + describe(`bid with ${validBidRequests[index].params.placeType} should be correct`, function() { + it('bidId should be correct', function() { + expect(bid.bidId).to.equal(bidId) + }) + it('placeId should be correct', function() { + expect(bid.placeId).to.equal(placeId) + }) + it('transactionId should be correct', function() { + expect(bid.transactionId).to.equal(transactionId) + }) + it('sizes should be correct', function() { + expect(bid.sizes).to.equal(sizes) + }) + + if ([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE].includes(validBidRequests[index].params.placeType)) { + it('imageUrl should be correct', function() { + expect(bid.imageUrl).to.equal(imageUrl) + }) + it('imageWidth should be correct', function() { + expect(bid.imageWidth).to.equal(Math.floor(imageWidth)) + }) + it('imageHeight should be correct', function() { + expect(bid.imageHeight).to.equal(Math.floor(imageHeight)) + }) + } + }) + }) + }) + }) + + describe('interpretResponse method', function() { + it('should return a void array, when the server response are not correct.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { + body: {} + } + const bids = spec.interpretResponse(serverResponse, request) + expect(Array.isArray(bids)).to.equal(true) + expect(bids.length).to.equal(0) + }) + it('should return a void array, when the server response have not got bids.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { body: { bids: [] } } + const bids = spec.interpretResponse(serverResponse, request) + expect(Array.isArray(bids)).to.equal(true) + expect(bids.length).to.equal(0) + }) + describe('when the server response return a bids', function() { + Object.keys(configByPlaceType).forEach(placeType => { + it(`should return a bid with ${placeType} placeType`, function() { + const cpm = 10 + const currency = 'RUB' + const creativeId = '123' + const netRevenue = true + const width = sizes[0][0] + const height = sizes[0][1] + const adSettings = { + content: 'html' + } + const placeSettings = { + placeType, + } + const request = spec.buildRequests([validBidRequests[0]], bidderRequest) + const serverResponse = { + body: { + bids: [ + { + bidId, + cpm, + currency, + creativeId, + netRevenue, + width, + height, + adSettings, + placeSettings, + } + ] + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal(bidId) + expect(bids[0].meta.mediaType).to.equal(mediaTypeByPlaceType[placeSettings.placeType]) + expect(bids[0].cpm).to.equal(cpm) + expect(bids[0].width).to.equal(width) + expect(bids[0].height).to.equal(height) + expect(bids[0].currency).to.equal(currency) + expect(bids[0].netRevenue).to.equal(netRevenue) + + if ([ + IN_IMAGE_BANNER_TYPE, + IN_IMAGE_MAX_BANNER_TYPE, + IN_CONTENT_BANNER_TYPE, + IN_CONTENT_STORY_TYPE, + ACTION_SCROLLER_TYPE, + ACTION_SCROLLER_LIGHT_TYPE, + ].includes(placeSettings.placeType)) { + expect(typeof bids[0].ad).to.equal('string') + } else if ([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE].includes(placeSettings.placeType)) { + expect(typeof bids[0].vastXml).to.equal('string') + expect(typeof bids[0].renderer).to.equal('object') + } + }) + }) + }) + }) +}) diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js deleted file mode 100644 index 0e545081869..00000000000 --- a/test/spec/modules/astraoneBidAdapter_spec.js +++ /dev/null @@ -1,212 +0,0 @@ -import { expect } from 'chai' -import { spec } from 'modules/astraoneBidAdapter.js' - -function getSlotConfigs(mediaTypes, params) { - return { - params: params, - sizes: [], - bidId: '2df8c0733f284e', - bidder: 'astraone', - mediaTypes: mediaTypes, - transactionId: '31a58515-3634-4e90-9c96-f86196db1459' - } -} - -describe('AstraOne Adapter', function() { - describe('isBidRequestValid method', function() { - const PLACE_ID = '5f477bf94d506ebe2c4240f3'; - const IMAGE_URL = 'https://creative.astraone.io/files/default_image-1-600x400.jpg'; - - describe('returns true', function() { - describe('when banner slot config has all mandatory params', () => { - describe('and placement has the correct value', function() { - const createBannerSlotConfig = placement => { - return getSlotConfigs( - { banner: {} }, - { - placeId: PLACE_ID, - imageUrl: IMAGE_URL, - placement - } - ) - } - const placements = ['inImage']; - placements.forEach(placement => { - it('should be ' + placement, function() { - const isBidRequestValid = spec.isBidRequestValid( - createBannerSlotConfig(placement) - ) - expect(isBidRequestValid).to.equal(true) - }) - }) - }) - }) - }) - describe('returns false', function() { - describe('when params are not correct', function() { - function createSlotconfig(params) { - return getSlotConfigs({ banner: {} }, params) - } - it('does not have the placeId.', function() { - const isBidRequestValid = spec.isBidRequestValid( - createSlotconfig({ - imageUrl: IMAGE_URL, - placement: 'inImage' - }) - ) - expect(isBidRequestValid).to.equal(false) - }) - it('does not have the imageUrl.', function() { - const isBidRequestValid = spec.isBidRequestValid( - createSlotconfig({ - placeId: PLACE_ID, - placement: 'inImage' - }) - ) - expect(isBidRequestValid).to.equal(false) - }) - it('does not have the placement.', function() { - const isBidRequestValid = spec.isBidRequestValid( - createSlotconfig({ - placeId: PLACE_ID, - imageUrl: IMAGE_URL, - }) - ) - expect(isBidRequestValid).to.equal(false) - }) - it('does not have a the correct placement.', function() { - const isBidRequestValid = spec.isBidRequestValid( - createSlotconfig({ - placeId: PLACE_ID, - imageUrl: IMAGE_URL, - placement: 'something' - }) - ) - expect(isBidRequestValid).to.equal(false) - }) - }) - }) - }) - - describe('buildRequests method', function() { - const bidderRequest = { - refererInfo: { referer: 'referer' } - } - const mandatoryParams = { - placeId: '5af45ad34d506ee7acad0c26', - imageUrl: 'https://creative.astraone.io/files/default_image-1-600x400.jpg', - placement: 'inImage' - } - const validBidRequests = [ - getSlotConfigs({ banner: {} }, mandatoryParams) - ] - it('Url params should be correct ', function() { - const request = spec.buildRequests(validBidRequests, bidderRequest) - expect(request.method).to.equal('POST') - expect(request.url).to.equal('https://ssp.astraone.io/auction/prebid') - }) - - it('Common data request should be correct', function() { - const request = spec.buildRequests(validBidRequests, bidderRequest) - const data = JSON.parse(request.data) - expect(Array.isArray(data.bidRequests)).to.equal(true) - data.bidRequests.forEach(bid => { - expect(bid.placeId).to.equal('5af45ad34d506ee7acad0c26') - expect(typeof bid.imageUrl).to.equal('string') - }) - }) - - describe('GDPR params', function() { - describe('when there are not consent management platform', function() { - it('cmp should be false', function() { - const request = spec.buildRequests(validBidRequests, bidderRequest) - const data = JSON.parse(request.data) - expect(data.cmp).to.equal(false) - }) - }) - describe('when there are consent management platform', function() { - it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() { - bidderRequest['gdprConsent'] = { - gdprApplies: undefined, - consentString: 'consentString' - } - const request = spec.buildRequests(validBidRequests, bidderRequest) - const data = JSON.parse(request.data) - expect(data.cmp).to.equal(true) - expect(Object.keys(data).indexOf('data')).to.equal(-1) - expect(data.cs).to.equal('consentString') - }) - it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() { - bidderRequest['gdprConsent'] = { - gdprApplies: true, - consentString: 'consentString' - } - const request = spec.buildRequests(validBidRequests, bidderRequest) - const data = JSON.parse(request.data) - expect(data.cmp).to.equal(true) - expect(data.ga).to.equal(true) - expect(data.cs).to.equal('consentString') - }) - }) - }) - - describe('BidRequests params', function() { - const request = spec.buildRequests(validBidRequests, bidderRequest) - const data = JSON.parse(request.data) - const bidRequests = data.bidRequests - it('should request a Banner', function() { - const bannerBid = bidRequests[0] - expect(bannerBid.bidId).to.equal('2df8c0733f284e') - expect(bannerBid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') - expect(bannerBid.placeId).to.equal('5af45ad34d506ee7acad0c26') - }) - }) - }) - - describe('interpret response method', function() { - it('should return a void array, when the server response have not got bids.', function() { - const serverResponse = { - body: [] - } - const bids = spec.interpretResponse(serverResponse) - expect(Array.isArray(bids)).to.equal(true) - expect(bids.length).to.equal(0) - }) - describe('when the server response return a bid', function() { - describe('the bid is a banner', function() { - it('should return a banner bid', function() { - const serverResponse = { - body: { - bids: [ - { - bidId: '2df8c0733f284e', - price: 0.5, - currency: 'USD', - content: { - content: 'html', - actionUrls: {}, - seanceId: '123123' - }, - width: 100, - height: 100, - ttl: 360 - } - ] - } - } - const bids = spec.interpretResponse(serverResponse) - expect(bids.length).to.equal(1) - expect(bids[0].requestId).to.equal('2df8c0733f284e') - expect(bids[0].creativeId).to.equal('123123') - expect(bids[0].cpm).to.equal(0.5) - expect(bids[0].width).to.equal(100) - expect(bids[0].height).to.equal(100) - expect(bids[0].currency).to.equal('USD') - expect(bids[0].netRevenue).to.equal(true) - expect(typeof bids[0].ad).to.equal('string') - expect(typeof bids[0].content).to.equal('object') - }) - }) - }) - }) -}) From 427aa9ad8c6f27dfd3b646101bc0a890a86d841e Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 13 Aug 2021 16:25:44 +0300 Subject: [PATCH 07/18] replace "AstraLab" with "AFP" --- modules/afpBidAdapter.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/afpBidAdapter.md b/modules/afpBidAdapter.md index a1b05a1cd08..7a0ea513e11 100644 --- a/modules/afpBidAdapter.md +++ b/modules/afpBidAdapter.md @@ -1,17 +1,17 @@ # Overview -**Module Name**: AstraLab Bidder Adapter +**Module Name**: AFP Bidder Adapter **Module Type**: Bidder Adapter **Maintainer**: devops@astraone.io # Description -You can use this adapter to get a bid from AstraLab. -Please reach out to your AstraLab account team before using this plugin to get placeId. +You can use this adapter to get a bid from AFP. +Please reach out to your AFP account team before using this plugin to get placeId. The code below returns a demo ad. -About us: https://astralab.ai, https://afp.ai +About us: https://afp.ai # Test Parameters ```js From b3bd86b19203cb5b4e308fd87ce178a972447e7a Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 13 Aug 2021 18:55:17 +0300 Subject: [PATCH 08/18] fix prefixes in example pages --- integrationExamples/gpt/afpExample.html | 12 ++++++------ integrationExamples/gpt/afpGamExample.html | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/integrationExamples/gpt/afpExample.html b/integrationExamples/gpt/afpExample.html index e3782e93c89..1e342accd87 100644 --- a/integrationExamples/gpt/afpExample.html +++ b/integrationExamples/gpt/afpExample.html @@ -41,7 +41,7 @@ }] }, { - code: 'asb-target', + code: 'as-target', mediaTypes: { banner: { sizes: [500, 500], @@ -52,7 +52,7 @@ params: { placeType: "Action Scroller", placeId: "60f15a8515770d5ab7c7f885", - placeContainer: '#asb-container', + placeContainer: '#as-container', } }] }]; @@ -80,8 +80,8 @@ pbjs.renderAd(iframe.contentDocument, params['hb_adid']); } - params = pbjs.getAdserverTargetingForAdUnitCode("asb-target"); - iframe = document.getElementById("asb-target"); + params = pbjs.getAdserverTargetingForAdUnitCode("as-target"); + iframe = document.getElementById("as-target"); if (params && params['hb_adid']) { pbjs.renderAd(iframe.contentDocument, params['hb_adid']); @@ -108,8 +108,8 @@

In-content Video

Action Scroller

-
- +
+
diff --git a/integrationExamples/gpt/afpGamExample.html b/integrationExamples/gpt/afpGamExample.html index 48d79cc812b..e60a195dd16 100644 --- a/integrationExamples/gpt/afpGamExample.html +++ b/integrationExamples/gpt/afpGamExample.html @@ -53,7 +53,7 @@ params: { placeType: "Action Scroller", placeId: "60f15a8515770d5ab7c7f885", - placeContainer: '#asb-container', + placeContainer: '#as-container', } }] }]; @@ -139,7 +139,7 @@

In-content Video

Action Scroller

-
+
+ + + +
+ + + `; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid(bid) { + return ( + getMediaTypeFromBid(bid) === BANNER && + !!bid.params.placeId && + !!bid.params.imageUrl && + !!bid.params.placement && + (bid.params.placement === 'inImage') + ); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests(validBidRequests, bidderRequest) { + const payload = { + url: bidderRequest.refererInfo.referer, + cmp: !!bidderRequest.gdprConsent, + bidRequests: buildBidRequests(validBidRequests) + }; + + if (payload.cmp) { + const gdprApplies = bidderRequest.gdprConsent.gdprApplies; + if (gdprApplies !== undefined) payload['ga'] = gdprApplies; + payload['cs'] = bidderRequest.gdprConsent.consentString; + } + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: SSP_ENDPOINT, + data: payloadString, + options: { + contentType: 'application/json' + } + } + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + const bids = serverResponse.body && serverResponse.body.bids; + + return Array.isArray(bids) ? bids.map(bid => buildBid(bid)) : [] + } + +} +registerBidder(spec); diff --git a/modules/astraoneBidAdapter.md b/modules/astraoneBidAdapter.md new file mode 100644 index 00000000000..e090cfe1e54 --- /dev/null +++ b/modules/astraoneBidAdapter.md @@ -0,0 +1,202 @@ +# Overview + + +**Module Name**: AstraOne Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid@astraone.io + +# Description + +You can use this adapter to get a bid from AstraOne. +Please reach out to your AstraOne account team before using this plugin to get placeId. +The code below returns a demo ad. + +About us: https://astraone.io + +# Test Parameters +```js +var adUnits = [{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [1, 1], + } + }, + bids: [{ + bidder: "astraone", + params: { + placement: "inImage", + placeId: "5f477bf94d506ebe2c4240f3", + imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg" + } + }] +}]; +``` + +# Example page + +```html + + + + + Prebid.js Banner Example + + + + + + +

Prebid.js InImage Banner Test

+ +
+ + +
+ + + +``` +# Example page with GPT + +```html + + + + + Prebid.js Banner gpt Example + + + + + + +

Prebid.js InImage Banner gpt Test

+ +
+ + + +
+ + +``` diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js new file mode 100644 index 00000000000..0e545081869 --- /dev/null +++ b/test/spec/modules/astraoneBidAdapter_spec.js @@ -0,0 +1,212 @@ +import { expect } from 'chai' +import { spec } from 'modules/astraoneBidAdapter.js' + +function getSlotConfigs(mediaTypes, params) { + return { + params: params, + sizes: [], + bidId: '2df8c0733f284e', + bidder: 'astraone', + mediaTypes: mediaTypes, + transactionId: '31a58515-3634-4e90-9c96-f86196db1459' + } +} + +describe('AstraOne Adapter', function() { + describe('isBidRequestValid method', function() { + const PLACE_ID = '5f477bf94d506ebe2c4240f3'; + const IMAGE_URL = 'https://creative.astraone.io/files/default_image-1-600x400.jpg'; + + describe('returns true', function() { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function() { + const createBannerSlotConfig = placement => { + return getSlotConfigs( + { banner: {} }, + { + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + placement + } + ) + } + const placements = ['inImage']; + placements.forEach(placement => { + it('should be ' + placement, function() { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig(placement) + ) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + }) + }) + describe('returns false', function() { + describe('when params are not correct', function() { + function createSlotconfig(params) { + return getSlotConfigs({ banner: {} }, params) + } + it('does not have the placeId.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + imageUrl: IMAGE_URL, + placement: 'inImage' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the imageUrl.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + placement: 'inImage' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have a the correct placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + placement: 'something' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + }) + }) + + describe('buildRequests method', function() { + const bidderRequest = { + refererInfo: { referer: 'referer' } + } + const mandatoryParams = { + placeId: '5af45ad34d506ee7acad0c26', + imageUrl: 'https://creative.astraone.io/files/default_image-1-600x400.jpg', + placement: 'inImage' + } + const validBidRequests = [ + getSlotConfigs({ banner: {} }, mandatoryParams) + ] + it('Url params should be correct ', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + expect(request.method).to.equal('POST') + expect(request.url).to.equal('https://ssp.astraone.io/auction/prebid') + }) + + it('Common data request should be correct', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(Array.isArray(data.bidRequests)).to.equal(true) + data.bidRequests.forEach(bid => { + expect(bid.placeId).to.equal('5af45ad34d506ee7acad0c26') + expect(typeof bid.imageUrl).to.equal('string') + }) + }) + + describe('GDPR params', function() { + describe('when there are not consent management platform', function() { + it('cmp should be false', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(false) + }) + }) + describe('when there are consent management platform', function() { + it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: undefined, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(Object.keys(data).indexOf('data')).to.equal(-1) + expect(data.cs).to.equal('consentString') + }) + it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: true, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(data.ga).to.equal(true) + expect(data.cs).to.equal('consentString') + }) + }) + }) + + describe('BidRequests params', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + const bidRequests = data.bidRequests + it('should request a Banner', function() { + const bannerBid = bidRequests[0] + expect(bannerBid.bidId).to.equal('2df8c0733f284e') + expect(bannerBid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') + expect(bannerBid.placeId).to.equal('5af45ad34d506ee7acad0c26') + }) + }) + }) + + describe('interpret response method', function() { + it('should return a void array, when the server response have not got bids.', function() { + const serverResponse = { + body: [] + } + const bids = spec.interpretResponse(serverResponse) + expect(Array.isArray(bids)).to.equal(true) + expect(bids.length).to.equal(0) + }) + describe('when the server response return a bid', function() { + describe('the bid is a banner', function() { + it('should return a banner bid', function() { + const serverResponse = { + body: { + bids: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: { + content: 'html', + actionUrls: {}, + seanceId: '123123' + }, + width: 100, + height: 100, + ttl: 360 + } + ] + } + } + const bids = spec.interpretResponse(serverResponse) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].creativeId).to.equal('123123') + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(100) + expect(bids[0].height).to.equal(100) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(typeof bids[0].ad).to.equal('string') + expect(typeof bids[0].content).to.equal('object') + }) + }) + }) + }) +}) From a2d1760ad4b15d21b5b0a2161667b86a22e70fb2 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 20 Aug 2021 13:35:58 +0300 Subject: [PATCH 10/18] fix error while testing in CircleCI --- test/spec/modules/afpBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index c220d052ead..49990acbd6a 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -118,7 +118,7 @@ const getTransformedConfig = ({mediaTypes, params}) => { transactionId, } } -const validBidRequests = Object.values(configByPlaceType).map(config => getTransformedConfig(config)) +const validBidRequests = Object.keys(configByPlaceType).map(key => getTransformedConfig(configByPlaceType[key])) describe('AFP Adapter', function() { describe('isBidRequestValid method', function() { From 31224ed19b624c5c639bf59f17abcd67061e6768 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 20 Aug 2021 13:46:28 +0300 Subject: [PATCH 11/18] update AFP Adapter and add page examples --- test/spec/modules/afpBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 49990acbd6a..3937c0f6f05 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -124,9 +124,9 @@ describe('AFP Adapter', function() { describe('isBidRequestValid method', function() { describe('returns true', function() { describe('when config has all mandatory params', () => { - Object.entries(configByPlaceType).forEach(([placeType, config]) => { + Object.keys(configByPlaceType).forEach(placeType => { it(`and ${placeType} config has the correct value`, function() { - const isBidRequestValid = spec.isBidRequestValid(config) + const isBidRequestValid = spec.isBidRequestValid(configByPlaceType[placeType]) expect(isBidRequestValid).to.equal(true) }) }) From b9d9c7a2c0b43c29557be0b67cffb3ff9113fef5 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 20 Aug 2021 13:47:32 +0300 Subject: [PATCH 12/18] Revert "update AFP Adapter and add page examples" This reverts commit 31224ed19b624c5c639bf59f17abcd67061e6768. --- test/spec/modules/afpBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 3937c0f6f05..49990acbd6a 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -124,9 +124,9 @@ describe('AFP Adapter', function() { describe('isBidRequestValid method', function() { describe('returns true', function() { describe('when config has all mandatory params', () => { - Object.keys(configByPlaceType).forEach(placeType => { + Object.entries(configByPlaceType).forEach(([placeType, config]) => { it(`and ${placeType} config has the correct value`, function() { - const isBidRequestValid = spec.isBidRequestValid(configByPlaceType[placeType]) + const isBidRequestValid = spec.isBidRequestValid(config) expect(isBidRequestValid).to.equal(true) }) }) From 3c05927258f70aeff70692468cd05fb2203aadcc Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 20 Aug 2021 13:49:23 +0300 Subject: [PATCH 13/18] fix error while testing in CircleCI --- test/spec/modules/afpBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 49990acbd6a..3937c0f6f05 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -124,9 +124,9 @@ describe('AFP Adapter', function() { describe('isBidRequestValid method', function() { describe('returns true', function() { describe('when config has all mandatory params', () => { - Object.entries(configByPlaceType).forEach(([placeType, config]) => { + Object.keys(configByPlaceType).forEach(placeType => { it(`and ${placeType} config has the correct value`, function() { - const isBidRequestValid = spec.isBidRequestValid(config) + const isBidRequestValid = spec.isBidRequestValid(configByPlaceType[placeType]) expect(isBidRequestValid).to.equal(true) }) }) From 11bbc581d82e712f5d509a699b8e404cc6e955a3 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 20 Aug 2021 14:06:14 +0300 Subject: [PATCH 14/18] fix error while testing in CircleCI --- test/spec/modules/afpBidAdapter_spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 3937c0f6f05..194419aae0e 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -1,3 +1,4 @@ +import includes from 'core-js-pure/features/array/includes.js' import cloneDeep from 'lodash/cloneDeep' import unset from 'lodash/unset' import { expect } from 'chai' @@ -206,7 +207,7 @@ describe('AFP Adapter', function() { expect(bid.sizes).to.equal(sizes) }) - if ([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE].includes(validBidRequests[index].params.placeType)) { + if (includes([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE], validBidRequests[index].params.placeType)) { it('imageUrl should be correct', function() { expect(bid.imageUrl).to.equal(imageUrl) }) @@ -282,16 +283,16 @@ describe('AFP Adapter', function() { expect(bids[0].currency).to.equal(currency) expect(bids[0].netRevenue).to.equal(netRevenue) - if ([ + if (includes([ IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE, IN_CONTENT_BANNER_TYPE, IN_CONTENT_STORY_TYPE, ACTION_SCROLLER_TYPE, ACTION_SCROLLER_LIGHT_TYPE, - ].includes(placeSettings.placeType)) { + ], placeSettings.placeType)) { expect(typeof bids[0].ad).to.equal('string') - } else if ([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE].includes(placeSettings.placeType)) { + } else if (includes([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE], placeSettings.placeType)) { expect(typeof bids[0].vastXml).to.equal('string') expect(typeof bids[0].renderer).to.equal('object') } From 7673e67a28daf85574839ab2c718a45bc769b214 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 20 Aug 2021 14:21:50 +0300 Subject: [PATCH 15/18] fix error while testing in CircleCI --- modules/afpBidAdapter.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/afpBidAdapter.js b/modules/afpBidAdapter.js index a61cc430ec9..a103c69a6c4 100644 --- a/modules/afpBidAdapter.js +++ b/modules/afpBidAdapter.js @@ -1,3 +1,4 @@ +import includes from 'core-js-pure/features/array/includes.js' import { registerBidder } from '../src/adapters/bidderFactory.js' import { Renderer } from '../src/Renderer.js' import { BANNER, VIDEO } from '../src/mediaTypes.js' @@ -81,7 +82,7 @@ export const spec = { return false } } - if ([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE].includes(placeType)) { + if (includes([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE], placeType)) { if (imageUrl && imageWidth && imageHeight) { return true } @@ -106,7 +107,7 @@ export const spec = { sizes, placeId, } - if ([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE].includes(placeType)) { + if (includes([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE], placeType)) { Object.assign(bidRequest, { imageUrl, imageWidth: Math.floor(imageWidth), @@ -149,16 +150,16 @@ export const spec = { const placeContainer = bidRequest.params.placeContainer const dataToCreatePlace = { adSettings, placeSettings, placeContainer, isPrebid: true } - if ([ + if (includes([ IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE, IN_CONTENT_BANNER_TYPE, IN_CONTENT_STORY_TYPE, ACTION_SCROLLER_TYPE, ACTION_SCROLLER_LIGHT_TYPE, - ].includes(placeSettings.placeType)) { + ], placeSettings.placeType)) { bid.ad = wrapAd(dataToCreatePlace) - } else if ([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE].includes(placeSettings.placeType)) { + } else if (includes([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE], placeSettings.placeType)) { bid.vastXml = adSettings.content bid.renderer = createRenderer(bid, dataToCreatePlace) } From b57bea041969f423ce4c00558a83fbf72dedf290 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 3 Sep 2021 17:43:33 +0300 Subject: [PATCH 16/18] replace test ids --- integrationExamples/gpt/afpExample.html | 2 +- integrationExamples/gpt/afpGamExample.html | 2 +- modules/afpBidAdapter.md | 10 +++++----- test/spec/modules/afpBidAdapter_spec.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/integrationExamples/gpt/afpExample.html b/integrationExamples/gpt/afpExample.html index 1e342accd87..86e2a30034f 100644 --- a/integrationExamples/gpt/afpExample.html +++ b/integrationExamples/gpt/afpExample.html @@ -16,7 +16,7 @@ bidder: "afp", params: { placeType: "In-image", - placeId: "60e7039918047b3fae304850", + placeId: "613221112871613d1517d181", placeContainer: '#iib-container', imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", imageWidth: 1000, diff --git a/integrationExamples/gpt/afpGamExample.html b/integrationExamples/gpt/afpGamExample.html index e60a195dd16..64cb169893c 100644 --- a/integrationExamples/gpt/afpGamExample.html +++ b/integrationExamples/gpt/afpGamExample.html @@ -17,7 +17,7 @@ bidder: "afp", params: { placeType: "In-image", - placeId: "60e7039918047b3fae304850", + placeId: "613221112871613d1517d181", placeContainer: '#iib-container', imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", imageWidth: 600, diff --git a/modules/afpBidAdapter.md b/modules/afpBidAdapter.md index 7a0ea513e11..9cd4b034b49 100644 --- a/modules/afpBidAdapter.md +++ b/modules/afpBidAdapter.md @@ -26,7 +26,7 @@ var adUnits = [{ bidder: "afp", params: { placeType: "In-image", // or "In-image Max" - placeId: "60e7039918047b3fae304850", + placeId: "613221112871613d1517d181", placeContainer: '#iib-container', imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", imageWidth: 1000, @@ -46,7 +46,7 @@ var adUnits = [{ bidder: "afp", params: { placeType: "In-content Banner", // or "In-content Stories" or "Action Scroller" or "Action Scroller Light" - placeId: "60e7039918047b3fae304850", + placeId: "{{id from personal account}}", placeContainer: '#iib-container', } }] @@ -63,7 +63,7 @@ var adUnits = [{ bidder: "afp", params: { placeType: "In-content Video", // or "Out-content Video" - placeId: "60e7039918047b3fae304850", + placeId: "{{id from personal account}}", placeContainer: '#iib-container', } }] @@ -91,7 +91,7 @@ var adUnits = [{ bidder: "afp", params: { placeType: "In-image", - placeId: "60e7039918047b3fae304850", + placeId: "613221112871613d1517d181", placeContainer: '#iib-container', imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", imageWidth: 1000, @@ -154,7 +154,7 @@ var adUnits = [{ bidder: "afp", params: { placeType: "In-image", - placeId: "60e7039918047b3fae304850", + placeId: "613221112871613d1517d181", placeContainer: '#iib-container', imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", imageWidth: 600, diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 194419aae0e..3ac6eb5deba 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -20,7 +20,7 @@ import { IS_DEV, mediaTypeByPlaceType } from 'modules/afpBidAdapter.js' -const placeId = '60e7039918047b3fae304850' +const placeId = '613221112871613d1517d181' const bidId = '2a67c5577ff6a5' const transactionId = '7e8515a2-2ed9-4733-b976-6c2596a03287' const imageUrl = 'https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png' From 42c60edb41f68c9ea6d5fd492c21a81b130c3936 Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 17 Sep 2021 14:59:28 +0300 Subject: [PATCH 17/18] add new format "Just Banner" and refactoring --- modules/afpBidAdapter.js | 13 ++++--------- test/spec/modules/afpBidAdapter_spec.js | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/modules/afpBidAdapter.js b/modules/afpBidAdapter.js index a103c69a6c4..68941ff17c9 100644 --- a/modules/afpBidAdapter.js +++ b/modules/afpBidAdapter.js @@ -18,6 +18,7 @@ export const OUT_CONTENT_VIDEO_TYPE = 'Out-content Video' export const IN_CONTENT_STORY_TYPE = 'In-content Stories' export const ACTION_SCROLLER_TYPE = 'Action Scroller' export const ACTION_SCROLLER_LIGHT_TYPE = 'Action Scroller Light' +export const JUST_BANNER_TYPE = 'Just Banner' export const mediaTypeByPlaceType = { [IN_IMAGE_BANNER_TYPE]: BANNER, @@ -26,6 +27,7 @@ export const mediaTypeByPlaceType = { [IN_CONTENT_STORY_TYPE]: BANNER, [ACTION_SCROLLER_TYPE]: BANNER, [ACTION_SCROLLER_LIGHT_TYPE]: BANNER, + [JUST_BANNER_TYPE]: BANNER, [IN_CONTENT_VIDEO_TYPE]: VIDEO, [OUT_CONTENT_VIDEO_TYPE]: VIDEO, } @@ -150,16 +152,9 @@ export const spec = { const placeContainer = bidRequest.params.placeContainer const dataToCreatePlace = { adSettings, placeSettings, placeContainer, isPrebid: true } - if (includes([ - IN_IMAGE_BANNER_TYPE, - IN_IMAGE_MAX_BANNER_TYPE, - IN_CONTENT_BANNER_TYPE, - IN_CONTENT_STORY_TYPE, - ACTION_SCROLLER_TYPE, - ACTION_SCROLLER_LIGHT_TYPE, - ], placeSettings.placeType)) { + if (mediaTypeByPlaceType[placeSettings.placeType] === BANNER) { bid.ad = wrapAd(dataToCreatePlace) - } else if (includes([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE], placeSettings.placeType)) { + } else if (mediaTypeByPlaceType[placeSettings.placeType] === VIDEO) { bid.vastXml = adSettings.content bid.renderer = createRenderer(bid, dataToCreatePlace) } diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 3ac6eb5deba..8e77a1f3e15 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -13,6 +13,7 @@ import { IN_CONTENT_STORY_TYPE, ACTION_SCROLLER_TYPE, ACTION_SCROLLER_LIGHT_TYPE, + JUST_BANNER_TYPE, BIDDER_CODE, SSP_ENDPOINT, REQUEST_METHOD, @@ -108,6 +109,14 @@ const configByPlaceType = { }), }) }, + get [JUST_BANNER_TYPE]() { + return cloneDeep({ + mediaTypes: mediaTypeBanner, + params: Object.assign({}, commonParams, { + placeType: JUST_BANNER_TYPE + }), + }) + }, } const getTransformedConfig = ({mediaTypes, params}) => { return { @@ -167,7 +176,8 @@ describe('AFP Adapter', function() { IN_CONTENT_BANNER_TYPE, IN_CONTENT_STORY_TYPE, ACTION_SCROLLER_TYPE, - ACTION_SCROLLER_LIGHT_TYPE + ACTION_SCROLLER_LIGHT_TYPE, + JUST_BANNER_TYPE ], [`mediaTypes.${BANNER}.sizes`, `mediaTypes.${BANNER}`]) }) }) @@ -283,16 +293,9 @@ describe('AFP Adapter', function() { expect(bids[0].currency).to.equal(currency) expect(bids[0].netRevenue).to.equal(netRevenue) - if (includes([ - IN_IMAGE_BANNER_TYPE, - IN_IMAGE_MAX_BANNER_TYPE, - IN_CONTENT_BANNER_TYPE, - IN_CONTENT_STORY_TYPE, - ACTION_SCROLLER_TYPE, - ACTION_SCROLLER_LIGHT_TYPE, - ], placeSettings.placeType)) { + if (mediaTypeByPlaceType[placeSettings.placeType] === BANNER) { expect(typeof bids[0].ad).to.equal('string') - } else if (includes([IN_CONTENT_VIDEO_TYPE, OUT_CONTENT_VIDEO_TYPE], placeSettings.placeType)) { + } else if (mediaTypeByPlaceType[placeSettings.placeType] === VIDEO) { expect(typeof bids[0].vastXml).to.equal('string') expect(typeof bids[0].renderer).to.equal('object') } From c7f0e8afe9cf445093574f24455a060bcf09e5ed Mon Sep 17 00:00:00 2001 From: andrey_ka_97 Date: Fri, 17 Sep 2021 15:11:27 +0300 Subject: [PATCH 18/18] update examples in test page and in '.md' file --- integrationExamples/gpt/afpExample.html | 271 +++++++++++++++++------- modules/afpBidAdapter.md | 159 ++++++++++++-- 2 files changed, 345 insertions(+), 85 deletions(-) diff --git a/integrationExamples/gpt/afpExample.html b/integrationExamples/gpt/afpExample.html index 86e2a30034f..a1e6e800d69 100644 --- a/integrationExamples/gpt/afpExample.html +++ b/integrationExamples/gpt/afpExample.html @@ -5,57 +5,158 @@ Prebid.js Banner Example - +

In-image

-
+
-

In-content Video

+

In-image Max

-
- +
+ +
+ +
+ +

In-content Banner

+
+
+ +
+ +

In-content Stories

+
+
+

Action Scroller

@@ -111,5 +217,26 @@

Action Scroller

+ +

Action Scroller Light

+
+
+ +
+ +

Just Banner

+
+
+ +
+ +

In-content Video

+
+
+ +
+ + + diff --git a/modules/afpBidAdapter.md b/modules/afpBidAdapter.md index 9cd4b034b49..75ebf2bce48 100644 --- a/modules/afpBidAdapter.md +++ b/modules/afpBidAdapter.md @@ -25,8 +25,8 @@ var adUnits = [{ bids: [{ bidder: "afp", params: { - placeType: "In-image", // or "In-image Max" - placeId: "613221112871613d1517d181", + placeType: "In-image", + placeId: "613221112871613d1517d181", // id from personal account placeContainer: '#iib-container', imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", imageWidth: 1000, @@ -36,7 +36,7 @@ var adUnits = [{ }]; var adUnits = [{ - code: 'iib-target', + code: 'iimb-target', mediaTypes: { banner: { sizes: [[0, 0]], @@ -45,15 +45,103 @@ var adUnits = [{ bids: [{ bidder: "afp", params: { - placeType: "In-content Banner", // or "In-content Stories" or "Action Scroller" or "Action Scroller Light" - placeId: "{{id from personal account}}", - placeContainer: '#iib-container', + placeType: "In-image Max", + placeId: "6139ae472871613d1517dedd", // id from personal account + placeContainer: '#iimb-container', + imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png", + imageWidth: 1000, + imageHeight: 524, } }] }]; var adUnits = [{ - code: 'iib-target', + code: 'icb-target', + mediaTypes: { + banner: { + sizes: [[0, 0]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "In-content Banner", + placeId: "6139ae082871613d1517dec0", // id from personal account + placeContainer: '#icb-container', + } + }] +}]; + +var adUnits = [{ + code: 'ics-target', + mediaTypes: { + banner: { + sizes: [[0, 0]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "In-content Stories", + placeId: "6139ae292871613d1517ded3", // id from personal account + placeContainer: '#ics-container', + } + }] +}]; + +var adUnits = [{ + code: 'as-target', + mediaTypes: { + banner: { + sizes: [[0, 0]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "Action Scroller", + placeId: "6139adc12871613d1517deb0", // id from personal account + placeContainer: '#as-container', + } + }] +}]; + +var adUnits = [{ + code: 'asl-target', + mediaTypes: { + banner: { + sizes: [[0, 0]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "Action Scroller Light", + placeId: "6139adda2871613d1517deb8", // id from personal account + placeContainer: '#asl-container', + } + }] +}]; + +var adUnits = [{ + code: 'jb-target', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "Just Banner", + placeId: "6139ae832871613d1517dee9", // id from personal account + placeContainer: '#jb-container', + } + }] +}]; + +var adUnits = [{ + code: 'icv-target', mediaTypes: { video: { playerSize: [[480, 320]], @@ -62,9 +150,26 @@ var adUnits = [{ bids: [{ bidder: "afp", params: { - placeType: "In-content Video", // or "Out-content Video" - placeId: "{{id from personal account}}", - placeContainer: '#iib-container', + placeType: "In-content Video", + placeId: "6139ae182871613d1517deca", // id from personal account + placeContainer: '#icv-container', + } + }] +}]; + +var adUnits = [{ + code: 'ocv-target', + mediaTypes: { + video: { + playerSize: [[480, 320]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "Out-content Video", + placeId: "6139ae5b2871613d1517dee2", // id from personal account + placeContainer: '#ocv-container', // only the "body" tag is used as a container } }] }]; @@ -98,7 +203,22 @@ var adUnits = [{ imageHeight: 524, } }] - }]; + },{ + code: 'jb-target', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [{ + bidder: "afp", + params: { + placeType: "Just Banner", + placeId: "6139ae832871613d1517dee9", // id from personal account + placeContainer: '#jb-container', + } + }] + }]; var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; @@ -115,6 +235,13 @@ var adUnits = [{ if (params && params['hb_adid']) { pbjs.renderAd(iframe.contentDocument, params['hb_adid']); } + + params = pbjs.getAdserverTargetingForAdUnitCode("jb-target"); + iframe = document.getElementById("jb-target"); + + if (params && params['hb_adid']) { + pbjs.renderAd(iframe.contentDocument, params['hb_adid']); + } } }); }); @@ -123,11 +250,17 @@ var adUnits = [{

In-image

-
+
+ +

Just Banner

+
+
+ +
@@ -199,7 +332,7 @@ var adUnits = [{

In-image

-
+