Skip to content

Commit

Permalink
Lasso Bid Adapter : add npi support (prebid#12545)
Browse files Browse the repository at this point in the history
* New npi functionality for Lasso prebid adapter

* New npi functionality for Lasso prebid adapter

* Update unit tests for lasso prebid adapter
  • Loading branch information
victorlassomarketing authored Dec 13, 2024
1 parent fb8fb3d commit 9fe52d9
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 4 deletions.
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

0 comments on commit 9fe52d9

Please sign in to comment.