forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Outcon bid adapter. * Fix identation * Fixes * Fixes * Fixes * Spec fixes * Fixes * Fix urls * Fix * Fix parameters * Fix space operators * Fix bidder timeout * Update * Fix whitespace * no message * Outcon unit test * no message * no message * no message * no message * Fixes * Fixes * Change url * no message * no message * no message * Added bidId * no message * no message * no message * no message * Wrapping url with html * no message * no message * no message
- Loading branch information
1 parent
bc855ed
commit 2121f18
Showing
3 changed files
with
183 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,26 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: outconAdapter | ||
Module Type: Bidder Adapter | ||
Maintainer: mfolmer@dokkogroup.com.ar | ||
``` | ||
|
||
# Description | ||
|
||
Module that connects to Outcon demand sources | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
bidder: 'outcon', | ||
params: { | ||
internalId: '12345678', | ||
publisher: '5d5d66f2306ea4114a37c7c2', | ||
bidId: '123456789', | ||
env: 'test' | ||
} | ||
} | ||
]; | ||
``` |
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 {registerBidder} from '../src/adapters/bidderFactory'; | ||
import {config} from '../src/config'; | ||
|
||
const BIDDER_CODE = 'outcon'; | ||
export const spec = { | ||
code: BIDDER_CODE, | ||
isBidRequestValid: function(bid) { | ||
return !!((bid.params.pod || (bid.params.internalId && bid.params.publisher)) && bid.params.env); | ||
}, | ||
buildRequests: function(validBidRequests) { | ||
for (let i = 0; i < validBidRequests.length; i++) { | ||
let par = ''; | ||
let url = ''; | ||
if (validBidRequests[i].params.pod != undefined) par = 'get?pod=' + validBidRequests[i].params.pod + '&bidId=' + validBidRequests[i].bidId; | ||
else par = 'get?internalId=' + validBidRequests[i].params.internalId + '&publisher=' + validBidRequests[i].params.publisher + '&bidId=' + validBidRequests[i].bidId; | ||
switch (validBidRequests[i].params.env) { | ||
case 'test': | ||
par = par + '&demo=true'; | ||
url = 'http://test.outcondigital.com:8048/ad/' + par; | ||
break; | ||
case 'api': | ||
url = 'http://api.outcondigital.com:8048/ad/' + par; | ||
break; | ||
case 'stg': | ||
url = 'http://stg.outcondigital.com:8048/ad/' + par; | ||
break; | ||
} | ||
return { | ||
method: 'GET', | ||
url: url, | ||
data: {} | ||
}; | ||
} | ||
}, | ||
interpretResponse: function(serverResponse, bidRequest) { | ||
const bidResponses = []; | ||
const bidResponse = { | ||
requestId: serverResponse.body.bidId, | ||
cpm: serverResponse.body.cpm, | ||
width: serverResponse.body.creatives[0].width, | ||
height: serverResponse.body.creatives[0].height, | ||
creativeId: serverResponse.body.creatives[0].id, | ||
currency: serverResponse.body.cur, | ||
netRevenue: true, | ||
ttl: config.getConfig('_bidderTimeout'), | ||
ad: wrapDisplayUrl(serverResponse.body.creatives[0].url, serverResponse.body.type), | ||
vastImpUrl: serverResponse.body.trackingURL | ||
}; | ||
bidResponses.push(bidResponse); | ||
return bidResponses; | ||
}, | ||
} | ||
|
||
function wrapDisplayUrl(displayUrl, type) { | ||
if (type == 'video') return `<html><head></head><body style='margin : 0; padding: 0;'><div><video width="100%"; height="100%"; autoplay = true><source src="${displayUrl}"></video></div></body>`; | ||
if (type == 'banner') return `<html><head></head><body style='margin : 0; padding: 0;'><div><img width:"100%"; height:"100%"; src="${displayUrl}"></div></body>`; | ||
} | ||
|
||
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,98 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from '../../../modules/outconBidAdapter'; | ||
|
||
describe('outconBidAdapter', function () { | ||
describe('bidRequestValidity', function () { | ||
it('Check the bidRequest with pod param', function () { | ||
expect(spec.isBidRequestValid({ | ||
bidder: 'outcon', | ||
params: { | ||
pod: '5d603538eba7192ae14e39a4', | ||
env: 'test' | ||
} | ||
})).to.equal(true); | ||
}); | ||
it('Check the bidRequest with internalID and publisherID params', function () { | ||
expect(spec.isBidRequestValid({ | ||
bidder: 'outcon', | ||
params: { | ||
internalId: '12345678', | ||
publisher: '5d5d66f2306ea4114a37c7c2', | ||
env: 'test' | ||
} | ||
})).to.equal(true); | ||
}); | ||
}); | ||
describe('buildRequests', function () { | ||
it('Build requests with pod param', function () { | ||
expect(spec.buildRequests([{ | ||
bidder: 'outcon', | ||
params: { | ||
pod: '5d603538eba7192ae14e39a4', | ||
env: 'test' | ||
} | ||
}])).to.have.keys('method', 'url', 'data'); | ||
}); | ||
|
||
it('Build requests with internalID and publisherID params', function () { | ||
expect(spec.buildRequests([{ | ||
bidder: 'outcon', | ||
params: { | ||
internalId: '12345678', | ||
publisher: '5d5d66f2306ea4114a37c7c2', | ||
env: 'test' | ||
} | ||
}])).to.have.keys('method', 'url', 'data'); | ||
}); | ||
}); | ||
|
||
describe('interpretResponse', function () { | ||
const bidRequest = { | ||
method: 'GET', | ||
url: 'http://test.outcondigital.com:8048/ad/', | ||
data: { | ||
pod: '5d603538eba7192ae14e39a4', | ||
env: 'test' | ||
} | ||
}; | ||
const bidResponse = { | ||
body: { | ||
cpm: 0.10, | ||
cur: 'USD', | ||
exp: 10, | ||
creatives: [ | ||
{ | ||
url: 'http://test.outcondigital.com/uploads/5d42e7a7306ea4689b67c122/frutas.mp4', | ||
size: 3, | ||
width: 1920, | ||
height: 1080, | ||
codec: 'video/mp4' | ||
} | ||
], | ||
id: '5d6e6aef22063e392bf7f564', | ||
type: 'video', | ||
campaign: '5d42e44b306ea469593c76a2', | ||
trackingURL: 'http://test.outcondigital.com:8048/ad/track?track=5d6e6aef22063e392bf7f564' | ||
}, | ||
}; | ||
it('check all the keys that are needed to interpret the response', function () { | ||
const result = spec.interpretResponse(bidResponse, bidRequest); | ||
let requiredKeys = [ | ||
'requestId', | ||
'cpm', | ||
'width', | ||
'height', | ||
'creativeId', | ||
'currency', | ||
'netRevenue', | ||
'ttl', | ||
'ad', | ||
'vastImpUrl' | ||
]; | ||
let resultKeys = Object.keys(result[0]); | ||
resultKeys.forEach(function(key) { | ||
expect(requiredKeys.indexOf(key) !== -1).to.equal(true); | ||
}); | ||
}) | ||
}); | ||
}); |