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

glimpseBidAdapter: Add support for advertiserDomains #6980

Merged
merged 1 commit into from
Jun 9, 2021
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
15 changes: 13 additions & 2 deletions modules/glimpseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { BANNER } from '../src/mediaTypes.js';

const BIDDER_CODE = 'glimpse';

function transformEachBidResponse(glimpseBid) {
const bid = glimpseBid;
bid.meta = { advertiserDomains: [] };

if (glimpseBid.adomain) {
bid.meta.advertiserDomains = glimpseBid.adomain;
}

return bid;
}

export const spec = {
code: BIDDER_CODE,
url: 'https://api.glimpseprotocol.io/cloud/v1/vault/prebid',
Expand Down Expand Up @@ -45,10 +56,10 @@ export const spec = {
},

interpretResponse: (serverResponse, _) => {
const bids = [];
let bids = [];
try {
const { body } = serverResponse;
bids.push(...body);
bids = body.map(transformEachBidResponse);
} catch (error) {}

return bids;
Expand Down
34 changes: 31 additions & 3 deletions test/spec/modules/glimpseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ const templateBidResponse = {
};

const copyBidResponse = () => ({ ...templateBidResponse });
const copyBidderRequest = () => ({ ...templateBidderRequest, bids: copyBidRequests() });
const copyBidderRequest = () => ({
...templateBidderRequest,
bids: copyBidRequests(),
});
const copyBidRequest = () => ({ ...templateBidRequest });

const copyBidRequests = () => [copyBidRequest()];
Expand Down Expand Up @@ -139,15 +142,19 @@ describe('GlimpseProtocolAdapter', function () {
expect(payload.gdprConsent).to.exist;
const { gdprConsent } = payload;
expect(gdprConsent.gdprApplies).to.be.true;
expect(gdprConsent.consentString).to.equal(bidderRequest.gdprConsent.consentString);
expect(gdprConsent.consentString).to.equal(
bidderRequest.gdprConsent.consentString
);
});

it('should add referer info', function () {
const bidderRequest = copyBidderRequest();
const request = spec.buildRequests(bidRequests, bidderRequest);
const payload = JSON.parse(request.data);

expect(payload.refererInfo.referer).to.equal(templateBidderRequest.refererInfo.referer);
expect(payload.refererInfo.referer).to.equal(
templateBidderRequest.refererInfo.referer
);
});
});

Expand Down Expand Up @@ -175,5 +182,26 @@ describe('GlimpseProtocolAdapter', function () {
const bids = spec.interpretResponse(response);
expect(bids).to.have.length(0);
});

it('should include advertiserDomains field in the response', function () {
const response = copyBidResponses();

const bids = spec.interpretResponse(response);
expect(bids[0].meta.advertiserDomains).to.be.an('array').that.is.empty;
});

it('should reflect the value of the OpenRTB adomain field', function () {
const advertiserDomainsMock = ['http://example.com'];
let response = copyBidResponses();
response.body = response.body.map((bid) => {
return {
...bid,
adomain: advertiserDomainsMock,
};
});

const bids = spec.interpretResponse(response);
expect(bids[0].meta.advertiserDomains).to.equal(advertiserDomainsMock);
});
});
});