Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Komorski authored and Marcin Komorski committed Aug 14, 2024
1 parent 6c905bc commit 1ccb05e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
16 changes: 2 additions & 14 deletions libraries/ortb2Utils/currency.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
const additionalData = new WeakMap();

export function getCurrencyFromBidderRequest(bidderRequest) {
return (bidderRequest?.ortb2?.ext?.cur || [])[0];
}

export function setAdditionalData(obj, key, value) {
const prevValue = additionalData.get(obj) || {};
additionalData.set(obj, { ...prevValue, [key]: value });
}

export function getAdditionalData(obj, key) {
const data = additionalData.get(obj) || {};
return data[key];
}
return bidderRequest?.ortb2?.ext?.prebid?.adServerCurrency;
}
2 changes: 1 addition & 1 deletion modules/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ registerOrtbProcessor({type: REQUEST, name: 'currency', fn: setOrtbCurrency, pri

function enrichFPDHook(next, fpd) {
return next(fpd.then(ortb2 => {
deepSetValue(ortb2, 'ext.cur', [adServerCurrency]);
deepSetValue(ortb2, 'ext.prebid.adServerCurrency', adServerCurrency);
return ortb2;
}))
}
14 changes: 13 additions & 1 deletion modules/koblerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ import {
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER} from '../src/mediaTypes.js';
import {getRefererInfo} from '../src/refererDetection.js';
import { getAdditionalData, getCurrencyFromBidderRequest, setAdditionalData } from '../libraries/ortb2Utils/currency.js';
import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.js';

const additionalData = new WeakMap();

export function setAdditionalData(obj, key, value) {
const prevValue = additionalData.get(obj) || {};
additionalData.set(obj, { ...prevValue, [key]: value });
}

export function getAdditionalData(obj, key) {
const data = additionalData.get(obj) || {};
return data[key];
}

const BIDDER_CODE = 'kobler';
const BIDDER_ENDPOINT = 'https://bid.essrtb.com/bid/prebid_rtb_call';
Expand Down
6 changes: 3 additions & 3 deletions test/spec/modules/adgenerationBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('AdgenerationAdapter', function () {
const bidRequests = {
banner: {
bidderRequest: {
ortb2: { ext: { cur: ['JPY'] } }
ortb2: {ext: {prebid: {adServerCurrency: 'JPY'}}}
},
bidRequest: {
bidder: 'adg',
Expand All @@ -279,7 +279,7 @@ describe('AdgenerationAdapter', function () {
},
native: {
bidderRequest: {
ortb2: { ext: { cur: ['JPY'] } }
ortb2: {ext: {prebid: {adServerCurrency: 'JPY'}}}
},
bidRequest: {
bidder: 'adg',
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('AdgenerationAdapter', function () {
},
upperBillboard: {
bidderRequest: {
ortb2: { ext: { cur: ['JPY'] } }
ortb2: {ext: {prebid: {adServerCurrency: 'JPY'}}}
},
bidRequest: {
bidder: 'adg',
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/currency_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ describe('currency', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ adServerCurrency: 'EUR' });
return fpd({}).then((ortb) => {
expect(ortb.ext.cur).to.eql(['EUR'])
expect(ortb.ext.prebid.adServerCurrency).to.eql('EUR')
})
})
})
Expand Down

0 comments on commit 1ccb05e

Please sign in to comment.