-
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.
The Moneytizer Bid Adapter: initial release (#11047)
- Loading branch information
1 parent
9379982
commit 57325f2
Showing
3 changed files
with
435 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,102 @@ | ||
import { logInfo, logWarn } from '../src/utils.js'; | ||
import { BANNER } from '../src/mediaTypes.js'; | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
|
||
const BIDDER_CODE = 'themoneytizer'; | ||
const GVLID = 1265; | ||
const ENDPOINT_URL = 'https://ads.biddertmz.com/m/'; | ||
|
||
export const spec = { | ||
aliases: [BIDDER_CODE], | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER], | ||
gvlid: GVLID, | ||
|
||
isBidRequestValid: function (bid) { | ||
if (!(bid && bid.params.pid)) { | ||
logWarn('Invalid bid request - missing required bid params'); | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
|
||
buildRequests: function (validBidRequests, bidderRequest) { | ||
return validBidRequests.map((bidRequest) => { | ||
const payload = { | ||
ext: bidRequest.ortb2Imp.ext, | ||
params: bidRequest.params, | ||
size: bidRequest.mediaTypes, | ||
adunit: bidRequest.adUnitCode, | ||
request_id: bidRequest.bidId, | ||
timeout: bidderRequest.timeout, | ||
ortb2: bidderRequest.ortb2, | ||
eids: bidRequest.userIdAsEids, | ||
id: bidRequest.auctionId, | ||
schain: bidRequest.schain, | ||
version: '$prebid.version$', | ||
excl_sync: window.tmzrBidderExclSync | ||
}; | ||
|
||
const baseUrl = bidRequest.params.baseUrl || ENDPOINT_URL; | ||
|
||
if (bidderRequest && bidderRequest.refererInfo) { | ||
payload.referer = bidderRequest.refererInfo.topmostLocation; | ||
payload.referer_canonical = bidderRequest.refererInfo.canonicalUrl; | ||
} | ||
|
||
if (bidderRequest && bidderRequest.gdprConsent) { | ||
payload.consent_string = bidderRequest.gdprConsent.consentString; | ||
payload.consent_required = bidderRequest.gdprConsent.gdprApplies; | ||
} | ||
|
||
if (bidRequest.params.test) { | ||
payload.test = bidRequest.params.test; | ||
} | ||
|
||
payload.userEids = bidRequest.userIdAsEids || []; | ||
|
||
return { | ||
method: 'POST', | ||
url: baseUrl, | ||
data: JSON.stringify(payload), | ||
}; | ||
}); | ||
}, | ||
|
||
interpretResponse: function (serverResponse, bidRequest) { | ||
const bidResponses = []; | ||
const response = serverResponse.body; | ||
|
||
if (response && response.bid && !response.timeout && !!response.bid.ad) { | ||
bidResponses.push(response.bid); | ||
} | ||
|
||
return bidResponses; | ||
}, | ||
getUserSyncs: function (syncOptions, serverResponses) { | ||
if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) { | ||
return []; | ||
} | ||
|
||
let s = []; | ||
serverResponses.map((c) => { | ||
if (c.body.c_sync) { | ||
c.body.c_sync.bidder_status.map((p) => { | ||
if (p.usersync.type === 'redirect') { | ||
p.usersync.type = 'image'; | ||
} | ||
s.push(p.usersync); | ||
}) | ||
} | ||
}); | ||
|
||
return s; | ||
}, | ||
|
||
onTimeout: function onTimeout(timeoutData) { | ||
logInfo('The Moneytizer - Timeout from adapter', timeoutData); | ||
}, | ||
}; | ||
|
||
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,44 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: The Moneytizer Bid Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: [email protected] | ||
``` | ||
|
||
## Description | ||
|
||
Module that connects to The Moneytizer demand sources | ||
|
||
## Bid Parameters | ||
|
||
| Key | Required | Example | Description | | ||
| --------------- | -------- | ---------------------------------------------| ---------------------------------------| | ||
| `pid` | yes | `12345` | The Moneytizer's publisher token | | ||
| `test` | no | `1` | Set to 1 to receive a test bid response| | ||
| `baseUrl` | no | `'https://custom-endpoint.biddertmz.com/m/'` | Call on custom endpoint | | ||
|
||
## Test parameters | ||
|
||
```js | ||
|
||
var adUnits = [ | ||
{ | ||
code: 'your-adunit-code', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]], | ||
}, | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "themoneytizer", | ||
params: { | ||
pid: -1, | ||
test: 1 | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
``` |
Oops, something went wrong.