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

change payload #5105

Merged
merged 1 commit into from
Apr 10, 2020
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
19 changes: 8 additions & 11 deletions modules/proxistoreBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ const { registerBidder } = require('../src/adapters/bidderFactory.js');
const BIDDER_CODE = 'proxistore';
const PROXISTORE_VENDOR_ID = 418;

function _mapSizes(sizes) {
const flatSize = sizes.reduce((acc, val) => acc.concat(val), []); ;
return flatSize.map(array1d => { return { width: array1d[0], height: array1d[1] } });
}

function _createServerRequest(bidRequests, bidderRequest) {
const sizeIds = [];
bidRequests.forEach(bid => {
const sizeId = {id: bid.bidId, sizes: bid.sizes.map(size => { return { width: size[0], height: size[1] } })};
sizeIds.push(sizeId);
});
const payload = {
auctionId: bidRequests[0].auctionId,
transactionId: bidRequests[0].transactionId,
sizes: _mapSizes(bidRequests.map(x => x.sizes)),
transactionId: bidRequests[0].auctionId,
bids: sizeIds,
website: bidRequests[0].params.website,
language: bidRequests[0].params.language,
gdpr: {
applies: false
}
};

const bidIds = bidRequests.map(req => req.bidId);
bidIds.length === 1 ? payload.bidId = bidIds[0] : payload.bidIds = bidIds;

const options = {
contentType: 'application/json',
withCredentials: true
Expand All @@ -42,7 +39,7 @@ function _createServerRequest(bidRequests, bidderRequest) {

return {
method: 'POST',
url: bidRequests[0].params.url || 'https://abs.proxistore.com/' + payload.language + '/v3/rtb/prebid',
url: bidRequests[0].params.url || 'https://abs.proxistore.com/' + payload.language + '/v3/rtb/prebid/multi',
data: JSON.stringify(payload),
options: options
};
Expand Down
12 changes: 8 additions & 4 deletions test/spec/modules/proxistoreBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('ProxistoreBidAdapter', function () {
});

describe('buildRequests', function () {
const url = 'https://abs.proxistore.com/fr/v3/rtb/prebid';
const url = 'https://abs.proxistore.com/fr/v3/rtb/prebid/multi';
const request = spec.buildRequests([bid], bidderRequest);
it('should return a valid object', function () {
expect(request).to.be.an('object');
Expand All @@ -55,10 +55,14 @@ describe('ProxistoreBidAdapter', function () {
expect(data.gdpr.applies).to.be.true;
expect(data.gdpr.consentGiven).to.be.true;
});
it('should have a property bidId if there is only one bid', function () {
it('should have a property a length of bids equal to one if there is only one bid', function () {
const data = JSON.parse(request.data);
expect(data.hasOwnProperty('bidId')).to.be.true;
})
expect(data.hasOwnProperty('bids')).to.be.true;
expect(data.bids).to.be.an('array');
expect(data.bids.length).equal(1);
expect(data.bids[0].hasOwnProperty('id')).to.be.true;
expect(data.bids[0].sizes).to.be.an('array');
});
});

describe('interpretResponse', function () {
Expand Down