Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Lasso Bid Adapter : add npi support #12545

Merged
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
8 changes: 5 additions & 3 deletions modules/lassoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export const spec = {
sizes,
aimXR,
uid: '$UID',
npi: bidRequest.params.npi || '',
npi_hash: bidRequest.params.npiHash || '',
params: JSON.stringify(bidRequest.params),
crumbs: JSON.stringify(bidRequest.crumbs),
prebidVersion: '$prebid.version$',
Expand Down Expand Up @@ -128,10 +130,10 @@ function getBidRequestUrl(aimXR, params) {
if (params && params.dtc) {
path = '/dtc-request';
}
if (!aimXR) {
return GET_IUD_URL + ENDPOINT_URL + path;
if (aimXR || params.npi || params.npiHash) {
return ENDPOINT_URL + path;
}
return ENDPOINT_URL + path;
return GET_IUD_URL + ENDPOINT_URL + path;
}

function getDeviceData() {
Expand Down
72 changes: 71 additions & 1 deletion test/spec/modules/lassoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { spec } from 'modules/lassoBidAdapter.js';
import { server } from '../../mocks/xhr';

const ENDPOINT_URL = 'https://trc.lhmos.com/prebid';
const GET_IUD_URL = 'https://secure.adnxs.com/getuid?';

const bid = {
bidder: 'lasso',
Expand Down Expand Up @@ -78,7 +79,7 @@ describe('lassoBidAdapter', function () {
});
});

describe('buildRequests', function () {
describe('buildRequests with standard flow', function () {
let validBidRequests, bidRequest;
before(() => {
validBidRequests = spec.buildRequests([bid], bidderRequest);
Expand All @@ -97,6 +98,75 @@ describe('lassoBidAdapter', function () {
expect(bidRequest.method).to.exist;
expect(bidRequest.method).to.equal('GET');
});

it('should send request to get uid and trc via get request', () => {
expect(bidRequest.method).to.equal('GET');
expect(bidRequest.url).to.equal(GET_IUD_URL + ENDPOINT_URL + '/request');
});
});

describe('buildRequests with npi', function () {
let validBidRequests, bidRequest;
before(() => {
const updateBidParams = Object.assign({}, bid, {
params: {
adUnitId: 123456,
npi: '123'
}
});
validBidRequests = spec.buildRequests([updateBidParams], bidderRequest);
expect(validBidRequests).to.be.an('array').that.is.not.empty;
bidRequest = validBidRequests[0];
})

it('Returns valid bidRequest', function () {
expect(bidRequest).to.exist;
expect(bidRequest.method).to.exist;
expect(bidRequest.url).to.exist;
expect(bidRequest.data).to.exist;
});

it('Returns GET method', function() {
expect(bidRequest.method).to.exist;
expect(bidRequest.method).to.equal('GET');
});

it('should send request to trc via get request with npi', () => {
expect(bidRequest.method).to.equal('GET');
expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request');
});
});

describe('buildRequests with npi hash', function () {
let validBidRequests, bidRequest;
before(() => {
const updateBidParams = Object.assign({}, bid, {
params: {
adUnitId: 123456,
npiHash: '123'
}
});
validBidRequests = spec.buildRequests([updateBidParams], bidderRequest);
expect(validBidRequests).to.be.an('array').that.is.not.empty;
bidRequest = validBidRequests[0];
})

it('Returns valid bidRequest', function () {
expect(bidRequest).to.exist;
expect(bidRequest.method).to.exist;
expect(bidRequest.url).to.exist;
expect(bidRequest.data).to.exist;
});

it('Returns GET method', function() {
expect(bidRequest.method).to.exist;
expect(bidRequest.method).to.equal('GET');
});

it('should send request to trc via get request with npi', () => {
expect(bidRequest.method).to.equal('GET');
expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request');
});
});

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