-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Orbitsoft module for Prebid 1.0 (#2108)
- Loading branch information
1 parent
1b2475e
commit 2d1d0e0
Showing
3 changed files
with
455 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import * as utils from 'src/utils'; | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
import {config} from 'src/config'; | ||
|
||
const BIDDER_CODE = 'orbitsoft'; | ||
let styleParamsMap = { | ||
'title.family': 'f1', // headerFont | ||
'title.size': 'fs1', // headerFontSize | ||
'title.weight': 'w1', // headerWeight | ||
'title.style': 's1', // headerStyle | ||
'title.color': 'c3', // headerColor | ||
'description.family': 'f2', // descriptionFont | ||
'description.size': 'fs2', // descriptionFontSize | ||
'description.weight': 'w2', // descriptionWeight | ||
'description.style': 's2', // descriptionStyle | ||
'description.color': 'c4', // descriptionColor | ||
'url.family': 'f3', // urlFont | ||
'url.size': 'fs3', // urlFontSize | ||
'url.weight': 'w3', // urlWeight | ||
'url.style': 's3', // urlStyle | ||
'url.color': 'c5', // urlColor | ||
'colors.background': 'c2', // borderColor | ||
'colors.border': 'c1', // borderColor | ||
'colors.link': 'c6', // lnkColor | ||
}; | ||
export const spec = { | ||
code: BIDDER_CODE, | ||
aliases: ['oas', '152media'], // short code and customer aliases | ||
isBidRequestValid: function (bid) { | ||
switch (true) { | ||
case !('params' in bid): | ||
utils.logError(bid.bidder + ': No required params'); | ||
return false; | ||
case !(bid.params.placementId): | ||
utils.logError(bid.bidder + ': No required param placementId'); | ||
return false; | ||
case !(bid.params.requestUrl): | ||
utils.logError(bid.bidder + ': No required param requestUrl'); | ||
return false; | ||
} | ||
return true; | ||
}, | ||
buildRequests: function (validBidRequests) { | ||
let bidRequest; | ||
let serverRequests = []; | ||
for (let i = 0; i < validBidRequests.length; i++) { | ||
bidRequest = validBidRequests[i]; | ||
let bidRequestParams = bidRequest.params; | ||
let callbackId = utils.getUniqueIdentifierStr(); | ||
let placementId = utils.getBidIdParameter('placementId', bidRequestParams); | ||
let requestUrl = utils.getBidIdParameter('requestUrl', bidRequestParams); | ||
let referrer = utils.getBidIdParameter('ref', bidRequestParams); | ||
let location = utils.getBidIdParameter('loc', bidRequestParams); | ||
// Append location & referrer | ||
if (location === '') { | ||
location = utils.getTopWindowUrl(); | ||
} | ||
if (referrer === '') { | ||
referrer = utils.getTopWindowReferrer(); | ||
} | ||
|
||
// Styles params | ||
let stylesParams = utils.getBidIdParameter('style', bidRequestParams); | ||
let stylesParamsArray = {}; | ||
for (let currentValue in stylesParams) { | ||
if (stylesParams.hasOwnProperty(currentValue)) { | ||
let currentStyle = stylesParams[currentValue]; | ||
for (let field in currentStyle) { | ||
if (currentStyle.hasOwnProperty(field)) { | ||
let styleField = styleParamsMap[currentValue + '.' + field]; | ||
if (typeof styleField !== 'undefined') { | ||
stylesParamsArray[styleField] = currentStyle[field]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Custom params | ||
let customParams = utils.getBidIdParameter('customParams', bidRequestParams); | ||
let customParamsArray = {}; | ||
for (let customField in customParams) { | ||
if (customParams.hasOwnProperty(customField)) { | ||
customParamsArray['c.' + customField] = customParams[customField]; | ||
} | ||
} | ||
|
||
// Sizes params (not supports by server, for future features) | ||
let sizesParams = bidRequest.sizes; | ||
let parsedSizes = utils.parseSizesInput(sizesParams); | ||
|
||
serverRequests.push({ | ||
method: 'GET', | ||
url: requestUrl, | ||
data: Object.assign({ | ||
'scid': placementId, | ||
'callback_uid': callbackId, | ||
'loc': location, | ||
'ref': referrer, | ||
'size': parsedSizes | ||
}, stylesParamsArray, customParamsArray), | ||
options: {withCredentials: false}, | ||
bidRequest: bidRequest | ||
}); | ||
} | ||
return serverRequests; | ||
}, | ||
interpretResponse: function (serverResponse, request) { | ||
let bidResponses = []; | ||
if (!serverResponse || serverResponse.error) { | ||
utils.logError(BIDDER_CODE + ': Server response error'); | ||
return bidResponses; | ||
} | ||
|
||
const serverBody = serverResponse.body; | ||
if (!serverBody) { | ||
utils.logError(BIDDER_CODE + ': Empty bid response'); | ||
return bidResponses; | ||
} | ||
|
||
const CPM = serverBody.cpm; | ||
const WIDTH = serverBody.width; | ||
const HEIGHT = serverBody.height; | ||
const CREATIVE = serverBody.content_url; | ||
const CALLBACK_UID = serverBody.callback_uid; | ||
const TIME_TO_LIVE = config.getConfig('_bidderTimeout'); | ||
const REFERER = utils.getTopWindowUrl(); | ||
let bidRequest = request.bidRequest; | ||
if (CPM > 0 && WIDTH > 0 && HEIGHT > 0) { | ||
let bidResponse = { | ||
requestId: bidRequest.bidId, | ||
cpm: CPM, | ||
width: WIDTH, | ||
height: HEIGHT, | ||
creativeId: CALLBACK_UID, | ||
ttl: TIME_TO_LIVE, | ||
referrer: REFERER, | ||
currency: 'USD', | ||
netRevenue: true, | ||
adUrl: CREATIVE | ||
}; | ||
bidResponses.push(bidResponse); | ||
} | ||
|
||
return bidResponses; | ||
} | ||
}; | ||
registerBidder(spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Orbitsoft Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: support@orbitsoft.com | ||
``` | ||
|
||
# Description | ||
|
||
Module that connects to Orbitsoft's demand sources. The “sizes” option is not supported, and the size of the ad depends on the placement settings. You can use an optional “style” parameter to set the appearance only for text ad. Specify the “requestUrl” param to your Orbitsoft ad server header bidding endpoint. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: 'orbitsoft-div', | ||
bids: [ | ||
{ | ||
bidder: "orbitsoft", | ||
params: { | ||
placementId: '132', | ||
requestUrl: 'https://orbitsoft.com/php/ads/hb.php', | ||
style: { | ||
title: { | ||
family: 'Tahoma', | ||
size: 'medium', | ||
weight: 'normal', | ||
style: 'normal', | ||
color: '0053F9' | ||
}, | ||
description: { | ||
family: 'Tahoma', | ||
size: 'medium', | ||
weight: 'normal', | ||
style: 'normal', | ||
color: '0053F9' | ||
}, | ||
url: { | ||
family: 'Tahoma', | ||
size: 'medium', | ||
weight: 'normal', | ||
style: 'normal', | ||
color: '0053F9' | ||
}, | ||
colors: { | ||
background: 'ffffff', | ||
border: 'E0E0E0', | ||
link: '5B99FE' | ||
} | ||
}, | ||
customParams: { | ||
macro_name: "macro_value" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.