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
alpadotsh committed Nov 1, 2019
2 parents 71fb503 + 4f9ee48 commit 14c841b
Show file tree
Hide file tree
Showing 77 changed files with 4,089 additions and 556 deletions.
4 changes: 2 additions & 2 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as utils from '../src/utils';

const BIDDER_CODE = '33across';
const END_POINT = 'https://ssc.33across.com/api/v1/hb';
const SYNC_ENDPOINT = 'https://de.tynt.com/deb/v2?m=xch&rt=html';
const SYNC_ENDPOINT = 'https://ssc-cms.33across.com/ps/?m=xch&rt=html&ru=deb';

const adapterState = {};

Expand Down Expand Up @@ -144,7 +144,7 @@ function _createServerRequest(bidRequest, gdprConsent = {}) {
}

// Sync object will always be of type iframe for TTX
function _createSync({siteId, gdprConsent = {}}) {
function _createSync({siteId = 'zzz000000000003zzz', gdprConsent = {}}) {
const ttxSettings = config.getConfig('ttxSettings');
const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT;

Expand Down
155 changes: 155 additions & 0 deletions modules/7xbidBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import * as utils from '../src/utils';
import { registerBidder } from '../src/adapters/bidderFactory';

const BIDDER_CODE = '7xbid';
const BIDDER_ALIAS = '7xb';
const ENDPOINT_BANNER = '//bidder.7xbid.com/api/v1/prebid/banner';
const ENDPOINT_NATIVE = '//bidder.7xbid.com/api/v1/prebid/native';
const COOKIE_SYNC_URL = '//bidder.7xbid.com/api/v1/cookie/gen';
const SUPPORTED_MEDIA_TYPES = ['banner', 'native'];
const SUPPORTED_CURRENCIES = ['USD', 'JPY'];
const DEFAULT_CURRENCY = 'JPY';
const NET_REVENUE = true;

const _encodeURIComponent = function(a) {
let b = window.encodeURIComponent(a);
b = b.replace(/'/g, '%27');
return b;
}

export const _getUrlVars = function(url) {
var hash;
var myJson = {};
var hashes = url.slice(url.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
myJson[hash[0]] = hash[1];
}
return myJson;
}

export const spec = {
code: BIDDER_CODE,
aliases: [BIDDER_ALIAS], // short code
supportedMediaTypes: SUPPORTED_MEDIA_TYPES,
isBidRequestValid: function(bid) {
if (!(bid.params.placementId)) {
return false;
}

if (bid.params.hasOwnProperty('currency') &&
SUPPORTED_CURRENCIES.indexOf(bid.params.currency) === -1) {
utils.logInfo('Invalid currency type, we support only JPY and USD!')
return false;
}

return true;
},
/**
* 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 serverRequests = [];
var refererInfo;
if (bidderRequest && bidderRequest.refererInfo) {
refererInfo = bidderRequest.refererInfo;
}
validBidRequests.forEach((bid, i) => {
let endpoint = ENDPOINT_BANNER
let data = {
'placementid': bid.params.placementId,
'cur': bid.params.hasOwnProperty('currency') ? bid.params.currency : DEFAULT_CURRENCY,
'ua': navigator.userAgent,
'loc': utils.getTopWindowUrl(),
'topframe': (window.parent === window.self) ? 1 : 0,
'sw': screen && screen.width,
'sh': screen && screen.height,
'cb': Math.floor(Math.random() * 99999999999),
'tpaf': 1,
'cks': 1,
'requestid': bid.bidId
};

if (bid.hasOwnProperty('nativeParams')) {
endpoint = ENDPOINT_NATIVE
data.tkf = 1 // return url tracker
data.ad_track = '1'
data.apiv = '1.1.0'
}

if (refererInfo && refererInfo.referer) {
data.referer = refererInfo.referer;
} else {
data.referer = '';
}

serverRequests.push({
method: 'GET',
url: endpoint,
data: utils.parseQueryStringParameters(data)
})
})

return serverRequests;
},
interpretResponse: function(serverResponse, request) {
const data = _getUrlVars(request.data)
const successBid = serverResponse.body || {};
let bidResponses = [];
if (successBid.hasOwnProperty(data.placementid)) {
let bid = successBid[data.placementid]
let bidResponse = {
requestId: bid.requestid,
cpm: bid.price,
creativeId: bid.creativeId,
currency: bid.cur,
netRevenue: NET_REVENUE,
ttl: 700
};

if (bid.hasOwnProperty('title')) { // it is native ad response
bidResponse.mediaType = 'native'
bidResponse.native = {
title: bid.title,
body: bid.description,
cta: bid.cta,
sponsoredBy: bid.advertiser,
clickUrl: _encodeURIComponent(bid.landingURL),
impressionTrackers: bid.trackings,
}
if (bid.screenshots) {
bidResponse.native.image = {
url: bid.screenshots.url,
height: bid.screenshots.height,
width: bid.screenshots.width,
}
}
if (bid.icon) {
bidResponse.native.icon = {
url: bid.icon.url,
height: bid.icon.height,
width: bid.icon.width,
}
}
} else {
bidResponse.ad = bid.adm
bidResponse.width = bid.width
bidResponse.height = bid.height
}

bidResponses.push(bidResponse);
}

return bidResponses;
},
getUserSyncs: function(syncOptions, serverResponses) {
return [{
type: 'image',
url: COOKIE_SYNC_URL
}];
}
}
registerBidder(spec);
60 changes: 60 additions & 0 deletions modules/7xbidBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Overview

Module Name: 7xbid Bid Adapter

Maintainer: [email protected]

# Description

Module that connects to 7xbid's demand sources

# Test Parameters
```javascript
var adUnits = [
{
code: 'test',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]],
}
},
bids: [
{
bidder: '7xbid',
params: {
placementId: 1425292,
currency: 'USD'

}
}
]
},
{
code: 'test',
mediaTypes: {
native: {
title: {
required: true,
len: 80
},
image: {
required: true,
sizes: [150, 50]
},
sponsoredBy: {
required: true
}
}
},
bids: [
{
bidder: '7xbid',
params: {
placementId: 1429695,
currency: 'USD'
}
},
],
}
];
```
93 changes: 93 additions & 0 deletions modules/ablidaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import * as utils from '../src/utils';
import {config} from '../src/config';
import {registerBidder} from '../src/adapters/bidderFactory';

const BIDDER_CODE = 'ablida';
const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';

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.placementId);
},

/**
* Make a server request from the list of BidRequests.
*
* @return Array Info describing the request to the server.
* @param validBidRequests
* @param bidderRequest
*/
buildRequests: function (validBidRequests, bidderRequest) {
if (validBidRequests.length === 0) {
return [];
}
return validBidRequests.map(bidRequest => {
const sizes = utils.parseSizesInput(bidRequest.sizes)[0];
const size = sizes.split('x');
const jaySupported = 'atob' in window && 'currentScript' in document;
const device = getDevice();
const payload = {
placementId: bidRequest.params.placementId,
width: size[0],
height: size[1],
bidId: bidRequest.bidId,
categories: bidRequest.params.categories,
referer: bidderRequest.refererInfo.referer,
jaySupported: jaySupported,
device: device
};
return {
method: 'POST',
url: ENDPOINT_URL,
data: payload
};
});
},

/**
* Unpack the response from the server into a list of bids.
*
* @param {ServerResponse} serverResponse A successful response from the server.
* @param bidRequest
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
const response = serverResponse.body;

response.forEach(function(bid) {
bid.ttl = config.getConfig('_bidderTimeout');
bidResponses.push(bid);
});
return bidResponses;
},
};

function getDevice() {
const ua = navigator.userAgent;
const topWindow = window.top;
if ((/(ipad|xoom|sch-i800|playbook|silk|tablet|kindle)|(android(?!.*mobi))/i).test(ua)) {
return 'tablet';
}
if ((/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(ua)) {
return 'connectedtv';
}
if ((/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Windows\sCE|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i).test(ua)) {
return 'smartphone';
}
const width = topWindow.innerWidth || topWindow.document.documentElement.clientWidth || topWindow.document.body.clientWidth;
if (width > 320) {
return 'desktop';
}
return 'other';
}

registerBidder(spec);
32 changes: 32 additions & 0 deletions modules/ablidaBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Overview

**Module Name**: Ablida Bidder Adapter
**Module Type**: Bidder Adapter
**Maintainer**: [email protected]

# Description

Module that connects to Ablida's bidder for bids.

# Test Parameters
```
var adUnits = [
{
code: 'ad-div',
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
},
bids: [
{
bidder: 'ablida',
params: {
placementId: 'mediumrectangle-demo',
categories: ['automotive', 'news-and-politics'] // optional: categories of page
}
}
]
}
];
```
Loading

0 comments on commit 14c841b

Please sign in to comment.