Skip to content

Commit

Permalink
Merge branch 'master' of github.com:prebid/Prebid.js
Browse files Browse the repository at this point in the history
  • Loading branch information
smenzer committed Sep 8, 2020
2 parents 22ce19f + 1676c76 commit d41a946
Show file tree
Hide file tree
Showing 13 changed files with 885 additions and 51 deletions.
2 changes: 1 addition & 1 deletion modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function storeConsentData(cmpConsentObject) {
vendorData: (cmpConsentObject) || undefined,
gdprApplies: cmpConsentObject && typeof cmpConsentObject.gdprApplies === 'boolean' ? cmpConsentObject.gdprApplies : gdprScope
};
if (cmpConsentObject.addtlConsent && utils.isStr(cmpConsentObject.addtlConsent)) {
if (cmpConsentObject && cmpConsentObject.addtlConsent && utils.isStr(cmpConsentObject.addtlConsent)) {
consentData.addtlConsent = cmpConsentObject.addtlConsent;
};
}
Expand Down
90 changes: 90 additions & 0 deletions modules/decenteradsBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'
import * as utils from '../src/utils.js'

const BIDDER_CODE = 'decenterads'
const URL = 'https://supply.decenterads.com/?c=o&m=multi'
const URL_SYNC = 'https://supply.decenterads.com/?c=o&m=cookie'

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

isBidRequestValid: function (opts) {
return Boolean(opts.bidId && opts.params && !isNaN(opts.params.placementId))
},

buildRequests: function (validBidRequests) {
validBidRequests = validBidRequests || []
let winTop = window
try {
window.top.location.toString()
winTop = window.top
} catch (e) { utils.logMessage(e) }

const location = utils.getWindowLocation()
const placements = []

for (let i = 0; i < validBidRequests.length; i++) {
const p = validBidRequests[i]

placements.push({
placementId: p.params.placementId,
bidId: p.bidId,
traffic: p.params.traffic || BANNER
})
}

return {
method: 'POST',
url: URL,
data: {
deviceWidth: winTop.screen.width,
deviceHeight: winTop.screen.height,
language: (navigator && navigator.language) ? navigator.language : '',
secure: +(location.protocol === 'https:'),
host: location.hostname,
page: location.pathname,
placements: placements
}
}
},

interpretResponse: function (opts) {
const body = opts.body
const response = []

for (let i = 0; i < body.length; i++) {
const item = body[i]
if (isBidResponseValid(item)) {
delete item.mediaType
response.push(item)
}
}

return response
},

getUserSyncs: function (syncOptions, serverResponses) {
return [{ type: 'image', url: URL_SYNC }]
}
}

registerBidder(spec)

function isBidResponseValid (bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId ||
!bid.ttl || !bid.currency) {
return false
}
switch (bid['mediaType']) {
case BANNER:
return Boolean(bid.width && bid.height && bid.ad)
case VIDEO:
return Boolean(bid.vastUrl)
case NATIVE:
return Boolean(bid.title && bid.image && bid.impressionTrackers)
default:
return false
}
}
91 changes: 91 additions & 0 deletions modules/gjirafaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'gjirafa';
const ENDPOINT_URL = 'https://central.gjirafa.com/bid';
const DIMENSION_SEPARATOR = 'x';
const SIZE_SEPARATOR = ';';

