Skip to content

Commit

Permalink
[AMXD-16] Cadent Bid Adapter: rename remaining references
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Denton committed Jun 6, 2023
1 parent a476fd3 commit cdad21c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
78 changes: 39 additions & 39 deletions modules/cadentApertureMXBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export const cadentAdapter = {
h: sizes[0][1]
};
},
formatVideoResponse: (bidResponse, emxBid, bidRequest) => {
bidResponse.vastXml = emxBid.adm;
formatVideoResponse: (bidResponse, cadentBid, bidRequest) => {
bidResponse.vastXml = cadentBid.adm;
if (bidRequest.bidderRequest && bidRequest.bidderRequest.bids && bidRequest.bidderRequest.bids.length > 0) {
const matchingBid = find(bidRequest.bidderRequest.bids, bid => bidResponse.requestId && bid.bidId && bidResponse.requestId === bid.bidId && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context === 'outstream');
if (matchingBid) {
bidResponse.renderer = cadentAdapter.createRenderer(bidResponse, {
id: emxBid.id,
id: cadentBid.id,
url: RENDERER_URL
});
}
Expand Down Expand Up @@ -148,34 +148,34 @@ export const cadentAdapter = {
ref: refInfo.ref || window.document.referrer
}
},
getGdpr: (bidRequests, emxData) => {
getGdpr: (bidRequests, cadentData) => {
if (bidRequests.gdprConsent) {
emxData.regs = {
cadentData.regs = {
ext: {
gdpr: bidRequests.gdprConsent.gdprApplies === true ? 1 : 0
}
};
}
if (bidRequests.gdprConsent && bidRequests.gdprConsent.gdprApplies) {
emxData.user = {
cadentData.user = {
ext: {
consent: bidRequests.gdprConsent.consentString
}
};
}

return emxData;
return cadentData;
},
getSupplyChain: (bidderRequest, emxData) => {
getSupplyChain: (bidderRequest, cadentData) => {
if (bidderRequest.bids[0] && bidderRequest.bids[0].schain) {
emxData.source = {
cadentData.source = {
ext: {
schain: bidderRequest.bids[0].schain
}
};
}

return emxData;
return cadentData;
},
// supporting eids
getEids(bidRequests) {
Expand Down Expand Up @@ -242,7 +242,7 @@ export const spec = {
return true;
},
buildRequests: function (validBidRequests, bidderRequest) {
const emxImps = [];
const cadentImps = [];
const timeout = bidderRequest.timeout || '';
const timestamp = Date.now();
const url = 'https://' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs');
Expand Down Expand Up @@ -271,33 +271,33 @@ export const spec = {
}
let typeSpecifics = isVideo ? { video: cadentAdapter.buildVideo(bid) } : { banner: cadentAdapter.buildBanner(bid) };
let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {};
let emxBid = Object.assign(data, typeSpecifics, bidfloorObj);
emxImps.push(emxBid);
let cadentBid = Object.assign(data, typeSpecifics, bidfloorObj);
cadentImps.push(cadentBid);
});

let emxData = {
let cadentData = {
id: bidderRequest.auctionId,
imp: emxImps,
imp: cadentImps,
device,
site,
cur: DEFAULT_CUR,
version: ADAPTER_VERSION
};

emxData = cadentAdapter.getGdpr(bidderRequest, Object.assign({}, emxData));
emxData = cadentAdapter.getSupplyChain(bidderRequest, Object.assign({}, emxData));
cadentData = cadentAdapter.getGdpr(bidderRequest, Object.assign({}, cadentData));
cadentData = cadentAdapter.getSupplyChain(bidderRequest, Object.assign({}, cadentData));
if (bidderRequest && bidderRequest.uspConsent) {
emxData.us_privacy = bidderRequest.uspConsent;
cadentData.us_privacy = bidderRequest.uspConsent;
}

// adding eid support
if (bidderRequest.userId) {
let eids = cadentAdapter.getEids(bidderRequest);
if (eids.length > 0) {
if (emxData.user && emxData.user.ext) {
emxData.user.ext.eids = eids;
if (cadentData.user && cadentData.user.ext) {
cadentData.user.ext.eids = eids;
} else {
emxData.user = {
cadentData.user = {
ext: {eids}
};
}
Expand All @@ -307,50 +307,50 @@ export const spec = {
return {
method: 'POST',
url,
data: JSON.stringify(emxData),
data: JSON.stringify(cadentData),
options: {
withCredentials: true
},
bidderRequest
};
},
interpretResponse: function (serverResponse, bidRequest) {
let emxBidResponses = [];
let cadentBidResponses = [];
let response = serverResponse.body || {};
if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) {
response.seatbid.forEach(function (emxBid) {
emxBid = emxBid.bid[0];
response.seatbid.forEach(function (cadentBid) {
cadentBid = cadentBid.bid[0];
let isVideo = false;
let adm = cadentAdapter.parseResponse(emxBid.adm) || '';
let adm = cadentAdapter.parseResponse(cadentBid.adm) || '';
let bidResponse = {
requestId: emxBid.id,
cpm: emxBid.price,
width: emxBid.w,
height: emxBid.h,
creativeId: emxBid.crid || emxBid.id,
dealId: emxBid.dealid || null,
requestId: cadentBid.id,
cpm: cadentBid.price,
width: cadentBid.w,
height: cadentBid.h,
creativeId: cadentBid.crid || cadentBid.id,
dealId: cadentBid.dealid || null,
currency: 'USD',
netRevenue: true,
ttl: emxBid.ttl,
ttl: cadentBid.ttl,
ad: adm
};
if (emxBid.adm && emxBid.adm.indexOf('<?xml version=') > -1) {
if (cadentBid.adm && cadentBid.adm.indexOf('<?xml version=') > -1) {
isVideo = true;
bidResponse = cadentAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest);
bidResponse = cadentAdapter.formatVideoResponse(bidResponse, Object.assign({}, cadentBid), bidRequest);
}
bidResponse.mediaType = (isVideo ? VIDEO : BANNER);

// support for adomain in prebid 5.0
if (emxBid.adomain && emxBid.adomain.length) {
if (cadentBid.adomain && cadentBid.adomain.length) {
bidResponse.meta = {
advertiserDomains: emxBid.adomain
advertiserDomains: cadentBid.adomain
};
}

emxBidResponses.push(bidResponse);
cadentBidResponses.push(bidResponse);
});
}
return emxBidResponses;
return cadentBidResponses;
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
const syncs = [];
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/cadentApertureMXBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ describe('Cadent Aperture MX Adapter', function () {
it('should not throw an error when decoding an improperly encoded adm', function () {
const badAdmServerResponse = utils.deepClone(serverRes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wi2VBQS7YAqwD4AK30UbqAlxodHRwczovL3d3dy5jZWxlYnV6ei5jb20vZy90YXlsb3Itc3dpZnQtZGVidXRzLXJlZC1oYWlyLWluLXN1Z2FybGFuZC12aWRlby8_YmlkZHJfZGVidWc9dHJ1ZfICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPERY8TEVBRl9OQU1FEgDyAh4KGjYdAPQqAUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMUoAMBqgMAwAOsAsgDANgDlCHgAwDoAwD4AwOABACSBAkvb3BlbnJ0YjKYBACiBA8xNDQuMTIxLjIzMy4yMzeoBIkWsgQMCAAQABgAIAAwADgAuAQAwAQAyASxgoIB0gQOMTM1NiNOWU0yOjQyODLaBAIIAeAEAPAE6PmBFPoEEgkAAAAAZqdHQBEAAAAgWpRewIgFAZgFAKAF____________AaoFFjQ5MTgxNTcxMzQxNTU2NTI2OTQ5ZTHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXW7gr6BQQIABAAkAYAmAYAuAYAwQYAAAAAAADwP8gGANAGwgTaBhYKEAAAAAAAAAAAAAAABQpQEAAYAOAGAfIGAggAgAcBiAcAoAcB\\&s\\=630dbbd55f593c7bfd9e7bccc4dbaa28203daaed\\&pp\\=\\$\\{EMX_MACRO\\}\\\"\\>\\<\\/script\\>';
badAdmServerResponse.seatbid[1].bid[0].adm = '%3F%%3Demx%3C3prebid';
badAdmServerResponse.seatbid[1].bid[0].adm = '%3F%%3Dcadent%3C3prebid';

assert.doesNotThrow(() => spec.interpretResponse({
body: badAdmServerResponse
Expand Down

0 comments on commit cdad21c

Please sign in to comment.