Skip to content

Commit 6318c24

Browse files
authored
custom endpoint (prebid#13612)
1 parent 8cf2d45 commit 6318c24

3 files changed

Lines changed: 41 additions & 4 deletions

File tree

modules/ttdBidAdapter.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getConnectionType } from '../libraries/connectionInfo/connectionUtils.j
1414
* @typedef {import('../src/adapters/bidderFactory.js').UserSync} UserSync
1515
*/
1616

17-
const BIDADAPTERVERSION = 'TTD-PREBID-2025.04.25';
17+
const BIDADAPTERVERSION = 'TTD-PREBID-2025.07.15';
1818
const BIDDER_CODE = 'ttd';
1919
const BIDDER_CODE_LONG = 'thetradedesk';
2020
const BIDDER_ENDPOINT = 'https://direct.adsrvr.org/bid/bidder/';
@@ -283,6 +283,10 @@ function video(bid) {
283283
}
284284

285285
function selectEndpoint(params) {
286+
if (params.customBidderEndpoint) {
287+
return params.customBidderEndpoint
288+
}
289+
286290
if (params.useHttp2) {
287291
return BIDDER_ENDPOINT_HTTP2;
288292
}
@@ -337,6 +341,12 @@ export const spec = {
337341
return false;
338342
}
339343

344+
if (bid.params.customBidderEndpoint &&
345+
(!bid.params.customBidderEndpoint.startsWith('https://') || !bid.params.customBidderEndpoint.endsWith('/bid/bidder/'))) {
346+
utils.logWarn(BIDDER_CODE + ': if params.customBidderEndpoint is provided, it must start with https:// and end with /bid/bidder/');
347+
return false;
348+
}
349+
340350
const mediaTypesBanner = utils.deepAccess(bid, 'mediaTypes.banner');
341351
const mediaTypesVideo = utils.deepAccess(bid, 'mediaTypes.video');
342352

modules/ttdBidAdapter.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The Trade Desk bid adapter supports Banner and Video.
5454
banner: {
5555
expdir: [1, 3]
5656
},
57+
customBidderEndpoint: 'https://customBidderEndpoint/bid/bidder/',
5758
}
5859
}
5960
]
@@ -109,7 +110,8 @@ The Trade Desk bid adapter supports Banner and Video.
109110
supplySourceId: 'supplier',
110111
publisherId: '1427ab10f2e448057ed3b422',
111112
placementId: '/1111/home#header',
112-
bidfloor: 0.45
113+
bidfloor: 0.45,
114+
customBidderEndpoint: 'https://customBidderEndpoint/bid/bidder/',
113115
}
114116
}
115117
]

test/spec/modules/ttdBidAdapter_spec.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ describe('ttdBidAdapter', function () {
9999
bid.params.bidfloor = 3.01;
100100
expect(spec.isBidRequestValid(bid)).to.equal(true);
101101
});
102+
103+
it('should return false if customBidderEndpoint is provided and does not start with https://', function () {
104+
const bid = makeBid();
105+
bid.params.customBidderEndpoint = 'customBidderEndpoint/bid/bidder/';
106+
expect(spec.isBidRequestValid(bid)).to.equal(false);
107+
});
108+
109+
it('should return false if customBidderEndpoint is provided and does not end with /bid/bidder/', function () {
110+
const bid = makeBid();
111+
bid.params.customBidderEndpoint = 'https://customBidderEndpoint/bid/bidder';
112+
expect(spec.isBidRequestValid(bid)).to.equal(false);
113+
});
114+
115+
it('should return true if customBidderEndpoint is provided that starts with https:// and ends with /bid/bidder/', function () {
116+
const bid = makeBid();
117+
bid.params.customBidderEndpoint = 'https://customBidderEndpoint/bid/bidder/';
118+
expect(spec.isBidRequestValid(bid)).to.equal(true);
119+
});
102120
});
103121

104122
describe('banner', function () {
@@ -306,11 +324,18 @@ describe('ttdBidAdapter', function () {
306324
expect(url).to.equal('https://direct.adsrvr.org/bid/bidder/supplier');
307325
});
308326

327+
it('sends bid requests to the correct http2 endpoint', function () {
328+
const bannerBidRequestsWithHttp2Endpoint = deepClone(baseBannerBidRequests);
329+
bannerBidRequestsWithHttp2Endpoint[0].params.useHttp2 = true;
330+
const url = testBuildRequests(bannerBidRequestsWithHttp2Endpoint, baseBidderRequest).url;
331+
expect(url).to.equal('https://d2.adsrvr.org/bid/bidder/supplier');
332+
});
333+
309334
it('sends bid requests to the correct custom endpoint', function () {
310335
const bannerBidRequestsWithCustomEndpoint = deepClone(baseBannerBidRequests);
311-
bannerBidRequestsWithCustomEndpoint[0].params.useHttp2 = true;
336+
bannerBidRequestsWithCustomEndpoint[0].params.customBidderEndpoint = 'https://customBidderEndpoint/bid/bidder/';
312337
const url = testBuildRequests(bannerBidRequestsWithCustomEndpoint, baseBidderRequest).url;
313-
expect(url).to.equal('https://d2.adsrvr.org/bid/bidder/supplier');
338+
expect(url).to.equal('https://customBidderEndpoint/bid/bidder/supplier');
314339
});
315340

316341
it('sends publisher id', function () {

0 commit comments

Comments
 (0)