Skip to content

Commit

Permalink
Smaato: Support in-app use cases (#5765)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrosinski authored Sep 25, 2020
1 parent f1ea594 commit 7aff389
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/smaatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => {
utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

if (utils.deepAccess(validBidRequests[0], 'params.app')) {
const geo = utils.deepAccess(validBidRequests[0], 'params.app.geo');
utils.deepSetValue(request, 'device.geo', geo);
const ifa = utils.deepAccess(validBidRequests[0], 'params.app.ifa')
utils.deepSetValue(request, 'device.ifa', ifa);
}

utils.logInfo('[SMAATO] OpenRTB Request:', request);
return JSON.stringify(request);
}
Expand Down Expand Up @@ -185,7 +192,7 @@ export const spec = {
ttl: ttlSec,
creativeId: b.crid,
dealId: b.dealid || null,
netRevenue: true,
netRevenue: utils.deepAccess(b, 'ext.net', true),
currency: res.cur,
meta: {
advertiserDomains: b.adomain,
Expand Down
57 changes: 57 additions & 0 deletions test/spec/modules/smaatoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,36 @@ const combinedBannerAndVideoBidRequest = {
bidderWinsCount: 0
};

const inAppBidRequest = {
bidder: 'smaato',
params: {
publisherId: 'publisherId',
adspaceId: 'adspaceId',
app: {
ifa: 'aDeviceId',
geo: {
lat: 33.3,
lon: -88.8
}
}
},
mediaTypes: {
banner: {
sizes: [[300, 50]]
}
},
adUnitCode: '/19968336/header-bid-tag-0',
transactionId: 'transactionId',
sizes: [[300, 50]],
bidId: 'bidId',
bidderRequestId: 'bidderRequestId',
auctionId: 'auctionId',
src: 'client',
bidRequestsCount: 1,
bidderRequestsCount: 1,
bidderWinsCount: 0
};

describe('smaatoBidAdapterTest', () => {
describe('isBidRequestValid', () => {
it('has valid params', () => {
Expand Down Expand Up @@ -462,6 +492,27 @@ describe('smaatoBidAdapterTest', () => {
});
});

describe('in-app requests', () => {
it('add geo and ifa info to device object', () => {
let req = JSON.parse(spec.buildRequests([inAppBidRequest], defaultBidderRequest).data);
expect(req.device.geo).to.deep.equal({'lat': 33.3, 'lon': -88.8});
expect(req.device.ifa).to.equal('aDeviceId');
});
it('add only ifa to device object', () => {
let inAppBidRequestWithoutGeo = utils.deepClone(inAppBidRequest);
delete inAppBidRequestWithoutGeo.params.app.geo
let req = JSON.parse(spec.buildRequests([inAppBidRequestWithoutGeo], defaultBidderRequest).data);

expect(req.device.geo).to.not.exist;
expect(req.device.ifa).to.equal('aDeviceId');
});
it('add no specific device info if param does not exist', () => {
let req = JSON.parse(spec.buildRequests([singleBannerBidRequest], defaultBidderRequest).data);
expect(req.device.geo).to.not.exist;
expect(req.device.ifa).to.not.exist;
});
});

describe('interpretResponse', () => {
it('single image reponse', () => {
const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_IMG), request);
Expand Down Expand Up @@ -501,5 +552,11 @@ describe('smaatoBidAdapterTest', () => {
expect(bids[0].ttl).to.equal(400);
clock.restore();
});
it('uses net revenue flag send from server', () => {
let resp = openRtbBidResponse(ADTYPE_IMG);
resp.body.seatbid[0].bid[0].ext = {net: false};
const bids = spec.interpretResponse(resp, request);
expect(bids[0].netRevenue).to.equal(false);
})
});
});

0 comments on commit 7aff389

Please sign in to comment.