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

KRAK-4688: Adds support for PAAPI module #34

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 16 additions & 1 deletion modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function buildRequests(validBidRequests, bidderRequest) {

function interpretResponse(response, bidRequest) {
const bids = response.body;
const fledgeAuctionConfigs = [];
const bidResponses = [];

if (isEmpty(bids) || typeof bids !== 'object') {
Expand Down Expand Up @@ -237,9 +238,23 @@ function interpretResponse(response, bidRequest) {
}

bidResponses.push(bidResponse);

if (adUnit.auctionConfig) {
fledgeAuctionConfigs.push({
bidID,
config: adUnit.auctionConfig
})
}
}

return bidResponses;
if (fledgeAuctionConfigs.length > 0) {
return {
bidResponses,
fledgeAuctionConfigs
}
} else {
return bidResponses;
}
}

function getUserSyncs(syncOptions, _, gdprConsent, usPrivacy, gppConsent) {
Expand Down
49 changes: 49 additions & 0 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,55 @@ describe('kargo adapter tests', function() {
advertiserDomains: [ 'https://foo.com', 'https://bar.com' ]
});
});

it('should return fledgeAuctionConfigs if provided in bid response', function () {
const auctionConfig = {
seller: 'https://kargo.com',
decisionLogicUrl: 'https://kargo.com/decision_logic.js',
interestGroupBuyers: ['https://some_buyer.com'],
perBuyerSignals: {
'https://some_buyer.com': { a: 1 }
}
}

const body = response.body;
for (const key in body) {
if (body.hasOwnProperty(key)) {
if (key % 2 !== 0) { // Add auctionConfig to every other object
body[key].auctionConfig = auctionConfig;
}
}
}

let bids = spec.interpretResponse(response, bidderRequest);

// Test properties of bidResponses
bids.bidResponses.forEach(bid => {
expect(bid).to.have.property('requestId');
expect(bid).to.have.property('cpm');
expect(bid).to.have.property('width');
expect(bid).to.have.property('height');
expect(bid).to.have.property('ttl');
expect(bid).to.have.property('creativeId');
expect(bid.netRevenue).to.be.true;
expect(bid).to.have.property('meta').that.is.an('object');
});

// Test properties of fledgeAuctionConfigs
expect(bids.fledgeAuctionConfigs).to.have.lengthOf(3);

const expectedBidIds = ['1', '3', '5']; // Expected bidIDs
bids.fledgeAuctionConfigs.forEach(config => {
expect(config).to.have.property('bidID');
expect(expectedBidIds).to.include(config.bidID);

expect(config).to.have.property('config').that.is.an('object');
expect(config.config).to.have.property('seller', 'https://kargo.com');
expect(config.config).to.have.property('decisionLogicUrl', 'https://kargo.com/decision_logic.js');
expect(config.config.interestGroupBuyers).to.be.an('array').that.includes('https://some_buyer.com');
expect(config.config.perBuyerSignals).to.have.property('https://some_buyer.com').that.deep.equals({ a: 1 });
});
});
});

describe('getUserSyncs', function() {
Expand Down