Skip to content

Commit

Permalink
OFF-500 Support "startCompact" param for Prebid.JS #4
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-lei authored May 1, 2023
1 parent 302de4d commit ba3de3c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
31 changes: 19 additions & 12 deletions modules/flippBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DEFAULT_CURRENCY = 'USD';
const DEFAULT_CREATIVE_TYPE = 'NativeX';
const VALID_CREATIVE_TYPES = ['DTX', 'NativeX'];
const FLIPP_USER_KEY = 'flipp-uid';
const COMPACT_DEFAULT_HEIGHT = 600;

let userKey = null;
export const storage = getStorageManager({bidderCode: BIDDER_CODE});
Expand Down Expand Up @@ -112,6 +113,7 @@ export const spec = {
properties: {
...(!isEmpty(contentCode) && {contentCode: contentCode.slice(0, 32)}),
},
options: bid.params.options,
prebid: {
requestId: bid.bidId,
publisherNameIdentifier: bid.params.publisherNameIdentifier,
Expand Down Expand Up @@ -142,20 +144,25 @@ export const spec = {
*/
interpretResponse: function(serverResponse, bidRequest) {
if (!serverResponse?.body) return [];
const placements = bidRequest.data.placements;
const res = serverResponse.body;
if (!isEmpty(res) && !isEmpty(res.decisions) && !isEmpty(res.decisions.inline)) {
return res.decisions.inline.map(decision => ({
bidderCode: BIDDER_CODE,
requestId: decision.prebid?.requestId,
cpm: decision.prebid?.cpm,
width: decision.width,
height: decision.height,
creativeId: decision.adId,
currency: DEFAULT_CURRENCY,
netRevenue: true,
ttl: DEFAULT_TTL,
ad: decision.prebid?.creative,
}));
return res.decisions.inline.map(decision => {
const placement = placements.find(p => p.prebid.requestId === decision.prebid?.requestId);
const height = placement.options?.startCompact ? COMPACT_DEFAULT_HEIGHT : decision.height;
return {
bidderCode: BIDDER_CODE,
requestId: decision.prebid?.requestId,
cpm: decision.prebid?.cpm,
width: decision.width,
height,
creativeId: decision.adId,
currency: DEFAULT_CURRENCY,
netRevenue: true,
ttl: DEFAULT_TTL,
ad: decision.prebid?.creative,
}
});
}
return [];
},
Expand Down
3 changes: 3 additions & 0 deletions modules/flippBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ var adUnits = [
zoneIds: [260678], // Optional
userKey: "", // Optional
creativeType: 'NativeX', // Optional
options: {
startCompact: true // Optional, default to true
}
}
}
]
Expand Down

0 comments on commit ba3de3c

Please sign in to comment.