Skip to content

Commit d71c065

Browse files
engtataudiencerun
authored andcommitted
Innity Bid Adapter: Support for Prebid.js v3 (prebid#4633)
* Innity Adapter for Prebid.js 1.0 * Fix Innity Adapter Test Spec Error (prebid#2180) * Fix utils.timestamp and remove userSyncs (prebid#2180) * Added Prebid.js 3.0 Support
1 parent d2e1e5c commit d71c065

File tree

3 files changed

+170
-2
lines changed

3 files changed

+170
-2
lines changed

modules/innityBidAdapter.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import * as utils from '../src/utils';
2+
import { registerBidder } from '../src/adapters/bidderFactory';
3+
4+
const BIDDER_CODE = 'innity';
5+
const ENDPOINT = 'https://as.innity.com/synd/';
6+
7+
export const spec = {
8+
code: BIDDER_CODE,
9+
isBidRequestValid: function(bid) {
10+
return !!(bid.params && bid.params.pub && bid.params.zone);
11+
},
12+
buildRequests: function(validBidRequests, bidderRequest) {
13+
let refererInfo = '';
14+
if (bidderRequest && bidderRequest.refererInfo) {
15+
refererInfo = bidderRequest.refererInfo.referer || '';
16+
}
17+
return validBidRequests.map(bidRequest => {
18+
let parseSized = utils.parseSizesInput(bidRequest.sizes);
19+
let arrSize = parseSized[0].split('x');
20+
return {
21+
method: 'GET',
22+
url: ENDPOINT,
23+
data: {
24+
cb: utils.timestamp(),
25+
ver: 2,
26+
hb: 1,
27+
output: 'js',
28+
pub: bidRequest.params.pub,
29+
zone: bidRequest.params.zone,
30+
url: encodeURIComponent(refererInfo),
31+
width: arrSize[0],
32+
height: arrSize[1],
33+
vpw: window.screen.width,
34+
vph: window.screen.height,
35+
callback: 'json',
36+
callback_uid: bidRequest.bidId,
37+
auction: bidRequest.auctionId,
38+
},
39+
};
40+
});
41+
},
42+
interpretResponse: function(serverResponse, request) {
43+
const res = serverResponse.body;
44+
const bidResponse = {
45+
requestId: res.callback_uid,
46+
cpm: parseFloat(res.cpm) / 100,
47+
width: res.width,
48+
height: res.height,
49+
creativeId: res.creative_id,
50+
currency: 'USD',
51+
netRevenue: true,
52+
ttl: 60,
53+
ad: '<script src="https://cdn.innity.net/frame_util.js"></script>' + res.tag,
54+
};
55+
return [bidResponse];
56+
}
57+
}
58+
registerBidder(spec);

modules/innityBidAdapter.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ Innity Bidder Adapter for Prebid.js.
1111
# Test Parameters
1212
```
1313
var adUnits = [{
14-
code: 'div-gpt-ad-1460505748561-0',
15-
sizes: [[300, 250]],
14+
code: '/19968336/header-bid-tag-0',
15+
mediaTypes: {
16+
banner: {
17+
sizes: [[300, 250]],
18+
}
19+
},
1620
bids: [{
1721
bidder: 'innity',
1822
params: {
+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { expect } from 'chai';
2+
import { spec } from 'modules/innityBidAdapter';
3+
4+
describe('innityAdapterTest', () => {
5+
describe('bidRequestValidity', () => {
6+
it('bidRequest with pub ID and zone ID param', () => {
7+
expect(spec.isBidRequestValid({
8+
bidder: 'innity',
9+
params: {
10+
'pub': 267,
11+
'zone': 62546
12+
},
13+
})).to.equal(true);
14+
});
15+
16+
it('bidRequest with no required params', () => {
17+
expect(spec.isBidRequestValid({
18+
bidder: 'innity',
19+
params: {
20+
},
21+
})).to.equal(false);
22+
});
23+
});
24+
25+
describe('bidRequest', () => {
26+
const bidRequests = [{
27+
'bidder': 'innity',
28+
'params': {
29+
'pub': 267,
30+
'zone': 62546
31+
},
32+
'adUnitCode': '/19968336/header-bid-tag-0',
33+
'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
34+
'sizes': [300, 250],
35+
'bidId': '51ef8751f9aead',
36+
'bidderRequestId': '418b37f85e772c',
37+
'auctionId': '18fd8b8b0bd757'
38+
}];
39+
40+
const bidderRequest = {
41+
refererInfo: {
42+
referer: 'https://example.com'
43+
}
44+
};
45+
46+
it('bidRequest HTTP method', () => {
47+
const requests = spec.buildRequests(bidRequests, bidderRequest);
48+
requests.forEach(function(requestItem) {
49+
expect(requestItem.method).to.equal('GET');
50+
});
51+
});
52+
53+
it('bidRequest data', () => {
54+
const requests = spec.buildRequests(bidRequests, bidderRequest);
55+
expect(requests[0].data.pub).to.equal(267);
56+
expect(requests[0].data.zone).to.equal(62546);
57+
expect(requests[0].data.width).to.equal('300');
58+
expect(requests[0].data.height).to.equal('250');
59+
expect(requests[0].data.callback_uid).to.equal('51ef8751f9aead');
60+
});
61+
});
62+
63+
describe('interpretResponse', () => {
64+
const bidRequest = {
65+
'method': 'GET',
66+
'url': 'https://as.innity.com/synd/?',
67+
'data': {
68+
'ver': 2,
69+
'hb': 1,
70+
'output': 'js',
71+
'pub': 267,
72+
'zone': 62546,
73+
'width': '300',
74+
'height': '250',
75+
'callback': 'json',
76+
'callback_uid': '51ef8751f9aead',
77+
'url': 'https://example.com',
78+
'cb': '',
79+
}
80+
};
81+
82+
const bidResponse = {
83+
body: {
84+
'cpm': 100,
85+
'width': '300',
86+
'height': '250',
87+
'creative_id': '148186',
88+
'callback_uid': '51ef8751f9aead',
89+
'tag': '<script>innity=true;</script>',
90+
},
91+
headers: {}
92+
};
93+
94+
it('result is correct', () => {
95+
const result = spec.interpretResponse(bidResponse, bidRequest);
96+
expect(result[0].requestId).to.equal('51ef8751f9aead');
97+
expect(result[0].cpm).to.equal(1);
98+
expect(result[0].width).to.equal('300');
99+
expect(result[0].height).to.equal('250');
100+
expect(result[0].creativeId).to.equal('148186');
101+
expect(result[0].currency).to.equal('USD');
102+
expect(result[0].ttl).to.equal(60);
103+
expect(result[0].ad).to.equal('<script src="https://cdn.innity.net/frame_util.js"></script><script>innity=true;</script>');
104+
});
105+
});
106+
});

0 commit comments

Comments
 (0)