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

OFF-372 Support DTX/Hero in flippBidAdapter #2

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
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
27 changes: 26 additions & 1 deletion modules/flippBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
const NETWORK_ID = 11090;
const AD_TYPES = [4309, 641];
const DTX_TYPES = [5061];
const TARGET_NAME = 'inline';
const BIDDER_CODE = 'flipp';
const ENDPOINT = 'https://gateflipp.flippback.com/flyer-locator-service/prebid_campaigns';
const DEFAULT_TTL = 30;
const DEFAULT_CURRENCY = 'USD';
const DEFAULT_CREATIVE_TYPE = 'NativeX';
const VALID_CREATIVE_TYPES = ['DTX', 'NativeX'];

const generateUUID = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
Expand All @@ -17,6 +20,27 @@ const generateUUID = () => {
});
};

/**
* Determines if a creativeType is valid
*
* @param {string} creativeType The Creative Type to validate.
* @return string creativeType if this is a valid Creative Type, and 'NativeX' otherwise.
*/
const validateCreativeType = (creativeType) => {
if (creativeType && VALID_CREATIVE_TYPES.includes(creativeType)) {
return creativeType;
} else {
return DEFAULT_CREATIVE_TYPE;
}
};

const getAdTypes = (creativeType) => {
if (creativeType === 'DTX') {
return DTX_TYPES;
}
return AD_TYPES;
}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
Expand Down Expand Up @@ -45,13 +69,14 @@ export const spec = {
divName: TARGET_NAME,
networkId: NETWORK_ID,
siteId: bid.params.siteId,
adTypes: AD_TYPES,
adTypes: getAdTypes(bid.params.creativeType),
count: 1,
...(!isEmpty(bid.params.zoneIds) && {zoneIds: bid.params.zoneIds}),
properties: {
...(!isEmpty(contentCode) && {contentCode: contentCode.slice(0, 32)}),
},
prebid: {
creativeType: validateCreativeType(bid.params.creativeType),
requestId: bid.bidId,
publisherNameIdentifier: bid.params.publisherNameIdentifier,
height: bid.mediaTypes.banner.sizes[index][0],
Expand Down
1 change: 1 addition & 0 deletions modules/flippBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var adUnits = [
{
bidder: 'flipp',
params: {
creativeType: 'NativeX', // Optional, can be one of 'NativeX' (default) or 'DTX'
publisherNameIdentifier: 'wishabi-test-publisher', // Required
siteId: 1192075, // Required
zoneIds: [260678], // Optional
Expand Down