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

Removed deprecated priceType option (+tests) #3170

Merged
merged 1 commit into from
Oct 16, 2018
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
14 changes: 4 additions & 10 deletions modules/visxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ export const spec = {
config.getConfig(`currency.bidderCurrencyDefault.${BIDDER_CODE}`) ||
config.getConfig('currency.adServerCurrency') ||
DEFAULT_CUR;
let priceType = 'net';
let reqId;

bids.forEach(bid => {
if (bid.params.priceType === 'gross') {
priceType = 'gross';
}
if (!bidsMap[bid.params.uid]) {
bidsMap[bid.params.uid] = [bid];
auids.push(bid.params.uid);
Expand All @@ -48,9 +44,8 @@ export const spec = {

const payload = {
u: utils.getTopWindowUrl(),
pt: priceType,
pt: 'net',
auids: auids.join(','),
test: 1,
r: reqId,
cur: currency,
};
Expand All @@ -75,7 +70,6 @@ export const spec = {
serverResponse = serverResponse && serverResponse.body;
const bidResponses = [];
const bidsMap = bidRequest.bidsMap;
const priceType = bidRequest.data.pt;
const currency = bidRequest.data.cur;

let errorMessage;
Expand All @@ -87,7 +81,7 @@ export const spec = {

if (!errorMessage && serverResponse.seatbid) {
serverResponse.seatbid.forEach(respItem => {
_addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, currency, bidResponses);
_addBidResponse(_getBidFromResponse(respItem), bidsMap, currency, bidResponses);
});
}
if (errorMessage) utils.logError(errorMessage);
Expand Down Expand Up @@ -123,7 +117,7 @@ function _getBidFromResponse(respItem) {
return respItem && respItem.bid && respItem.bid[0];
}

function _addBidResponse(serverBid, bidsMap, priceType, currency, bidResponses) {
function _addBidResponse(serverBid, bidsMap, currency, bidResponses) {
if (!serverBid) return;
let errorMessage;
if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid);
Expand All @@ -139,7 +133,7 @@ function _addBidResponse(serverBid, bidsMap, priceType, currency, bidResponses)
height: serverBid.h,
creativeId: serverBid.auid,
currency: currency || DEFAULT_CUR,
netRevenue: priceType !== 'gross',
netRevenue: true,
ttl: TIME_TO_LIVE,
ad: serverBid.adm,
dealId: serverBid.dealid
Expand Down
24 changes: 20 additions & 4 deletions test/spec/modules/visxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ describe('VisxAdapter', function () {
expect(payload).to.have.property('cur', 'EUR');
});

it('pt parameter must be "gross" if params.priceType === "gross"', function () {
it('pt parameter must be "net" if params.priceType === "gross"', function () {
bidRequests[1].params.priceType = 'gross';
const request = spec.buildRequests(bidRequests);
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('u').that.is.a('string');
expect(payload).to.have.property('pt', 'gross');
expect(payload).to.have.property('pt', 'net');
expect(payload).to.have.property('auids', '903535,903536');
expect(payload).to.have.property('r', '22edbae2733bf6');
expect(payload).to.have.property('cur', 'EUR');
delete bidRequests[1].params.priceType;
});

it('pt parameter must be "net" or "gross"', function () {
bidRequests[1].params.priceType = 'some';
it('pt parameter must be "net" if params.priceType === "net"', function () {
bidRequests[1].params.priceType = 'net';
const request = spec.buildRequests(bidRequests);
const payload = request.data;
expect(payload).to.be.an('object');
Expand All @@ -123,6 +123,20 @@ describe('VisxAdapter', function () {
expect(payload).to.have.property('cur', 'EUR');
delete bidRequests[1].params.priceType;
});

it('pt parameter must be "net" if params.priceType === "undefined"', function () {
bidRequests[1].params.priceType = 'undefined';
const request = spec.buildRequests(bidRequests);
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('u').that.is.a('string');
expect(payload).to.have.property('pt', 'net');
expect(payload).to.have.property('auids', '903535,903536');
expect(payload).to.have.property('r', '22edbae2733bf6');
expect(payload).to.have.property('cur', 'EUR');
delete bidRequests[1].params.priceType;
});

it('should add currency from currency.bidderCurrencyDefault', function () {
const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
arg => arg === 'currency.bidderCurrencyDefault.visx' ? 'JPY' : 'USD');
Expand All @@ -136,6 +150,7 @@ describe('VisxAdapter', function () {
expect(payload).to.have.property('cur', 'JPY');
getConfigStub.restore();
});

it('should add currency from currency.adServerCurrency', function () {
const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
arg => arg === 'currency.bidderCurrencyDefault.visx' ? '' : 'USD');
Expand All @@ -149,6 +164,7 @@ describe('VisxAdapter', function () {
expect(payload).to.have.property('cur', 'USD');
getConfigStub.restore();
});

it('if gdprConsent is present payload must have gdpr params', function () {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}});
const payload = request.data;
Expand Down