Skip to content

Commit

Permalink
added adapters for gjirafa and malltv (#5587)
Browse files Browse the repository at this point in the history
* added adapters for gjirafa and malltv

* interpretResponse fix for empty result

* updated testing propertyId and placementId
  • Loading branch information
drilon-kastrati authored Sep 8, 2020
1 parent 33e1691 commit bcf7b5a
Show file tree
Hide file tree
Showing 6 changed files with 555 additions and 27 deletions.
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);
51 changes: 51 additions & 0 deletions modules/malltvBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Overview
Module Name: MallTV Bidder Adapter Module
Type: Bidder Adapter
Maintainer: drilon@gjirafa.com

# Description
MallTV Bidder Adapter for Prebid.js.

# Test Parameters
var adUnits = [
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 300]]
}
},
bids: [
{
bidder: 'malltv',
params: {
propertyId: '105134',
placementId: '846832'
}
}
]
},
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 300]]
}
},
bids: [
{
bidder: 'malltv',
params: {
propertyId: '105134',
placementId: '846832',
contents: [ //optional
{
type: 'video',
id: '123'
}
]
}
}
]
}
];
Loading

0 comments on commit bcf7b5a

Please sign in to comment.