Skip to content

Commit

Permalink
The Moneytizer Bid Adapter: initial release (#11047)
Browse files Browse the repository at this point in the history
  • Loading branch information
themoneytizer authored Feb 15, 2024
1 parent 9379982 commit 57325f2
Show file tree
Hide file tree
Showing 3 changed files with 435 additions and 0 deletions.
102 changes: 102 additions & 0 deletions modules/themoneytizerBidAdapter.js
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);
44 changes: 44 additions & 0 deletions modules/themoneytizerBidAdapter.md
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
},
},
],
},
];
```
Loading

0 comments on commit 57325f2

Please sign in to comment.