-
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.
- Loading branch information
1 parent
e1fb3a8
commit 155dd8a
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,50 @@ | ||
import {BANNER} from 'src/mediaTypes'; | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
|
||
export const spec = { | ||
code: 'otm', | ||
supportedMediaTypes: [BANNER], | ||
isBidRequestValid: function (bid) { | ||
return !!bid.params.pid && !!bid.params.tid; | ||
}, | ||
buildRequests: function (bidRequests) { | ||
const requests = bidRequests.map(function (bid) { | ||
const params = { | ||
pid: bid.params.pid, | ||
tid: bid.params.tid, | ||
bidfloor: bid.params.bidfloor, | ||
url: encodeURIComponent(window.location.href), | ||
size: bid.sizes[0][0] + 'x' + bid.sizes[0][1], | ||
resp_type: 'json', | ||
rnd: Math.random(), | ||
bidId: bid.bidId, | ||
}; | ||
|
||
return {method: 'GET', url: 'https://ads2.otm-r.com/banner/hb', data: params} | ||
}); | ||
|
||
return requests; | ||
}, | ||
interpretResponse: function (serverResponse, bidRequest) { | ||
if (!serverResponse || !serverResponse.body || !serverResponse.body.ad) { | ||
return []; | ||
} | ||
|
||
const bid = serverResponse.body; | ||
const sizes = bid.size.split('x'); | ||
|
||
return [{ | ||
requestId: bidRequest.data.bidId, | ||
cpm: bid.price, | ||
width: sizes[0], | ||
height: sizes[1], | ||
creativeId: bidRequest.data.bidId, | ||
currency: bid.currency || 'RUB', | ||
netRevenue: true, | ||
ad: bid.ad, | ||
ttl: 360 | ||
}]; | ||
}, | ||
}; | ||
|
||
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,38 @@ | ||
# Overview | ||
|
||
Module Name: OTM Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: ? | ||
|
||
# Description | ||
|
||
You can use this adapter to get a bid from otm-r.com. | ||
|
||
About us : http://otm-r.com | ||
|
||
|
||
# Test Parameters | ||
```javascript | ||
var adUnits = [ | ||
{ | ||
code: 'div-otm-example', | ||
sizes: [[320, 480]], | ||
bids: [ | ||
{ | ||
bidder: "otm", | ||
params: { | ||
pid: 1, | ||
tid: "demo", | ||
bidfloor: 20 | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` | ||
|
||
Where: | ||
|
||
* pid - Publisher id | ||
* tid - A tag id (should have low cardinality) | ||
* bidfloor - Floor price |
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,60 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/otmBidAdapter'; | ||
|
||
describe('otmBidAdapterTests', function () { | ||
it('validate_pub_params', function () { | ||
expect(spec.isBidRequestValid({ | ||
bidder: 'otm', | ||
params: { | ||
pid: 1, | ||
tid: 'demo', | ||
bidfloor: 20 | ||
} | ||
})).to.equal(true); | ||
}); | ||
|
||
it('validate_generated_params', function () { | ||
let bidRequestData = [{ | ||
bidId: 'bid1234', | ||
bidder: 'otm', | ||
params: { | ||
pid: 1, | ||
tid: 'demo', | ||
bidfloor: 20 | ||
}, | ||
sizes: [[240, 400]] | ||
}]; | ||
|
||
let request = spec.buildRequests(bidRequestData); | ||
let req_data = request[0].data; | ||
|
||
expect(req_data.bidId).to.equal('bid1234'); | ||
}); | ||
|
||
it('validate_response_params', function () { | ||
let bidRequestData = { | ||
data: { | ||
bidId: 'bid1234' | ||
} | ||
}; | ||
|
||
let serverResponse = { | ||
body: { | ||
price: 1.12, | ||
ad: 'Ad html', | ||
size: '250x600' | ||
} | ||
}; | ||
|
||
let bids = spec.interpretResponse(serverResponse, bidRequestData); | ||
expect(bids).to.have.lengthOf(1); | ||
let bid = bids[0]; | ||
expect(bid.cpm).to.equal(1.12); | ||
expect(bid.currency).to.equal('RUB'); | ||
expect(bid.width).to.equal('250'); | ||
expect(bid.height).to.equal('600'); | ||
expect(bid.netRevenue).to.equal(true); | ||
expect(bid.requestId).to.equal('bid1234'); | ||
expect(bid.ad).to.equal('Ad html'); | ||
}); | ||
}); |