Skip to content

Commit 16b3e92

Browse files
fedotxxlPedro López Jiménez
authored and
Pedro López Jiménez
committed
OTM adapter update (prebid#3407)
* otm * ALF-95 * otm: modify adapter to support migration to a new ssp * otm: fixed spec
1 parent e5d92c4 commit 16b3e92

File tree

3 files changed

+60
-45
lines changed

3 files changed

+60
-45
lines changed

modules/otmBidAdapter.js

+35-25
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,56 @@ export const spec = {
55
code: 'otm',
66
supportedMediaTypes: [BANNER],
77
isBidRequestValid: function (bid) {
8-
return !!bid.params.pid && !!bid.params.tid;
8+
return !!bid.params.tid;
99
},
1010
buildRequests: function (bidRequests) {
1111
const requests = bidRequests.map(function (bid) {
1212
const params = {
13-
pid: bid.params.pid,
14-
tid: bid.params.tid,
15-
bidfloor: bid.params.bidfloor,
16-
url: encodeURIComponent(window.location.href),
17-
size: bid.sizes[0][0] + 'x' + bid.sizes[0][1],
18-
resp_type: 'json',
19-
rnd: Math.random(),
20-
bidId: bid.bidId,
13+
tz: getTz(),
14+
w: bid.sizes[0][0],
15+
h: bid.sizes[0][1],
16+
s: bid.params.tid,
17+
bidid: bid.bidId,
18+
transactionid: bid.transactionId,
19+
auctionid: bid.auctionId,
20+
bidfloor: bid.params.bidfloor
2121
};
2222

23-
return {method: 'GET', url: 'https://ads2.otm-r.com/banner/hb', data: params}
23+
return {method: 'GET', url: 'https://ssp.otm-r.com/adjson', data: params}
2424
});
2525

2626
return requests;
2727
},
2828
interpretResponse: function (serverResponse, bidRequest) {
29-
if (!serverResponse || !serverResponse.body || !serverResponse.body.ad) {
29+
if (!serverResponse || !serverResponse.body) {
3030
return [];
3131
}
3232

33-
const bid = serverResponse.body;
34-
const sizes = bid.size.split('x');
35-
36-
return [{
37-
requestId: bidRequest.data.bidId,
38-
cpm: bid.price,
39-
width: sizes[0],
40-
height: sizes[1],
41-
creativeId: bidRequest.data.bidId,
42-
currency: bid.currency || 'RUB',
43-
netRevenue: true,
44-
ad: bid.ad,
45-
ttl: 360
46-
}];
33+
const answer = [];
34+
35+
serverResponse.body.forEach(bid => {
36+
if (bid.ad) {
37+
answer.push({
38+
requestId: bid.bidid,
39+
cpm: bid.cpm,
40+
width: bid.w,
41+
height: bid.h,
42+
creativeId: bid.creativeid,
43+
currency: bid.currency || 'RUB',
44+
netRevenue: true,
45+
ad: bid.ad,
46+
ttl: bid.ttl,
47+
transactionId: bid.transactionid
48+
});
49+
}
50+
});
51+
52+
return answer;
4753
},
4854
};
4955

56+
function getTz() {
57+
return new Date().getTimezoneOffset();
58+
}
59+
5060
registerBidder(spec);

modules/otmBidAdapter.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ About us : http://otm-r.com
2121
{
2222
bidder: "otm",
2323
params: {
24-
pid: 1,
25-
tid: "demo",
24+
tid: "99",
2625
bidfloor: 20
2726
}
2827
}
@@ -33,6 +32,5 @@ About us : http://otm-r.com
3332

3433
Where:
3534

36-
* pid - Publisher id
3735
* tid - A tag id (should have low cardinality)
3836
* bidfloor - Floor price
+24-17
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { expect } from 'chai';
2-
import { spec } from 'modules/otmBidAdapter';
1+
import {expect} from 'chai';
2+
import {spec} from 'modules/otmBidAdapter';
33

44
describe('otmBidAdapterTests', function () {
55
it('validate_pub_params', function () {
66
expect(spec.isBidRequestValid({
77
bidder: 'otm',
88
params: {
9-
pid: 1,
10-
tid: 'demo',
9+
tid: '123',
1110
bidfloor: 20
1211
}
1312
})).to.equal(true);
@@ -18,8 +17,7 @@ describe('otmBidAdapterTests', function () {
1817
bidId: 'bid1234',
1918
bidder: 'otm',
2019
params: {
21-
pid: 1,
22-
tid: 'demo',
20+
tid: '123',
2321
bidfloor: 20
2422
},
2523
sizes: [[240, 400]]
@@ -28,7 +26,7 @@ describe('otmBidAdapterTests', function () {
2826
let request = spec.buildRequests(bidRequestData);
2927
let req_data = request[0].data;
3028

31-
expect(req_data.bidId).to.equal('bid1234');
29+
expect(req_data.bidid).to.equal('bid1234');
3230
});
3331

3432
it('validate_response_params', function () {
@@ -39,22 +37,31 @@ describe('otmBidAdapterTests', function () {
3937
};
4038

4139
let serverResponse = {
42-
body: {
43-
price: 1.12,
44-
ad: 'Ad html',
45-
size: '250x600'
46-
}
40+
body: [
41+
{
42+
'auctionid': '3c6f8e22-541b-485c-9214-e974d9fb1b6f',
43+
'cpm': 847.097,
44+
'ad': '<html><body>test html</body></html>',
45+
'w': 240,
46+
'h': 400,
47+
'currency': 'RUB',
48+
'ttl': 300,
49+
'creativeid': '1_7869053',
50+
'bidid': '101f211def7c99',
51+
'transactionid': 'transaction_id_1'
52+
}
53+
]
4754
};
4855

4956
let bids = spec.interpretResponse(serverResponse, bidRequestData);
5057
expect(bids).to.have.lengthOf(1);
5158
let bid = bids[0];
52-
expect(bid.cpm).to.equal(1.12);
59+
expect(bid.cpm).to.equal(847.097);
5360
expect(bid.currency).to.equal('RUB');
54-
expect(bid.width).to.equal('250');
55-
expect(bid.height).to.equal('600');
61+
expect(bid.width).to.equal(240);
62+
expect(bid.height).to.equal(400);
5663
expect(bid.netRevenue).to.equal(true);
57-
expect(bid.requestId).to.equal('bid1234');
58-
expect(bid.ad).to.equal('Ad html');
64+
expect(bid.requestId).to.equal('101f211def7c99');
65+
expect(bid.ad).to.equal('<html><body>test html</body></html>');
5966
});
6067
});

0 commit comments

Comments
 (0)