Skip to content
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

added adapters for gjirafa and malltv #5587

Merged
merged 3 commits into from
Sep 8, 2020
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
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