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

RixEngine Bid Adapter: add AlgoriX alias #12654

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
32 changes: 32 additions & 0 deletions modules/algorixBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Overview

```
Module Name: AlgoriX Bid Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

Connects to AlgoriX exchange for bids.

AlgoriX bid adapter supports Banner currently.

# Sample Banner Ad Unit: For Publishers
```
var adUnits = [
{
sizes: [
[300, 250]
],
bids: [{
bidder: 'algorix',
params: {
region: "APAC", // option
token: '89b6d58567e3913e507f2be61fe8823e', // required
sid: 260785, // required
}
}]
}];
```

70 changes: 47 additions & 23 deletions modules/rixengineBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'rixengine';

let ENDPOINT = null;
let SID = null;
let TOKEN = null;

// We will also allow an alias named 'algorix'
const ALGORIX_REGIONS = ['apac', 'use', 'euc'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't implement this, but you could detect the region like this

const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;

const DEFAULT_BID_TTL = 30;
const DEFAULT_CURRENCY = 'USD';
const DEFAULT_NET_REVENUE = true;

// We'll store the endpoint in a global for simplicity.
// If your use case requires multiple endpoints per auction, store these in a request-level object.
let ENDPOINT = null;

const converter = ortbConverter({
context: {
netRevenue: DEFAULT_NET_REVENUE,
Expand All @@ -24,35 +26,57 @@ const converter = ortbConverter({
return imp;
},
});

export const spec = {
code: BIDDER_CODE,

// Include your GVL ID
gvlid: 1176,

// Register "algorix" as an alias, also with gvlid if needed
aliases: [{
code: 'algorix',
gvlid: 1176
}],

supportedMediaTypes: [BANNER],

isBidRequestValid: function (bid) {
if (
Boolean(bid.params.endpoint) &&
Boolean(bid.params.sid) &&
Boolean(bid.params.token)
) {
SID = bid.params.sid;
TOKEN = bid.params.token;
ENDPOINT = bid.params.endpoint + '?sid=' + SID + '&token=' + TOKEN;
return true;
if (bid.bidder === 'algorix') {
// Algorix-specific logic for building endpoint
if (Boolean(bid.params.sid) && Boolean(bid.params.token)) {
let region = bid.params.region ? bid.params.region.toLowerCase() : '';
// Base URL for Algorix
let url = `xyz.svr-algorix.com/rtb/sa?sid=${bid.params.sid}&token=${bid.params.token}`;
// If region is in ALGORIX_REGIONS, prepend it, else just use url
ENDPOINT = 'https://' + (ALGORIX_REGIONS.includes(region) ? (region + '.' + url) : url);
return true;
}
return false;
} else {
// rixengine logic
if (
Boolean(bid.params.endpoint) &&
Boolean(bid.params.sid) &&
Boolean(bid.params.token)
) {
ENDPOINT = `${bid.params.endpoint}?sid=${bid.params.sid}&token=${bid.params.token}`;
return true;
}
return false;
}
return false;
},

buildRequests(bidRequests, bidderRequest) {
let data = converter.toORTB({ bidRequests, bidderRequest });
// All valid bids for this adapter (rixengine or algorix alias) share the same ENDPOINT in this simplified approach
const data = converter.toORTB({ bidRequests, bidderRequest });

return [
{
method: 'POST',
url: ENDPOINT,
data,
options: { contentType: 'application/json;charset=utf-8' },
},
];
return [{
method: 'POST',
url: ENDPOINT,
data,
options: { contentType: 'application/json;charset=utf-8' },
}];
},

interpretResponse(response, request) {
Expand Down