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

New advenue header bidding adapter #3429

Merged
merged 25 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
86 changes: 86 additions & 0 deletions modules/advenueBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes';
import * as utils from 'src/utils';

const BIDDER_CODE = 'advenue';
const URL_MULTI = '//ssp.advenuemedia.co.uk/?c=o&m=multi';

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

/**
* Determines whether or not the given bid request is valid.
*
* @param {object} bid The bid to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: (bid) => {
return Boolean(bid.bidId &&
bid.params &&
!isNaN(bid.params.placementId) &&
spec.supportedMediaTypes.indexOf(bid.params.traffic) !== -1
);
},

/**
* Make a server request from the list of BidRequests.
*
* @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server.
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: (validBidRequests, bidderRequest) => {
let winTop;
try {
winTop = window.top;
winTop.location.toString();
} catch (e) {
utils.logMessage(e);
winTop = window;
};

const location = bidderRequest ? new URL(bidderRequest.refererInfo.referer) : winTop.location;
const placements = [];
const request = {
'secure': (location.protocol === 'https:') ? 1 : 0,
'deviceWidth': winTop.screen.width,
'deviceHeight': winTop.screen.height,
'host': location.host,
'page': location.pathname,
'placements': placements
};

for (let i = 0; i < validBidRequests.length; i++) {
const bid = validBidRequests[i];
const params = bid.params;
placements.push({
placementId: params.placementId,
bidId: bid.bidId,
sizes: bid.sizes,
traffic: params.traffic
});
}
return {
method: 'POST',
url: URL_MULTI,
data: request
};
},

/**
* Unpack the response from the server into a list of bids.
*
* @param {*} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: (serverResponse) => {
try {
serverResponse = serverResponse.body;
} catch (e) {
utils.logMessage(e);
};
return serverResponse;
},
};

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

```
Module Name: Advenue SSP Bidder Adapter
Module Type: Bidder Adapter
Maintainer: dev.advenue@gmail.com
```

# Description

Module that connects to Advenue SSP demand sources

# Test Parameters
```
var adUnits = [{
code: 'placementCode',
sizes: [[300, 250]],
bids: [{
bidder: 'advenue',
params: {
placementId: 0,
traffic: 'banner'
}
}]
}
];
```
Loading