Skip to content

Commit

Permalink
Admatic Bid Adapter: alias and bid floor features activated
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihkaya84 committed Nov 4, 2022
1 parent 7a845b7 commit 7a2e0e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
23 changes: 14 additions & 9 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../s
import { loadExternalScript } from '../src/adloader.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb';
const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js';
const BIDDER_CODE = 'admatic';

export const spec = {
code: 'admatic',
aliases: [
{code: 'adpixel'}
],
supportedMediaTypes: ['video', 'banner'],
/**
* Determines whether or not the given bid request is valid.
Expand All @@ -20,11 +20,12 @@ export const spec = {
let isValid = false;
if (typeof bid.params !== 'undefined') {
let isValidNetworkId = _validateId(getValue(bid.params, 'networkId'));
isValid = isValidNetworkId;// && isValidTypeId;
let isValidHost = getValue(bid.params, 'host');
isValid = isValidNetworkId && isValidHost;
}

if (!isValid) {
logError('AdMatic networkId parameters are required. Bid aborted.');
logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`);
}
return isValid;
},
Expand All @@ -36,11 +37,13 @@ export const spec = {
*/
buildRequests: function(validBidRequests, bidderRequest) {
const bids = validBidRequests.map(buildRequestObject);
const bidderName = validBidRequests[0].bidder;
const networkId = getValue(validBidRequests[0].params, 'networkId');
const host = getValue(validBidRequests[0].params, 'host');
const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY';

setTimeout(() => {
loadExternalScript(SYNC_URL, BIDDER_CODE);
loadExternalScript(SYNC_URL, bidderName);
}, bidderRequest.timeout);

const payload = {
Expand All @@ -59,14 +62,14 @@ export const spec = {
imp: bids,
ext: {
'cur': currency,
'type': 'admatic'
'bidder': bidderName
}
};

const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: ENDPOINT_URL,
url: `https://${host}/pb?bidder=${bidderName}`,
data: payloadString,
options: {
contentType: 'application/json'
Expand Down Expand Up @@ -97,7 +100,7 @@ export const spec = {
advertiserDomains: bid && bid.adomain ? bid.adomain : []
},
ttl: 360,
bidder: 'admatic',
bidder: JSON.parse(request.data).ext.bidder,
timeToRespond: 1,
requestTimestamp: 1
};
Expand All @@ -109,6 +112,8 @@ export const spec = {
}
};

registerBidder(spec);

function enrichSlotWithFloors(slot, bidRequest) {
try {
const slotFloors = {};
Expand Down
7 changes: 4 additions & 3 deletions modules/admaticBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Use `admatic` as bidder.
bids: [{
bidder: 'admatic',
params: {
networkId: 12345
networkId: 12345,
host: 'layer.serve.admatic.com.tr'
}
}]
},{
Expand All @@ -27,14 +28,14 @@ Use `admatic` as bidder.
bids: [{
bidder: 'admatic',
params: {
networkId: 12345
networkId: 12345,
host: 'layer.serve.admatic.com.tr'
}
}]
}];
```

## UserSync example

```
pbjs.setConfig({
userSync: {
Expand Down
1 change: 1 addition & 0 deletions src/adloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const _approvedLoadExternalJSList = [
'debugging',
'adloox',
'admatic',
'adpixel',
'criteo',
'outstream',
'adagio',
Expand Down

0 comments on commit 7a2e0e2

Please sign in to comment.