From ddd444bd964e7b7f5a22c61261282c8e88d40be5 Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Tue, 14 Nov 2023 17:17:33 +0200 Subject: [PATCH 1/8] adding currency param to bid object --- modules/riseBidAdapter.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js index 78740f7f87d..1f5b6666042 100644 --- a/modules/riseBidAdapter.js +++ b/modules/riseBidAdapter.js @@ -19,7 +19,7 @@ const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'rise'; const ADAPTER_VERSION = '6.0.0'; const TTL = 360; -const CURRENCY = 'USD'; +const DEFAULT_CURRENCY = 'USD'; const DEFAULT_SELLER_ENDPOINT = 'https://hb.yellowblue.io/'; const MODES = { PRODUCTION: 'hb-multi', @@ -73,7 +73,7 @@ export const spec = { const bidResponse = { requestId: adUnit.requestId, cpm: adUnit.cpm, - currency: adUnit.currency || CURRENCY, + currency: adUnit.currency || DEFAULT_CURRENCY, width: adUnit.width, height: adUnit.height, ttl: adUnit.ttl || TTL, @@ -142,16 +142,16 @@ registerBidder(spec); * @param bid {bid} * @returns {Number} */ -function getFloor(bid, mediaType) { +function getFloor(bid, mediaType, currency) { if (!isFn(bid.getFloor)) { return 0; } let floorResult = bid.getFloor({ - currency: CURRENCY, + currency: currency, mediaType: mediaType, size: '*' }); - return floorResult.currency === CURRENCY && floorResult.floor ? floorResult.floor : 0; + return floorResult.currency === currency && floorResult.floor ? floorResult.floor : 0; } /** @@ -304,7 +304,8 @@ function generateBidParameters(bid, bidderRequest) { bidderRequestId: getBidIdParameter('bidderRequestId', bid), loop: getBidIdParameter('bidderRequestsCount', bid), transactionId: bid.ortb2Imp?.ext?.tid, - coppa: 0 + coppa: 0, + currency: params.currency || config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY }; const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`); From 9fd4fa232f57bffeb619c5acfa58f0e11ec8c64a Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Wed, 15 Nov 2023 12:21:48 +0200 Subject: [PATCH 2/8] update getFloor function --- modules/riseBidAdapter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js index 1f5b6666042..af60073eea0 100644 --- a/modules/riseBidAdapter.js +++ b/modules/riseBidAdapter.js @@ -142,16 +142,16 @@ registerBidder(spec); * @param bid {bid} * @returns {Number} */ -function getFloor(bid, mediaType, currency) { +function getFloor(bid, mediaType) { if (!isFn(bid.getFloor)) { return 0; } let floorResult = bid.getFloor({ - currency: currency, + currency: bid.params.currency || DEFAULT_CURRENCY, mediaType: mediaType, size: '*' }); - return floorResult.currency === currency && floorResult.floor ? floorResult.floor : 0; + return floorResult.currency === (bid.params.currency || DEFAULT_CURRENCY) && floorResult.floor ? floorResult.floor : 0; } /** From a51ff1f06de0ad2e8536b51fb9cd3bd8123b876a Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Wed, 15 Nov 2023 14:19:48 +0200 Subject: [PATCH 3/8] adding test for currency param --- test/spec/modules/riseBidAdapter_spec.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/riseBidAdapter_spec.js b/test/spec/modules/riseBidAdapter_spec.js index eed8d74f271..30cf9e3a5bc 100644 --- a/test/spec/modules/riseBidAdapter_spec.js +++ b/test/spec/modules/riseBidAdapter_spec.js @@ -53,7 +53,7 @@ describe('riseAdapter', function () { 'adUnitCode': 'adunit-code', 'sizes': [[640, 480]], 'params': { - 'org': 'jdye8weeyirk00000001' + 'org': 'jdye8weeyirk00000001', }, 'bidId': '299ffc8cca0b87', 'loop': 1, @@ -195,6 +195,12 @@ describe('riseAdapter', function () { expect(request.data.bids[1].mediaType).to.equal(BANNER) }); + it('should send the correct currency in bid request', function () { + const expectedCurrency = 'USD'; + const request = spec.buildRequests(bidRequests, bidderRequest) + expect(request.data.bids[0].currency).to.equal(expectedCurrency); + }); + it('should respect syncEnabled option', function() { config.setConfig({ userSync: { From 85277bbce4818a0543c92832818736323dd82c0b Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Wed, 22 Nov 2023 18:09:43 +0200 Subject: [PATCH 4/8] update md file --- modules/riseBidAdapter.md | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/riseBidAdapter.md b/modules/riseBidAdapter.md index f0837cb5508..ac0ea559c88 100644 --- a/modules/riseBidAdapter.md +++ b/modules/riseBidAdapter.md @@ -26,6 +26,7 @@ The adapter supports Video(instream). | `testMode` | optional | Boolean | This activates the test mode | false | `rtbDomain` | optional | String | Sets the seller end point | "www.test.com" | `is_wrapper` | private | Boolean | Please don't use unless your account manager asked you to | false +| `currency` | optional | String | 3 letters currency | "EUR" # Test Parameters From 33f631913db09c1ed4b552faa76bd671e9adbdaf Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Wed, 22 Nov 2023 18:23:35 +0200 Subject: [PATCH 5/8] update currency implementatiom and tests --- modules/riseBidAdapter.js | 12 ++++++------ test/spec/modules/riseBidAdapter_spec.js | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js index af60073eea0..3267e58f45c 100644 --- a/modules/riseBidAdapter.js +++ b/modules/riseBidAdapter.js @@ -142,16 +142,16 @@ registerBidder(spec); * @param bid {bid} * @returns {Number} */ -function getFloor(bid, mediaType) { +function getFloor(bid, mediaType, currency) { if (!isFn(bid.getFloor)) { return 0; } let floorResult = bid.getFloor({ - currency: bid.params.currency || DEFAULT_CURRENCY, + currency: currency, mediaType: mediaType, size: '*' }); - return floorResult.currency === (bid.params.currency || DEFAULT_CURRENCY) && floorResult.floor ? floorResult.floor : 0; + return floorResult.currency === currency && floorResult.floor ? floorResult.floor : 0; } /** @@ -289,7 +289,7 @@ function generateBidParameters(bid, bidderRequest) { const {params} = bid; const mediaType = isBanner(bid) ? BANNER : VIDEO; const sizesArray = getSizesArray(bid, mediaType); - + const currency = params.currency || config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY; // fix floor price in case of NAN if (isNaN(params.floorPrice)) { params.floorPrice = 0; @@ -299,13 +299,13 @@ function generateBidParameters(bid, bidderRequest) { mediaType, adUnitCode: getBidIdParameter('adUnitCode', bid), sizes: sizesArray, - floorPrice: Math.max(getFloor(bid, mediaType), params.floorPrice), + currency: currency, + floorPrice: Math.max(getFloor(bid, mediaType, currency), params.floorPrice), bidId: getBidIdParameter('bidId', bid), bidderRequestId: getBidIdParameter('bidderRequestId', bid), loop: getBidIdParameter('bidderRequestsCount', bid), transactionId: bid.ortb2Imp?.ext?.tid, coppa: 0, - currency: params.currency || config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY }; const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`); diff --git a/test/spec/modules/riseBidAdapter_spec.js b/test/spec/modules/riseBidAdapter_spec.js index 30cf9e3a5bc..0097baecc57 100644 --- a/test/spec/modules/riseBidAdapter_spec.js +++ b/test/spec/modules/riseBidAdapter_spec.js @@ -196,9 +196,18 @@ describe('riseAdapter', function () { }); it('should send the correct currency in bid request', function () { - const expectedCurrency = 'USD'; - const request = spec.buildRequests(bidRequests, bidderRequest) - expect(request.data.bids[0].currency).to.equal(expectedCurrency); + const bid = utils.deepClone(bidRequests[0]); + bid.params = { + 'currency': 'EUR' + }; + const defaultCurrency = 'USD'; + const expectedCurrency = bid.params.currency || defaultCurrency; + const request = spec.buildRequests([bid], bidderRequest); + if (bid.params.currency) { + expect(request.data.bids[0].currency).to.equal(expectedCurrency); + } else { + expect(request.data.bids[0].currency).to.equal(defaultCurrency); + } }); it('should respect syncEnabled option', function() { From 4c91cf296deba023fcc648b259ed281160114a78 Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Thu, 23 Nov 2023 08:51:57 +0200 Subject: [PATCH 6/8] update function params --- modules/riseBidAdapter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js index 3267e58f45c..44cc91aa87b 100644 --- a/modules/riseBidAdapter.js +++ b/modules/riseBidAdapter.js @@ -140,6 +140,8 @@ registerBidder(spec); /** * Get floor price * @param bid {bid} + * @param mediaType {string} + * @param currency {string} * @returns {Number} */ function getFloor(bid, mediaType, currency) { From dc8aad3bb088af905538fcad5553baea00a95a31 Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Thu, 23 Nov 2023 14:27:45 +0200 Subject: [PATCH 7/8] update currency tests --- test/spec/modules/riseBidAdapter_spec.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/spec/modules/riseBidAdapter_spec.js b/test/spec/modules/riseBidAdapter_spec.js index 0097baecc57..a6b0ed40397 100644 --- a/test/spec/modules/riseBidAdapter_spec.js +++ b/test/spec/modules/riseBidAdapter_spec.js @@ -200,14 +200,19 @@ describe('riseAdapter', function () { bid.params = { 'currency': 'EUR' }; + const expectedCurrency = bid.params.currency; + const request = spec.buildRequests([bid], bidderRequest); + expect(request.data.bids[0].currency).to.equal(expectedCurrency); + }); + + it('should send the correct currency in bid request, using default if not specified', function () { + const bid = utils.deepClone(bidRequests[0]); + bid.params = { + 'currency': undefined + }; const defaultCurrency = 'USD'; - const expectedCurrency = bid.params.currency || defaultCurrency; const request = spec.buildRequests([bid], bidderRequest); - if (bid.params.currency) { - expect(request.data.bids[0].currency).to.equal(expectedCurrency); - } else { - expect(request.data.bids[0].currency).to.equal(defaultCurrency); - } + expect(request.data.bids[0].currency).to.equal(defaultCurrency); }); it('should respect syncEnabled option', function() { From f4adb3224f23d6f153c39b6021b06cd444e65789 Mon Sep 17 00:00:00 2001 From: YakirLavi Date: Thu, 30 Nov 2023 15:17:49 +0200 Subject: [PATCH 8/8] removed default test --- test/spec/modules/riseBidAdapter_spec.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/spec/modules/riseBidAdapter_spec.js b/test/spec/modules/riseBidAdapter_spec.js index a6b0ed40397..4be56c79913 100644 --- a/test/spec/modules/riseBidAdapter_spec.js +++ b/test/spec/modules/riseBidAdapter_spec.js @@ -205,16 +205,6 @@ describe('riseAdapter', function () { expect(request.data.bids[0].currency).to.equal(expectedCurrency); }); - it('should send the correct currency in bid request, using default if not specified', function () { - const bid = utils.deepClone(bidRequests[0]); - bid.params = { - 'currency': undefined - }; - const defaultCurrency = 'USD'; - const request = spec.buildRequests([bid], bidderRequest); - expect(request.data.bids[0].currency).to.equal(defaultCurrency); - }); - it('should respect syncEnabled option', function() { config.setConfig({ userSync: {