-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add vuble adapter #2201
Merged
Merged
Add vuble adapter #2201
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c076553
Add: vuble bid adapter
5d88372
Add: vuble bid adapter unit tests
d726c1e
Fix: getUserSync returns an empty array if no user sync is found
66555cc
Add: unit tests for getUserSync
f56287c
Mod vuble unit test use single quotes
ff38722
Mod: check mediatypes for bid request valid check on vuble adapter
3bf761f
Add: vuble adapter: bid id and env in request data
eb9219d
Fix: vuble adaptor uses bid data in interpret reponse
92fedcf
Del: unused size param anymore
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Vuble Adapter | ||
|
||
import * as utils from 'src/utils'; | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
|
||
const BIDDER_CODE = 'vuble'; | ||
|
||
const ENVS = ['com', 'net']; | ||
const CURRENCIES = { | ||
com: 'EUR', | ||
net: 'USD' | ||
}; | ||
const TTL = 60; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: ['video'], | ||
|
||
/** | ||
* 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) { | ||
if (utils.isEmpty(bid.sizes) || utils.parseSizesInput(bid.sizes).length == 0) { | ||
return false; | ||
} | ||
|
||
if (!utils.deepAccess(bid, 'mediaTypes.video.context')) { | ||
return false; | ||
} | ||
|
||
if (!utils.contains(ENVS, bid.params.env)) { | ||
return false; | ||
} | ||
|
||
return !!(bid.params.env && bid.params.pubId && bid.params.zoneId); | ||
}, | ||
|
||
/** | ||
* 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) { | ||
return validBidRequests.map(bid => { | ||
// We take the first size | ||
let size = utils.parseSizesInput(bid.sizes)[0].split('x'); | ||
|
||
// Get the page's url | ||
let referrer = utils.getTopWindowUrl(); | ||
if (bid.params.referrer) { | ||
referrer = bid.params.referrer; | ||
} | ||
|
||
// Get Video Context | ||
let context = utils.deepAccess(bid, 'mediaTypes.video.context'); | ||
|
||
let url = '//player.mediabong.' + bid.params.env + '/prebid/request'; | ||
let data = { | ||
width: size[0], | ||
height: size[1], | ||
pub_id: bid.params.pubId, | ||
zone_id: bid.params.zoneId, | ||
context: context, | ||
floor_price: bid.params.floorPrice ? bid.params.floorPrice : 0, | ||
url: referrer, | ||
env: bid.params.env, | ||
bid_id: bid.bidId | ||
}; | ||
|
||
return { | ||
method: 'POST', | ||
url: url, | ||
data: data | ||
}; | ||
}); | ||
}, | ||
|
||
/** | ||
* 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, bid) { | ||
const responseBody = serverResponse.body; | ||
|
||
if (typeof responseBody !== 'object' || responseBody.status !== 'ok') { | ||
return []; | ||
} | ||
|
||
let responses = []; | ||
let reponse = { | ||
requestId: bid.data.bid_id, | ||
cpm: responseBody.cpm, | ||
width: bid.data.width, | ||
height: bid.data.height, | ||
ttl: TTL, | ||
creativeId: responseBody.creativeId, | ||
netRevenue: true, | ||
currency: CURRENCIES[bid.data.env], | ||
vastUrl: responseBody.url | ||
}; | ||
responses.push(reponse); | ||
|
||
return responses; | ||
}, | ||
|
||
/** | ||
* Register the user sync pixels which should be dropped after the auction. | ||
* | ||
* @param {SyncOptions} syncOptions Which user syncs are allowed? | ||
* @param {ServerResponse[]} serverResponses List of server's responses. | ||
* @return {UserSync[]} The user syncs which should be dropped. | ||
*/ | ||
getUserSyncs: function (syncOptions, serverResponses) { | ||
if (syncOptions.iframeEnabled) { | ||
if (serverResponses.length > 0) { | ||
let responseBody = serverResponses[0].body; | ||
if (typeof responseBody !== 'object' || responseBody.iframeSync) { | ||
return [{ | ||
type: 'iframe', | ||
url: responseBody.iframeSync | ||
}]; | ||
} | ||
} | ||
} | ||
return []; | ||
} | ||
}; | ||
|
||
registerBidder(spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Vuble Bidder Adapter | ||
Module Type: Vuble Adapter | ||
Maintainer: gv@mediabong.com | ||
``` | ||
|
||
# Description | ||
|
||
Module that connects to Vuble's demand sources | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: 'test-video-instream', | ||
sizes: [[640, 360]], | ||
mediaTypes: { | ||
video: { | ||
context: 'instream' | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "vuble", | ||
params: { | ||
env: 'net', | ||
pubId: '3', | ||
zoneId: '12345', | ||
referrer: "http://www.vuble.tv/", // optional | ||
floorPrice: 5.00 // optional | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
code: 'test-video-outstream', | ||
sizes: [[640, 360]], | ||
mediaTypes: { | ||
video: { | ||
context: 'outstream' | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "vuble", | ||
params: { | ||
env: 'net', | ||
pubId: '3', | ||
zoneId: '12345', | ||
referrer: "http://www.vuble.tv/", // optional | ||
floorPrice: 5.00 // optional | ||
} | ||
} | ||
] | ||
} | ||
]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does your bidder also support banner or just video?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, it is video only.