Skip to content

Commit

Permalink
Rise Bid Adapter : support currency (prebid#10790)
Browse files Browse the repository at this point in the history
* add Rise adapter

* fixes

* change param isOrg to org

* Rise adapter

* change email for rise

* fix circle failed

* bump

* bump

* bump

* remove space

* Upgrade Rise adapter to 5.0

* added isWrapper param

* addes is_wrapper parameter to documentation

* added is_wrapper to test

* removed isWrapper

* Rise Bid Adapter: support Coppa param (#24)

* MinuteMedia Bid Adapter: support Coppa param (#25)

* Revert "MinuteMedia Bid Adapter: support Coppa param (#25)" (#26)

This reverts commit 66c4e7b.

* bump

* update coppa fetch

* setting coppa param update

* update Coppa tests

* update test naming

* Rise Bid Adapter: support plcmt and sua (#27)

* update minuteMediaBidAdapter - support missing params (#29)

* RIseBidAdapter: support currency (#35)

---------

Co-authored-by: Noam Tzuberi <noam.tzuberi@ironsrc.com>
Co-authored-by: noamtzu <noamtzu@gmail.com>
Co-authored-by: Noam Tzuberi <noamtzu@users.noreply.github.com>
Co-authored-by: Laslo Chechur <laslo.chechur@ironsrc.com>
Co-authored-by: OronW <41260031+OronW@users.noreply.github.com>
Co-authored-by: lasloche <62240785+lasloche@users.noreply.github.com>
Co-authored-by: inna <innayare@gmail.com>
Co-authored-by: YakirLavi <yakir.lavi@risecodes.com>
  • Loading branch information
9 people authored Dec 5, 2023
1 parent 4f3826a commit 27b57ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
19 changes: 11 additions & 8 deletions modules/riseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -140,18 +140,20 @@ registerBidder(spec);
/**
* Get floor price
* @param bid {bid}
* @param mediaType {string}
* @param currency {string}
* @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;
}

/**
Expand Down Expand Up @@ -289,7 +291,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;
Expand All @@ -299,12 +301,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
coppa: 0,
};

const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`);
Expand Down
1 change: 1 addition & 0 deletions modules/riseBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion test/spec/modules/riseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('riseAdapter', function () {
'adUnitCode': 'adunit-code',
'sizes': [[640, 480]],
'params': {
'org': 'jdye8weeyirk00000001'
'org': 'jdye8weeyirk00000001',
},
'bidId': '299ffc8cca0b87',
'loop': 1,
Expand Down Expand Up @@ -195,6 +195,16 @@ describe('riseAdapter', function () {
expect(request.data.bids[1].mediaType).to.equal(BANNER)
});

it('should send the correct currency in bid request', function () {
const bid = utils.deepClone(bidRequests[0]);
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 respect syncEnabled option', function() {
config.setConfig({
userSync: {
Expand Down

0 comments on commit 27b57ab

Please sign in to comment.