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

Triplelift - update creativeId #3305

Merged
merged 10 commits into from
Nov 16, 2018
11 changes: 7 additions & 4 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ export const tripleliftAdapterSpec = {

buildRequests: function(bidRequests, bidderRequest) {
let tlCall = STR_ENDPOINT;
let referrer = utils.getTopWindowUrl();
let data = _buildPostBody(bidRequests);

tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid');
tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$');
tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer);

if (bidderRequest && bidderRequest.refererInfo) {
let referrer = bidderRequest.refererInfo.referer;
tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer);
}

if (bidderRequest && bidderRequest.timeout) {
tlCall = utils.tryAppendQueryString(tlCall, 'tmax', bidderRequest.timeout);
Expand Down Expand Up @@ -110,11 +113,11 @@ function _buildResponseObject(bidderRequest, bid) {
let width = bid.width || 1;
let height = bid.height || 1;
let dealId = bid.deal_id || '';
let creativeId = bid.imp_id;
let creativeId = bid.crid || '';

if (bid.cpm != 0 && bid.ad) {
bidResponse = {
requestId: bidderRequest.bids[creativeId].bidId,
requestId: bidderRequest.bids[bid.imp_id].bidId,
cpm: bid.cpm,
width: width,
height: height,
Expand Down
44 changes: 36 additions & 8 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,42 @@ describe('triplelift adapter', function () {
}
];

let bidderRequest = {
bidderCode: 'triplelift',
auctionId: 'a7ebcd1d-66ff-4b5c-a82c-6a21a6ee5a18',
bidderRequestId: '5c55612f99bc11',
bids: [
{
imp_id: 0,
cpm: 1.062,
width: 300,
height: 250,
ad: 'ad-markup',
iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg'
}
],
refererInfo: {
referer: 'http://examplereferer.com'
},
gdprConsent: {
consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY',
gdprApplies: true
}
};

it('exists and is an object', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests);
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request).to.exist.and.to.be.a('object');
});

it('should only parse sizes that are of the proper length and format', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests);
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].banner.format).to.have.length(2);
expect(request.data.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
});

it('should be a post request and populate the payload', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests);
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const payload = request.data;
expect(payload).to.exist;
expect(payload.imp[0].tagid).to.equal('12345');
Expand All @@ -89,16 +112,15 @@ describe('triplelift adapter', function () {
});

it('should return a query string for TL call', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests);
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const url = request.url;
expect(url).to.exist;
expect(url).to.be.a('string');
expect(url).to.match(/(?:tlx.3lift.com\/header\/auction)/)
expect(url).to.match(/(?:lib=prebid)/)
expect(url).to.match(/(?:prebid.version)/)
// expect(url).to.match(/(?:fe=)/) //
expect(url).to.match(/(?:referrer)/)
})
expect(url).to.match(/(?:referrer)/);
});
});

describe('interpretResponse', function () {
Expand Down Expand Up @@ -130,8 +152,11 @@ describe('triplelift adapter', function () {
iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg'
}
],
refererInfo: {
referer: 'http://examplereferer.com'
},
gdprConsent: {
consentString: 'BOONm0NOONma-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVOQ6gEaY',
consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY',
gdprApplies: true
}
};
Expand Down Expand Up @@ -201,6 +226,9 @@ describe('triplelift adapter', function () {
iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg'
}
],
refererInfo: {
referer: 'http://examplereferer.com'
},
gdprConsent: {
consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY',
gdprApplies: true
Expand Down