export const spec = {
code: BIDDER_CODE,
/**
* Determines whether or not the given bid request is valid.
*
* @param {BidRequest} bid The bid params to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
return !!(bid.params.propertyId && bid.params.placementId);
},
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
let response = validBidRequests.map(bidRequest => {
let sizes = generateSizeParam(bidRequest.sizes);
let propertyId = bidRequest.params.propertyId;
let placementId = bidRequest.params.placementId;
let adUnitId = bidRequest.adUnitCode;
let pageViewGuid = bidRequest.params.pageViewGuid || '';
let contents = bidRequest.params.contents || [];
const body = {
sizes: sizes,
adUnitId: adUnitId,
placementId: placementId,
propertyId: propertyId,
pageViewGuid: pageViewGuid,
url: bidderRequest ? bidderRequest.refererInfo.referer : '',
requestid: bidRequest.bidderRequestId,
bidid: bidRequest.bidId,
contents: contents
};
return {
method: 'POST',
url: ENDPOINT_URL,
data: body
};
});
return response
},
/**
* Unpack the response from the server into a list of bids.
*
* @param {ServerResponse} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, bidRequest) {
window.adnResponse = serverResponse;
const responses = serverResponse.body;
const bidResponses = [];
for (var i = 0; i < responses.length; i++) {
const bidResponse = {
requestId: bidRequest.data.bidid,
cpm: responses[i].CPM,
width: responses[i].Width,
height: responses[i].Height,
creativeId: responses[i].CreativeId,
currency: responses[i].Currency,
netRevenue: responses[i].NetRevenue,
ttl: responses[i].TTL,
referrer: responses[i].Referrer,
ad: responses[i].Ad
};
bidResponses.push(bidResponse);
}
return bidResponses;
}
}

/**
* Generate size param for bid request using sizes array
*
* @param {Array} sizes Possible sizes for the ad unit.
* @return {string} Processed sizes param to be used for the bid request.
*/
function generateSizeParam(sizes) {
return sizes.map(size => size.join(DIMENSION_SEPARATOR)).join(SIZE_SEPARATOR);
}

registerBidder(spec);
69 changes: 42 additions & 27 deletions modules/gjirafaBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
# Overview
Module Name: Gjirafa Bidder Adapter Module
Type: Bidder Adapter
Maintainer: agonq@gjirafa.com
Maintainer: drilon@gjirafa.com

# Description
Gjirafa Bidder Adapter for Prebid.js.

# Test Parameters
var adUnits = [
{
code: 'test-div',
sizes: [[728, 90]], // leaderboard
bids: [
{
bidder: 'gjirafa',
params: {
placementId: '71-3'
}
}
]
},{
code: 'test-div',
sizes: [[300, 250]], // mobile rectangle
bids: [
{
bidder: 'gjirafa',
params: {
minCPM: 0.0001,
minCPC: 0.001,
explicit: true
}
}
]
}
];
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
bids: [
{
bidder: 'gjirafa',
params: {
propertyId: '105227',
placementId: '846841'
}
}
]
},
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
bids: [
{
bidder: 'gjirafa',
params: {
propertyId: '105227',
placementId: '846848',
contents: [ //optional
{
type: 'article',
id: '123'
}
]
}
}
]
}
];
91 changes: 91 additions & 0 deletions modules/malltvBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'malltv';
const ENDPOINT_URL = 'https://central.mall.tv/bid';
const DIMENSION_SEPARATOR = 'x';
const SIZE_SEPARATOR = ';';

export const spec = {
code: BIDDER_CODE,
/**
* Determines whether or not the given bid request is valid.
*
* @param {BidRequest} bid The bid params to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
return !!(bid.params.propertyId && bid.params.placementId);
},
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
let response = validBidRequests.map(bidRequest => {
let sizes = generateSizeParam(bidRequest.sizes);
let propertyId = bidRequest.params.propertyId;
let placementId = bidRequest.params.placementId;
let adUnitId = bidRequest.adUnitCode;
let pageViewGuid = bidRequest.params.pageViewGuid || '';
let contents = bidRequest.params.contents || [];
const body = {
sizes: sizes,
adUnitId: adUnitId,
placementId: placementId,
propertyId: propertyId,
pageViewGuid: pageViewGuid,
url: bidderRequest ? bidderRequest.refererInfo.referer : '',
requestid: bidRequest.bidderRequestId,
bidid: bidRequest.bidId,
contents: contents
};
return {
method: 'POST',
url: ENDPOINT_URL,
data: body
};
});
return response
},
/**
* Unpack the response from the server into a list of bids.
*
* @param {ServerResponse} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, bidRequest) {
window.adnResponse = serverResponse;
const responses = serverResponse.body;
const bidResponses = [];
for (var i = 0; i < responses.length; i++) {
const bidResponse = {
requestId: bidRequest.data.bidid,
cpm: responses[i].CPM,
width: responses[i].Width,
height: responses[i].Height,
creativeId: responses[i].CreativeId,
currency: responses[i].Currency,
netRevenue: responses[i].NetRevenue,
ttl: responses[i].TTL,
referrer: responses[i].Referrer,
ad: responses[i].Ad
};
bidResponses.push(bidResponse);
}
return bidResponses;
}
}

/**
* Generate size param for bid request using sizes array
*
* @param {Array} sizes Possible sizes for the ad unit.
* @return {string} Processed sizes param to be used for the bid request.
*/
function generateSizeParam(sizes) {
return sizes.map(size => size.join(DIMENSION_SEPARATOR)).join(SIZE_SEPARATOR);
}

registerBidder(spec);
Loading

0 comments on commit d41a946

Please sign in to comment.