Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escalax Bid Adapter: initial release #12483

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions modules/escalaxBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';

const BIDDER_CODE = 'escalax';
const ESCALAX_SOURCE_ID_MACRO = '[sourceId]';
const ESCALAX_ACCOUNT_ID_MACRO = '[accountId]';
const ESCALAX_SUBDOMAIN_MACRO = '[subdomain]';
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
const ESCALAX_URL = `https://${ESCALAX_SUBDOMAIN_MACRO}.escalax.io/bid?type=pjs&partner=${ESCALAX_SOURCE_ID_MACRO}&token=${ESCALAX_ACCOUNT_ID_MACRO}`;
const ESCALAX_DEFAULT_CURRENCY = 'USD';
const ESCALAX_DEFAULT_SUBDOMAIN = 'bidder_us';

function createImp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
imp.ext = {
[BIDDER_CODE]: {
sourceId: bidRequest.params.sourceId,
accountId: bidRequest.params.accountId,
}
};
if (!imp.bidfloor) imp.bidfloor = bidRequest.params.bidfloor;
return imp;
}

function createRequest(buildRequest, imps, bidderRequest, context) {
const request = buildRequest(imps, bidderRequest, context);
const bid = context.bidRequests[0];
request.test = config.getConfig('debug') ? 1 : 0;
if (!request.cur) request.cur = [bid.params.currency || ESCALAX_DEFAULT_CURRENCY];
return request;
}

function createBidResponse(buildBidResponse, bid, context) {
const bidResponse = buildBidResponse(bid, context);
bidResponse.cur = 'USD';
return bidResponse;
}

function getSubdomain() {
const regionMap = {
'Europe': 'bidder_eu',
'Africa': 'bidder_eu',
'Atlantic': 'bidder_eu',
'Arctic': 'bidder_eu',
'Asia': 'bidder_apac',
'Australia': 'bidder_apac',
'Antarctica': 'bidder_apac',
'Pacific': 'bidder_apac',
'Indian': 'bidder_apac',
'America': 'bidder_us'
};

try {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const region = timezone.split('/')[0];
return regionMap[region] || 'bidder_us';
} catch (err) {
return 'bidder_us';
}
}

const converter = ortbConverter({
context: {
netRevenue: true,
ttl: 20,
},
imp: createImp,
request: createRequest,
bidResponse: createBidResponse
});

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

isBidRequestValid: (bid) => {
return Boolean(bid.params.sourceId) && Boolean(bid.params.accountId);
},

buildRequests: (validBidRequests, bidderRequest) => {
if (validBidRequests && validBidRequests.length === 0) return [];
const { sourceId, accountId } = validBidRequests[0].params;
const subdomain = getSubdomain();
const endpointURL = ESCALAX_URL
.replace(ESCALAX_SUBDOMAIN_MACRO, subdomain || ESCALAX_DEFAULT_SUBDOMAIN)
.replace(ESCALAX_ACCOUNT_ID_MACRO, sourceId)
.replace(ESCALAX_SOURCE_ID_MACRO, accountId);
const request = converter.toORTB({ bidRequests: validBidRequests, bidderRequest });
return {
method: 'POST',
url: endpointURL,
data: request
};
},

interpretResponse: (response, request) => {
if (response?.body) {
const bids = converter.fromORTB({ response: response.body, request: request.data }).bids;
return bids;
}
return [];
},
};

registerBidder(spec);
80 changes: 80 additions & 0 deletions modules/escalaxBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Overview

```
Module Name: Escalax SSP Bidder Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

Escalax Bidding adapter requires setup before beginning. Please contact us at <[email protected]>

# Test Parameters

```js
const adUnits = [
{
code: "banner1",
mediaTypes: {
banner: {
sizes: [
[300, 250],
[300, 600],
],
},
},
bids: [
{
bidder: "escalax",
params: {
accountId: "hash",
sourceId: "sourceId",
},
},
],
},
{
code: "native_example",
mediaTypes: {
native: {},
},
bids: [
{
bidder: "escalax",
params: {
accountId: "hash",
sourceId: "sourceId",
},
},
],
},
{
code: "video1",
sizes: [640, 480],
mediaTypes: {
video: {
minduration: 0,
maxduration: 999,
boxingallowed: 1,
skip: 0,
mimes: ["application/javascript", "video/mp4"],
w: 1920,
h: 1080,
protocols: [2],
linearity: 1,
api: [1, 2],
},
},
bids: [
{
bidder: "escalax",
params: {
accountId: "hash",
sourceId: "sourceId",
},
},
],
},
];
```
Loading
Loading