Skip to content

Commit 2779585

Browse files
aelioxPedro López Jiménez
authored and
Pedro López Jiménez
committed
new TapHype bidder adapter (prebid#3319)
* new TapHype bidder adapter * Added 930x600 to Rubicon Adapter (prebid#3323) * PubMatic adapter to support TTD (prebid#3311) * first commit * added unit test cases for TTD id * Sonobi - support video and display same adunit (prebid#3325) * changed adapter to support video and display for ad unit * added case for sbi_ct outstream * outstream is display media type * Fix user-sync iframes insertion bug (prebid#3300) According to documentation, iframes should be inserted at bottom of head, rather than at top. * Prevent 33Across adapter from throwing an error when unable to getElementById(), fix JSDocs in utils.js (prebid#3333) * check gdpr in buildRequest * User sync based on whether gdpr applies or not * check if consent data exists during user sync * split user sync into further branches: 1) when gdpr does not apply 2) when consent data is unavailable * contribute viewability to ttxRequest * update tests * remove window mock from tests * use local variables * introduce ServerRequestBuilder * add withOptions() method to ServerRequestBuilder * add semicolons * sync up package-lock.json with upstream/master * stub window.top in tests * introduce getTopWindowSize() for test purpose * reformat code * add withSite() method to TtxRequestBuilder add withSite() method to TtxRequestBuilder * add isIframe() and _isViewabilityMeasurable() * handle NON_MEASURABLE viewability in nested iframes * consider page visibility, stub utils functions getWindowTop() and getWindowSelf() * contribute viewability as 0 for inactive tab * add prebidjs version to ttx request * send caller as an array * fix JSDoc in utils.js * send viewability as non measurable when unable to locate target HTMLElement, add warning message * TripleliftBidAdapter-update creative_id (prebid#3324) * removed dependancy on getTopWindowUrl for referer * protect against undefined obj and remove test on old dependency * added unit test for referer and gdpr in query string * removed gdpr test * removed gdpr from bidderRequest obj * decontructed bidder request obj in chai test * just need to run karma tests again * added gdpr consent to all bidderRequest obj in chai tests * changed creativeId to be a Triplelift specific id rather than represent SRA impression * error-proofed creative id * Update taphypeBidAdapter.js removed `supportedMediaTypes` and logging * Update taphypeBidAdapter.js remove mediaTypes import * new TapHype bidder adapter * Update taphypeBidAdapter.js removed `supportedMediaTypes` and logging * Update taphypeBidAdapter.js remove mediaTypes import
1 parent 8d7e43f commit 2779585

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed

modules/taphypeBidAdapter.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {registerBidder} from 'src/adapters/bidderFactory';
2+
3+
export const spec = {
4+
code: 'taphype',
5+
isBidRequestValid: function (bid) {
6+
return !!bid.params.placementId;
7+
},
8+
buildRequests: function (bidRequests) {
9+
const requests = bidRequests.map(function (bid) {
10+
const params = {
11+
placementId: bid.params.placementId,
12+
url: encodeURIComponent(window.location.href),
13+
size: bid.sizes[0][0] + 'x' + bid.sizes[0][1],
14+
rnd: Math.random(),
15+
bidId: bid.bidId,
16+
};
17+
18+
return {method: 'GET', url: 'https://us-central1-taphype-internal.cloudfunctions.net/th-prebid', data: params, options: {withCredentials: false}}
19+
});
20+
21+
return requests;
22+
},
23+
interpretResponse: function (serverResponse, bidRequest) {
24+
if (!serverResponse || !serverResponse.body || !serverResponse.body.ad) {
25+
return [];
26+
}
27+
28+
const bid = serverResponse.body;
29+
const sizes = bid.size.split(',');
30+
31+
return [{
32+
requestId: bidRequest.data.bidId,
33+
cpm: bid.price,
34+
width: sizes[0],
35+
height: sizes[1],
36+
creativeId: bidRequest.data.bidId,
37+
currency: bid.currency || 'USD',
38+
netRevenue: true,
39+
ad: bid.ad,
40+
ttl: 360
41+
}];
42+
},
43+
};
44+
45+
registerBidder(spec);

modules/taphypeBidAdapter.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Overview
2+
3+
Module Name: TapHype Bidder Adapter
4+
Module Type: Bidder Adapter
5+
Maintainer: [email protected]
6+
7+
# Description
8+
9+
You can use this adapter to get a bid from taphype.com.
10+
11+
12+
# Test Parameters
13+
```javascript
14+
var adUnits = [
15+
{
16+
code: 'div-taphype-example',
17+
sizes: [[300, 250]],
18+
bids: [
19+
{
20+
bidder: "taphype",
21+
params: {
22+
placementId: 12345
23+
}
24+
}
25+
]
26+
}
27+
];
28+
```
29+
30+
Where:
31+
32+
* placementId - TapHype Placement ID
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { expect } from 'chai';
2+
import { spec } from 'modules/taphypeBidAdapter';
3+
4+
describe('taphypeBidAdapterTests', function () {
5+
it('validate_pub_params', function () {
6+
expect(spec.isBidRequestValid({
7+
bidder: 'taphype',
8+
params: {
9+
placementId: 12345
10+
}
11+
})).to.equal(true);
12+
});
13+
14+
it('validate_generated_params', function () {
15+
let bidRequestData = [{
16+
bidId: 'bid12345',
17+
bidder: 'taphype',
18+
params: {
19+
placementId: 12345
20+
},
21+
sizes: [[300, 250]]
22+
}];
23+
24+
let request = spec.buildRequests(bidRequestData);
25+
let req_data = request[0].data;
26+
27+
expect(req_data.bidId).to.equal('bid12345');
28+
});
29+
30+
it('validate_response_params', function () {
31+
let bidRequestData = {
32+
data: {
33+
bidId: 'bid12345'
34+
}
35+
};
36+
37+
let serverResponse = {
38+
body: {
39+
price: 1.23,
40+
ad: '<html></html>',
41+
size: '300,250'
42+
}
43+
};
44+
45+
let bids = spec.interpretResponse(serverResponse, bidRequestData);
46+
expect(bids).to.have.lengthOf(1);
47+
let bid = bids[0];
48+
expect(bid.cpm).to.equal(1.23);
49+
expect(bid.currency).to.equal('USD');
50+
expect(bid.width).to.equal('300');
51+
expect(bid.height).to.equal('250');
52+
expect(bid.netRevenue).to.equal(true);
53+
expect(bid.requestId).to.equal('bid12345');
54+
expect(bid.ad).to.equal('<html></html>');
55+
});
56+
});

0 commit comments

Comments
 (0)