Skip to content

Adkernel adapter aliasing #857

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

Merged
merged 7 commits into from
Dec 14, 2016
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
35 changes: 23 additions & 12 deletions src/adapters/adkernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import bidmanager from 'src/bidmanager';
import bidfactory from 'src/bidfactory';
import * as utils from 'src/utils';
import {ajax} from 'src/ajax';
import Adapter from 'src/adapters/adapter';

/**
* Adapter for requesting bids from AdKernel white-label platform
* @class
*/
const AdkernelAdapter = function AdkernelAdapter() {
const ADKERNEL = 'adkernel';
const AdKernelAdapter = function AdKernelAdapter() {
const AJAX_REQ_PARAMS = {
contentType: 'text/plain',
withCredentials: true,
method: 'GET'
};
const EMPTY_BID_RESPONSE = {'seatbid': [{'bid': []}]};

let baseAdapter = Adapter.createNew('adkernel');

/**
* Helper object to build multiple bid requests in case of multiple zones/ad-networks
* @constructor
Expand Down Expand Up @@ -119,10 +121,10 @@ const AdkernelAdapter = function AdkernelAdapter() {
/**
* Main module export function implementation
*/
function _callBids(params) {
baseAdapter.callBids = function (params) {
var bids = params.bids || [];
processBids(bids);
}
};

/**
* Process all bids grouped by network/zone
Expand Down Expand Up @@ -156,8 +158,8 @@ const AdkernelAdapter = function AdkernelAdapter() {
*/
function createBidObject(resp, bid, width, height) {
return utils.extend(bidfactory.createBid(1, bid), {
bidderCode: ADKERNEL,
ad: formatAdmarkup(resp),
bidderCode: bid.bidder,
ad: formatAdMarkup(resp),
width: width,
height: height,
cpm: parseFloat(resp.price)
Expand All @@ -169,14 +171,14 @@ const AdkernelAdapter = function AdkernelAdapter() {
*/
function createEmptyBidObject(bid) {
return utils.extend(bidfactory.createBid(2, bid), {
bidderCode: ADKERNEL
bidderCode: bid.bidder
});
}

/**
* Format creative with optional nurl call
*/
function formatAdmarkup(bid) {
function formatAdMarkup(bid) {
var adm = bid.adm;
if ('nurl' in bid) {
adm += utils.createTrackPixelHtml(bid.nurl);
Expand All @@ -194,14 +196,23 @@ const AdkernelAdapter = function AdkernelAdapter() {
function createSite() {
var location = utils.getTopWindowLocation();
return {
'domain': location.hostname,
'page': location.pathname
'domain': location.hostname
};
}

return {
callBids: _callBids
callBids: baseAdapter.callBids,
setBidderCode: baseAdapter.setBidderCode,
getBidderCode : baseAdapter.getBidderCode,
createNew : AdKernelAdapter.createNew
};
};

module.exports = AdkernelAdapter;
/**
* Creates new instance of AdKernel bidder adapter
*/
AdKernelAdapter.createNew = function() {
return new AdKernelAdapter();
};

module.exports = AdKernelAdapter;
Loading