From 33dfb47a9b20759f652d942e8344d40a55482f36 Mon Sep 17 00:00:00 2001 From: "v.raybaud" Date: Mon, 24 Apr 2023 15:50:02 +0200 Subject: [PATCH] Criteo Bid Adapter: Map native assets to slot.ext.assets --- modules/criteoBidAdapter.js | 8 ++-- test/spec/modules/criteoBidAdapter_spec.js | 56 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index a27f77349bf..8f24dd6c1aa 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -6,10 +6,8 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { find } from '../src/polyfill.js'; import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; // ref#2 import { getStorageManager } from '../src/storageManager.js'; -import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; import { getRefererInfo } from '../src/refererDetection.js'; import { hasPurpose1Consent } from '../src/utils/gpdr.js'; - const GVLID = 91; export const ADAPTER_VERSION = 35; const BIDDER_CODE = 'criteo'; @@ -146,9 +144,6 @@ export const spec = { * @return {ServerRequest} */ buildRequests: (bidRequests, bidderRequest) => { - // convert Native ORTB definition to old-style prebid native definition - bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); - let url; let data; let fpd = bidderRequest.ortb2 || {}; @@ -439,6 +434,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (bidRequest.params.ext) { slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext); } + if (bidRequest.nativeOrtbRequest?.assets) { + slot.ext = Object.assign({}, slot.ext, {assets: bidRequest.nativeOrtbRequest.assets}); + } if (bidRequest.params.publisherSubId) { slot.publishersubid = bidRequest.params.publisherSubId; } diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index 36d04d4b2e0..a1d738c3657 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -728,6 +728,62 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.slots[0].native).to.equal(true); }); + it('should map ortb native assets to slot ext assets', function () { + const assets = [{ + required: 1, + id: 1, + img: { + type: 3, + wmin: 100, + hmin: 100, + } + }, + { + required: 1, + id: 2, + title: { + len: 140, + } + }, + { + required: 1, + id: 3, + data: { + type: 1, + } + }, + { + required: 0, + id: 4, + data: { + type: 2, + } + }, + { + required: 0, + id: 5, + img: { + type: 1, + wmin: 20, + hmin: 20, + } + }]; + const bidRequests = [ + { + nativeOrtbRequest: { + assets: assets + }, + params: { + nativeCallback: function () { } + }, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.slots[0].native).to.equal(true); + expect(ortbRequest.slots[0].ext.assets).to.deep.equal(assets); + }); + it('should properly build a networkId request', function () { const bidderRequest = { refererInfo: {