Skip to content

Colossus adapter changes #4476

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

Merged
merged 14 commits into from
Dec 2, 2019
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
21 changes: 12 additions & 9 deletions modules/colossussspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes';
import * as utils from '../src/utils';

const BIDDER_CODE = 'colossusssp';
const URL = '//colossusssp.com/?c=o&m=multi';
const URL_SYNC = '//colossusssp.com/?c=o&m=cookie';
const G_URL = 'https://colossusssp.com/?c=o&m=multi';
const G_URL_SYNC = 'https://colossusssp.com/?c=o&m=cookie';

function isBidResponseValid(bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) {
Expand Down Expand Up @@ -42,15 +42,16 @@ export const spec = {
* @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) => {
buildRequests: (validBidRequests, bidderRequest) => {
let winTop = window;
let location;
try {
window.top.location.toString();
location = new URL(bidderRequest.refererInfo.referer)
winTop = window.top;
} catch (e) {
location = winTop.location;
utils.logMessage(e);
};
let location = utils.getTopWindowLocation();
let placements = [];
let request = {
'deviceWidth': winTop.screen.width,
Expand All @@ -61,19 +62,21 @@ export const spec = {
'page': location.pathname,
'placements': placements
};

for (let i = 0; i < validBidRequests.length; i++) {
let bid = validBidRequests[i];
let traff = bid.params.traffic || BANNER
let placement = {
placementId: bid.params.placement_id,
bidId: bid.bidId,
sizes: bid.sizes,
traffic: bid.params.traffic || BANNER
sizes: bid.mediaTypes[traff].sizes,
traffic: traff
};
placements.push(placement);
}
return {
method: 'POST',
url: URL,
url: G_URL,
data: request
};
},
Expand Down Expand Up @@ -103,7 +106,7 @@ export const spec = {
getUserSyncs: () => {
return [{
type: 'image',
url: URL_SYNC
url: G_URL_SYNC
}];
}
};
Expand Down
6 changes: 5 additions & 1 deletion modules/colossussspBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ Module that connects to Colossus SSP demand sources
```
var adUnits = [{
code: 'placementid_0',
sizes: [[300, 250]],
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]]
}
},
bids: [{
bidder: 'colossusssp',
params: {
Expand Down
10 changes: 7 additions & 3 deletions test/spec/modules/colossussspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ describe('ColossussspAdapter', function () {
},
placementCode: 'placementid_0',
auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
sizes: [[300, 250]],
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62'
};

Expand All @@ -37,7 +41,7 @@ describe('ColossussspAdapter', function () {
expect(serverRequest.method).to.equal('POST');
});
it('Returns valid URL', function () {
expect(serverRequest.url).to.equal('//colossusssp.com/?c=o&m=multi');
expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi');
});
it('Returns valid data if array of bids is valid', function () {
let data = serverRequest.data;
Expand Down Expand Up @@ -112,7 +116,7 @@ describe('ColossussspAdapter', function () {
expect(userSync[0].type).to.exist;
expect(userSync[0].url).to.exist;
expect(userSync[0].type).to.be.equal('image');
expect(userSync[0].url).to.be.equal('//colossusssp.com/?c=o&m=cookie');
expect(userSync[0].url).to.be.equal('https://colossusssp.com/?c=o&m=cookie');
});
});
});