Skip to content

Commit

Permalink
one
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenmore committed Jun 24, 2021
1 parent 32b344a commit d5cdc8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
22 changes: 10 additions & 12 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as utils from '../src/utils.js'
import { BANNER, VIDEO } from '../src/mediaTypes.js';

import { config } from '../src/config.js'
import { createEidsArray } from './userId/eids.js';
import { getStorageManager } from '../src/storageManager.js';
import includes from 'core-js-pure/features/array/includes';
import { registerBidder } from '../src/adapters/bidderFactory.js'
Expand Down Expand Up @@ -84,14 +83,6 @@ function getWrapperCode(wrapper, data) {
return wrapper.replace('AD_JSON', window.btoa(JSON.stringify(data)))
}

function _getTradeDeskIDParam(userId) {
const unifiedIdObj = {};
if (userId.tdid) {
unifiedIdObj.tdid = userId.tdid;
}
return unifiedIdObj;
}

function _getDigiTrustQueryParams(userId) {
let digiTrustId = userId.digitrustid && userId.digitrustid.data;
// Verify there is an ID and this user has not opted out
Expand Down Expand Up @@ -231,6 +222,13 @@ function _getFloor (mediaTypes, staticBidFloor, bid) {
return bidFloor;
}

function getEids (userId) {
return Object.keys(userId).reduce(function (eids, provider) {
if (provider.id) eids[provider] = userId[provider].id;
return eids;
}, {});
}

/**
* Make a server request from the list of BidRequests.
*
Expand Down Expand Up @@ -260,8 +258,8 @@ function buildRequests (validBidRequests, bidderRequest) {
let gpid = '';

// ADTS-134 Fetch DIL Envelope for Client Side Header Bidding
bidRequest.userId && eids.push.apply(eids, createEidsArray(bidRequest.userId));
eids.length && (data.user = { ext: { eids } });
eids.push.apply(eids, getEids(userId));
for (const eid in eids) data[eid] = eids[eid];

// ADJS-1024
if (utils.deepAccess(ortb2Imp, 'ext.data.adserver.name')) {
Expand Down Expand Up @@ -334,7 +332,7 @@ function buildRequests (validBidRequests, bidderRequest) {
url: BID_ENDPOINT,
method: 'GET',
gpid: gpid,
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId), _getTradeDeskIDParam(userId))
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId))
})
});
return bids;
Expand Down
12 changes: 5 additions & 7 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,20 @@ describe('gumgumAdapter', function () {
const zoneParam = { 'zone': '123a' };
const pubIdParam = { 'pubId': 123 };

it('should send IDL envelope if available', function () {
const id = 'abc123';
const idl_env = id;
const source = 'liveramp.com';
const atype = 3;
it('should send IDL envelope ID if available', function () {
const idl_env = 'abc123';
const request = { ...bidRequests[0], userId: { idl_env } };
const bidRequest = spec.buildRequests([request])[0];

expect(bidRequest.data.user.ext).to.deep.equal({ eids: [ { source, uids: [ { id, atype } ] } ] });
expect(bidRequest.data).to.have.property('idl_env');
expect(bidRequest.data.idl_env).to.equal(idl_env);
});

it('should not send IDL envelope if not available', function () {
const request = { ...bidRequests[0] };
const bidRequest = spec.buildRequests([request])[0];

expect(bidRequest.data).to.not.have.property('user');
expect(bidRequest.data).to.not.have.property('idl_env');
});

it('should set pubId param if found', function () {
Expand Down

0 comments on commit d5cdc8d

Please sign in to comment.