Skip to content

Commit 878896f

Browse files
nickjacobDecayConstant
authored andcommitted
AMX Bid Adapter: add support for overriding bidderCode (allowAlternateBidderCodes) (prebid#11712)
* add support for overriding bidderCode (allowAlternateBidderCodes) in AMX Bid adapter * fix formatting and actually run tests
1 parent 5c310f3 commit 878896f

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

modules/amxBidAdapter.js

+7
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ export const spec = {
454454
setUIDSafe(response.am);
455455
}
456456

457+
const bidderSettings = config.getConfig('bidderSettings');
458+
const settings = bidderSettings?.amx ?? bidderSettings?.standard ?? {};
459+
const allowAlternateBidderCodes = !!settings.allowAlternateBidderCodes;
460+
457461
return flatMap(Object.keys(response.r), (bidID) => {
458462
return flatMap(response.r[bidID], (siteBid) =>
459463
siteBid.b.map((bid) => {
@@ -466,8 +470,10 @@ export const spec = {
466470

467471
const size = resolveSize(bid, request.data, bidID);
468472
const defaultExpiration = mediaType === BANNER ? 240 : 300;
473+
const { bc: bidderCode, ds: demandSource } = bid.ext ?? {};
469474

470475
return {
476+
...(bidderCode != null && allowAlternateBidderCodes ? { bidderCode } : {}),
471477
requestId: bidID,
472478
cpm: bid.price,
473479
width: size[0],
@@ -479,6 +485,7 @@ export const spec = {
479485
meta: {
480486
advertiserDomains: bid.adomain,
481487
mediaType,
488+
...(demandSource != null ? { demandSource } : {}),
482489
},
483490
mediaType,
484491
ttl: typeof bid.exp === 'number' ? bid.exp : defaultExpiration,

test/spec/modules/amxBidAdapter_spec.js

+49
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,55 @@ describe('AmxBidAdapter', () => {
583583
expect(parsed).to.eql([]);
584584
});
585585

586+
it('will read an bidderCode override from bid.ext.prebid.meta', () => {
587+
const currentConfig = config.getConfig();
588+
config.setConfig({
589+
...currentConfig,
590+
bidderSettings: {
591+
amx: {
592+
allowAlternateBidderCodes: true
593+
}
594+
}
595+
});
596+
597+
const parsed = spec.interpretResponse(
598+
{ body: {
599+
...sampleServerResponse,
600+
r: {
601+
[sampleRequestId]: [{
602+
...sampleServerResponse.r[sampleRequestId][0],
603+
b: [{
604+
...sampleServerResponse.r[sampleRequestId][0].b[0],
605+
ext: {
606+
bc: 'amx-pmp',
607+
ds: 'example',
608+
}
609+
}]
610+
}]
611+
}}},
612+
baseRequest
613+
);
614+
615+
config.setConfig(currentConfig);
616+
expect(parsed.length).to.equal(1); // we removed one
617+
618+
// we should have display, video, display
619+
expect(parsed[0]).to.deep.equal({
620+
...baseBidResponse,
621+
meta: {
622+
...baseBidResponse.meta,
623+
mediaType: BANNER,
624+
demandSource: 'example'
625+
},
626+
mediaType: BANNER,
627+
bidderCode: 'amx-pmp',
628+
width: 300,
629+
height: 600, // from the bid itself
630+
ttl: 90,
631+
ad: sampleDisplayAd,
632+
});
633+
});
634+
586635
it('can parse a display ad', () => {
587636
const parsed = spec.interpretResponse(
588637
{ body: sampleServerResponse },

0 commit comments

Comments
 (0)