-
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.
Update Innity Adapter to Prebid.js v1.0 (#2180)
* Innity Adapter for Prebid.js 1.0 * Fix Innity Adapter Test Spec Error (#2180) * Fix utils.timestamp and remove userSyncs (#2180)
- Loading branch information
1 parent
0ddebdf
commit 37ead27
Showing
3 changed files
with
179 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,54 @@ | ||
import * as utils from 'src/utils'; | ||
import { registerBidder } from 'src/adapters/bidderFactory'; | ||
|
||
const BIDDER_CODE = 'innity'; | ||
const ENDPOINT = location.protocol + '//as.innity.com/synd/'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
isBidRequestValid: function(bid) { | ||
return !!(bid.params && bid.params.pub && bid.params.zone); | ||
}, | ||
buildRequests: function(validBidRequests) { | ||
return validBidRequests.map(bidRequest => { | ||
let parseSized = utils.parseSizesInput(bidRequest.sizes); | ||
let arrSize = parseSized[0].split('x'); | ||
return { | ||
method: 'GET', | ||
url: ENDPOINT, | ||
data: { | ||
cb: utils.timestamp(), | ||
ver: 2, | ||
hb: 1, | ||
output: 'js', | ||
pub: bidRequest.params.pub, | ||
zone: bidRequest.params.zone, | ||
url: encodeURIComponent(utils.getTopWindowUrl()), | ||
width: arrSize[0], | ||
height: arrSize[1], | ||
vpw: window.screen.width, | ||
vph: window.screen.height, | ||
callback: 'json', | ||
callback_uid: bidRequest.bidId, | ||
auction: bidRequest.auctionId, | ||
}, | ||
}; | ||
}); | ||
}, | ||
interpretResponse: function(serverResponse, request) { | ||
const res = serverResponse.body; | ||
const bidResponse = { | ||
requestId: res.callback_uid, | ||
cpm: parseFloat(res.cpm) / 100, | ||
width: res.width, | ||
height: res.height, | ||
creativeId: res.creative_id, | ||
currency: 'USD', | ||
netRevenue: true, | ||
ttl: 60, | ||
ad: '<script src="' + location.protocol + '//cdn.innity.net/frame_util.js"></script>' + res.tag, | ||
}; | ||
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,25 @@ | ||
# Overview | ||
|
||
**Module Name**: Innity Bidder Adapter | ||
**Module Type**: Bidder Adapter | ||
**Maintainer**: engtat@innity.com | ||
|
||
# Description | ||
|
||
Innity Bidder Adapter for Prebid.js. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [{ | ||
code: 'div-gpt-ad-1460505748561-0', | ||
sizes: [[300, 250]], | ||
bids: [{ | ||
bidder: 'innity', | ||
params: { | ||
pub: 267, | ||
zone: 62546 | ||
} | ||
}] | ||
}]; | ||
``` |
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,100 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/innityBidAdapter'; | ||
|
||
describe('innityAdapterTest', () => { | ||
describe('bidRequestValidity', () => { | ||
it('bidRequest with pub ID and zone ID param', () => { | ||
expect(spec.isBidRequestValid({ | ||
bidder: 'innity', | ||
params: { | ||
'pub': 267, | ||
'zone': 62546 | ||
}, | ||
})).to.equal(true); | ||
}); | ||
|
||
it('bidRequest with no required params', () => { | ||
expect(spec.isBidRequestValid({ | ||
bidder: 'innity', | ||
params: { | ||
}, | ||
})).to.equal(false); | ||
}); | ||
}); | ||
|
||
describe('bidRequest', () => { | ||
const bidRequests = [{ | ||
'bidder': 'innity', | ||
'params': { | ||
'pub': 267, | ||
'zone': 62546 | ||
}, | ||
'adUnitCode': 'div-gpt-ad-1460505748561-0', | ||
'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', | ||
'sizes': [300, 250], | ||
'bidId': '51ef8751f9aead', | ||
'bidderRequestId': '418b37f85e772c', | ||
'auctionId': '18fd8b8b0bd757' | ||
}]; | ||
|
||
it('bidRequest HTTP method', () => { | ||
const requests = spec.buildRequests(bidRequests); | ||
requests.forEach(function(requestItem) { | ||
expect(requestItem.method).to.equal('GET'); | ||
}); | ||
}); | ||
|
||
it('bidRequest data', () => { | ||
const requests = spec.buildRequests(bidRequests); | ||
expect(requests[0].data.pub).to.equal(267); | ||
expect(requests[0].data.zone).to.equal(62546); | ||
expect(requests[0].data.width).to.equal('300'); | ||
expect(requests[0].data.height).to.equal('250'); | ||
expect(requests[0].data.callback_uid).to.equal('51ef8751f9aead'); | ||
}); | ||
}); | ||
|
||
describe('interpretResponse', () => { | ||
const bidRequest = { | ||
'method': 'GET', | ||
'url': 'https://as.innity.com/synd/?', | ||
'data': { | ||
'ver': 2, | ||
'hb': 1, | ||
'output': 'js', | ||
'pub': 267, | ||
'zone': 62546, | ||
'width': '300', | ||
'height': '250', | ||
'callback': 'json', | ||
'callback_uid': '51ef8751f9aead', | ||
'url': 'https://example.com', | ||
'cb': '', | ||
} | ||
}; | ||
|
||
const bidResponse = { | ||
body: { | ||
'cpm': 100, | ||
'width': '300', | ||
'height': '250', | ||
'creative_id': '148186', | ||
'callback_uid': '51ef8751f9aead', | ||
'tag': '<script>innity=true;</script>', | ||
}, | ||
headers: {} | ||
}; | ||
|
||
it('result is correct', () => { | ||
const result = spec.interpretResponse(bidResponse, bidRequest); | ||
expect(result[0].requestId).to.equal('51ef8751f9aead'); | ||
expect(result[0].cpm).to.equal(1); | ||
expect(result[0].width).to.equal('300'); | ||
expect(result[0].height).to.equal('250'); | ||
expect(result[0].creativeId).to.equal('148186'); | ||
expect(result[0].currency).to.equal('USD'); | ||
expect(result[0].ttl).to.equal(60); | ||
expect(result[0].ad).to.equal('<script src="http://cdn.innity.net/frame_util.js"></script><script>innity=true;</script>'); | ||
}); | ||
}); | ||
}); |