-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add vuukle adapter * add readme * doc: add email
- Loading branch information
Showing
3 changed files
with
148 additions
and
0 deletions.
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,63 @@ | ||
import * as utils from '../src/utils.js'; | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
|
||
const BIDDER_CODE = 'vuukle'; | ||
const URL = 'https://pb.vuukle.com/adapter'; | ||
const TIME_TO_LIVE = 360; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
|
||
isBidRequestValid: function(bid) { | ||
return true | ||
}, | ||
|
||
buildRequests: function(bidRequests) { | ||
const requests = bidRequests.map(function (bid) { | ||
const parseSized = utils.parseSizesInput(bid.sizes); | ||
const arrSize = parseSized[0].split('x'); | ||
const params = { | ||
url: encodeURIComponent(window.location.href), | ||
sizes: JSON.stringify(parseSized), | ||
width: arrSize[0], | ||
height: arrSize[1], | ||
params: JSON.stringify(bid.params), | ||
rnd: Math.random(), | ||
bidId: bid.bidId, | ||
source: 'pbjs', | ||
version: '$prebid.version$', | ||
v: 1, | ||
}; | ||
|
||
return { | ||
method: 'GET', | ||
url: URL, | ||
data: params, | ||
options: {withCredentials: false} | ||
} | ||
}); | ||
|
||
return requests; | ||
}, | ||
|
||
interpretResponse: function(serverResponse, bidRequest) { | ||
if (!serverResponse || !serverResponse.body || !serverResponse.body.ad) { | ||
return []; | ||
} | ||
|
||
const res = serverResponse.body; | ||
const bidResponse = { | ||
requestId: bidRequest.data.bidId, | ||
cpm: res.cpm, | ||
width: res.width, | ||
height: res.height, | ||
creativeId: res.creative_id, | ||
currency: res.currency || 'USD', | ||
netRevenue: true, | ||
ttl: TIME_TO_LIVE, | ||
ad: res.ad | ||
}; | ||
return [bidResponse]; | ||
}, | ||
} | ||
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,26 @@ | ||
# Overview | ||
``` | ||
Module Name: Vuukle Bid Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: [email protected] | ||
``` | ||
|
||
# Description | ||
Module that connects to Vuukle's server for bids. | ||
Currently module supports only banner mediaType. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [{ | ||
code: '/test/div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]] | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'vuukle', | ||
params: {} | ||
}] | ||
}]; | ||
``` |
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,59 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/vuukleBidAdapter.js'; | ||
|
||
describe('vuukleBidAdapterTests', function() { | ||
let bidRequestData = { | ||
bids: [ | ||
{ | ||
bidId: 'testbid', | ||
bidder: 'vuukle', | ||
params: { | ||
test: 1 | ||
}, | ||
sizes: [[300, 250]] | ||
} | ||
] | ||
}; | ||
let request = []; | ||
|
||
it('validate_pub_params', function() { | ||
expect( | ||
spec.isBidRequestValid({ | ||
bidder: 'vuukle', | ||
params: { | ||
test: 1 | ||
} | ||
}) | ||
).to.equal(true); | ||
}); | ||
|
||
it('validate_generated_params', function() { | ||
request = spec.buildRequests(bidRequestData.bids); | ||
let req_data = request[0].data; | ||
|
||
expect(req_data.bidId).to.equal('testbid'); | ||
}); | ||
|
||
it('validate_response_params', function() { | ||
let serverResponse = { | ||
body: { | ||
'cpm': 0.01, | ||
'width': 300, | ||
'height': 250, | ||
'creative_id': '12345', | ||
'ad': 'test ad' | ||
} | ||
}; | ||
|
||
request = spec.buildRequests(bidRequestData.bids); | ||
let bids = spec.interpretResponse(serverResponse, request[0]); | ||
expect(bids).to.have.lengthOf(1); | ||
|
||
let bid = bids[0]; | ||
expect(bid.ad).to.equal('test ad'); | ||
expect(bid.cpm).to.equal(0.01); | ||
expect(bid.width).to.equal(300); | ||
expect(bid.height).to.equal(250); | ||
expect(bid.creativeId).to.equal('12345'); | ||
}); | ||
}); |