Skip to content

Commit

Permalink
Criteo Bid Adapter: Map native assets to slot.ext.assets
Browse files Browse the repository at this point in the history
  • Loading branch information
v.raybaud committed Apr 26, 2023
1 parent 21b9bbe commit 33dfb47
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
8 changes: 3 additions & 5 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 || {};
Expand Down Expand Up @@ -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;
}
Expand Down
56 changes: 56 additions & 0 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 33dfb47

Please sign in to comment.