Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add multiformat support for ringieraxelspringer adapter #40

Open
wants to merge 2 commits into
base: dreamlab-master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions modules/ringieraxelspringerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const buildBid = (ad, mediaType) => {
height: ad.height || 0
}

if (mediaType === 'native') {
if (ad.type === 'native') {
data.meta = { mediaType: NATIVE };
data.mediaType = NATIVE;
data.native = parseNativeResponse(ad) || {};
Expand Down Expand Up @@ -267,19 +267,22 @@ const getSlots = (bidRequests) => {
for (let i = 0; i < batchSize; i++) {
const adunit = bidRequests[i];
const slotSequence = deepAccess(adunit, 'params.slotSequence');
const creFormat = getAdUnitCreFormat(adunit);
const sizes = creFormat === 'native' ? 'fluid' : parseSizesInput(getAdUnitSizes(adunit)).join(',');
const creFormats = getAdUnitCreFormats(adunit);
const sizes = parseSizesInput(getAdUnitSizes(adunit))?.filter(Boolean);

if (creFormats.includes('native') && sizes?.indexOf('fluid') === -1) {
sizes.push('fluid');
}

queryString += `&slot${i}=${encodeURIComponent(adunit.params.slot)}&id${i}=${encodeURIComponent(adunit.bidId)}&composition${i}=CHILD`;

if (creFormat === 'native') {
queryString += `&cre_format${i}=native`;
}
queryString += `&cre_format${i}=${encodeURIComponent(creFormats.join())}`;

queryString += `&kvhb_format${i}=${creFormat === 'native' ? 'native' : 'banner'}`;
// change 'html' format to 'banner'
queryString += `&kvhb_format${i}=${encodeURIComponent(creFormats.map(format => format === 'html' ? 'banner' : format).join())}`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a po co to jest? czemu w getAdUnitCreFormats nie możemy od razu dodawać banner zamiast html?


if (sizes) {
queryString += `&iusizes${i}=${encodeURIComponent(sizes)}`;
if (Array.isArray(sizes)) {
queryString += `&iusizes${i}=${encodeURIComponent(sizes.join(','))}`;
}

if (slotSequence !== undefined && slotSequence !== null) {
Expand Down Expand Up @@ -333,19 +336,24 @@ const parseAuctionConfigs = (serverResponse, bidRequest) => {
}
}

const getAdUnitCreFormat = (adUnit) => {
const getAdUnitCreFormats = (adUnit) => {
if (!adUnit) {
return;
}

let creFormat = 'html';
let mediaTypes = Object.keys(adUnit.mediaTypes);
let creFormats = [];

if (mediaTypes && mediaTypes.length === 1 && mediaTypes.includes('native')) {
creFormat = 'native';
if (adUnit.mediaTypes) {
if (adUnit.mediaTypes.banner) {
creFormats.push('html');
}

if (adUnit.mediaTypes.native || adUnit.nativeParams) {
creFormats.push('native');
}
}

return creFormat;
return creFormats;
}

export const spec = {
Expand Down