Skip to content

Commit

Permalink
tappx Bid Adapter: add video instream support and update testing (#6580)
Browse files Browse the repository at this point in the history
* tappxBidAdapter : update tests adding video

* tappxBidAdapter : add video instream

* tappxBidAdapter : update tappx md doc

* tappxBidAdapter: Fix Newline required eol-last

* tappxBidAdapter: update tests User sync and  video reqs

* tappxBidAdapter: Extra space after fix

Co-authored-by: marc_tappx <marc@tappx.com>
  • Loading branch information
prebidtappx and marc_tappx authored Apr 16, 2021
1 parent dd64734 commit ef00f9b
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 21 deletions.
81 changes: 66 additions & 15 deletions modules/tappxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';

const BIDDER_CODE = 'tappx';
const TTL = 360;
const CUR = 'USD';
const TAPPX_BIDDER_VERSION = '0.1.10329';
const TAPPX_BIDDER_VERSION = '0.1.10413';
const TYPE_CNN = 'prebidjs';
const VIDEO_SUPPORT = ['instream'];

var HOST;
var hostDomain;

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

/**
* Determines whether or not the given bid request is valid.
Expand All @@ -24,11 +26,7 @@ export const spec = {
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function(bid) {
if ((bid.params == null) || (bid.params.endpoint == null) || (bid.params.tappxkey == null)) {
utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters. ${JSON.stringify(bid)}`);
return false;
}
return true;
return validBasic(bid) && validMediaType(bid)
},

/**
Expand Down Expand Up @@ -63,7 +61,7 @@ export const spec = {
const bids = [];
responseBody.seatbid.forEach(serverSeatBid => {
serverSeatBid.bid.forEach(serverBid => {
bids.push(interpretBannerBid(serverBid, originalRequest));
bids.push(interpretBid(serverBid, originalRequest));
});
});

Expand Down Expand Up @@ -106,25 +104,66 @@ export const spec = {
}
}

function validBasic(bid) {
if (
(bid.params == null) ||
(bid.params.endpoint == null) ||
(bid.params.tappxkey == null)) {
utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters.`);
return false;
}
return true;
}

function validMediaType(bid) {
const video = utils.deepAccess(bid, 'mediaTypes.video');

// Video validations
if (typeof video != 'undefined') {
if (VIDEO_SUPPORT.indexOf(video.context) === -1) {
utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters for Video. Only "instream" is suported.`);
return false;
}
}

return true;
}

/**
* Parse the response and generate one bid object.
*
* @param {object} serverBid Bid by OpenRTB 2.5
* @returns {object} Prebid banner bidObject
*/
function interpretBannerBid(serverBid, request) {
return {
function interpretBid(serverBid, request) {
let bidReturned = {
requestId: request.bids.bidId,
cpm: serverBid.price,
currency: serverBid.cur ? serverBid.cur : CUR,
width: serverBid.w,
height: serverBid.h,
ad: serverBid.adm,
ttl: TTL,
creativeId: serverBid.crid,
netRevenue: true,
mediaType: BANNER,
}

if (typeof serverBid.dealId != 'undefined') { bidReturned.dealId = serverBid.dealId }

if (typeof request.bids.mediaTypes != 'undefined' && typeof request.bids.mediaTypes.video != 'undefined') {
bidReturned.vastXml = serverBid.adm;
bidReturned.vastUrl = serverBid.lurl;
bidReturned.ad = serverBid.adm;
bidReturned.mediaType = VIDEO;
} else {
bidReturned.ad = serverBid.adm;
bidReturned.mediaType = BANNER;
}

if (typeof bidReturned.adomain != 'undefined' || bidReturned.adomain != null) {
bidReturned.meta = { advertiserDomains: request.bids.adomain };
}

return bidReturned;
}

/**
Expand All @@ -136,14 +175,14 @@ function interpretBannerBid(serverBid, request) {
*/
function buildOneRequest(validBidRequests, bidderRequest) {
HOST = utils.deepAccess(validBidRequests, 'params.host');
let hostInfo = getHostInfo(HOST)
// hostDomain = HOST.split('/', 1)[0];
let hostInfo = getHostInfo(HOST);
hostDomain = hostInfo.domain;

const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint');
const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey');
const BIDFLOOR = utils.deepAccess(validBidRequests, 'params.bidfloor');
const bannerMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.banner');
const videoMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.video');
const { refererInfo } = bidderRequest;

// let requests = [];
Expand Down Expand Up @@ -205,6 +244,18 @@ function buildOneRequest(validBidRequests, bidderRequest) {
imp.banner = banner;
}

if (videoMediaType) {
let video = {};
w = videoMediaType.playerSize[0][0];
h = videoMediaType.playerSize[0][1];
video.w = w;
video.h = h;

video.mimes = videoMediaType.mimes;

imp.video = video;
}

imp.id = validBidRequests.bidId;
imp.tagid = tagid;
imp.secure = 1;
Expand Down
33 changes: 33 additions & 0 deletions modules/tappxBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Maintainer: prebid@tappx.com

# Description
Module that connects to :tappx demand sources.
Suppots Banner and Instream Video.
Please use ```tappx``` as the bidder code.
Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90]

Expand Down Expand Up @@ -35,3 +36,35 @@ Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90]
}
];
```


# Video Test Parameters
```
var adUnits = [
{
code: 'video-ad-div',
renderer: {
options: {
text: "Tappx instream Video"
}
},
mediaTypes: {
video: {
context: "instream",
mimes : [ "video/mp4", "application/javascript" ],
playerSize: [320, 250]
}
},
bids: [{
bidder: 'tappx',
params: {
host: "testing.ssp.tappx.com/rtb/v2/",
tappxkey: "pub-1234-desktop-1234",
endpoint: "VZ12TESTCTV",
bidfloor: 0.005,
test: true
}
}]
}
];
```
Loading

0 comments on commit ef00f9b

Please sign in to comment.