Skip to content

Commit fe330c5

Browse files
hieund-genieeMurano Takamasagn-daikichitakm-furukawafurukawaTakumi
authored
SSP Genie Bid Adapter: Change logic of specified currency bid-params do not refer to adServerCurrency. (prebid#14061)
* modify adUnit infomation * fix imuid module * feat(GenieeBidAdapter): Add support for GPID and pbadslot - Add support for GPID (Global Placement ID) from ortb2Imp.ext.gpid - Add fallback support for ortb2Imp.ext.data.pbadslot - Include gpid parameter in request when GPID exists - Add test cases to verify GPID, pbadslot, and priority behavior * Aladdin Bidder ID5 Compatible Adapter * add comment * modified test message * the import of buildExtuidQuery was missing * test: add test cases for id5id in extuid query * delete duplicate test * feat(GenieeBidAdapter): Add support for iframe-based cookie sync in BidAdapter * [CARPET-5190] Bid Adapter: Fix the default value of the ib parameter - change default value ib parameter * remove ib param * fix test/spec/modules/ssp_genieeBidAdapter_spec.js * Corrected cookie sync URL and added title to data * reset document.title after test * Modify document.title in sandbox.stub * CARPET-6134 Change logic of specified currency bidparams * format code * update assert in unit test * update code * update code * update reset config * Update assert to expect * Update logic --------- Co-authored-by: Murano Takamasa <takamasa-murano@j0098.geniee.jp> Co-authored-by: daikichiteranishi <49385718+daikichiteranishi@users.noreply.github.com> Co-authored-by: teranishi daikichi <daikichi.teranishi@geniee.co.jp> Co-authored-by: gn-daikichi <49385718+gn-daikichi@users.noreply.github.com> Co-authored-by: takumi-furukawa <takumi.furukawa@geniee.co.jp> Co-authored-by: furukawaTakumi <45890154+furukawaTakumi@users.noreply.github.com> Co-authored-by: furukawaTakumi <black3moon88@gmail.com> Co-authored-by: haruki-yamaguchi <haruki.yamaguchi@geniee.co.jp> Co-authored-by: haruki yamaguchi <100411113+hrkhito@users.noreply.github.com> Co-authored-by: Thanh Tran <thanhtv@geniee.co.jp> Co-authored-by: thanhtran-geniee <135969265+thanhtran-geniee@users.noreply.github.com>
1 parent 79e6dbf commit fe330c5

2 files changed

Lines changed: 57 additions & 32 deletions

File tree

modules/ssp_genieeBidAdapter.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,22 @@ export const spec = {
342342
*/
343343
isBidRequestValid: function (bidRequest) {
344344
if (!bidRequest.params.zoneId) return false;
345-
const currencyType = config.getConfig('currency.adServerCurrency');
346-
if (typeof currencyType === 'string' && ALLOWED_CURRENCIES.indexOf(currencyType) === -1) {
347-
utils.logError('Invalid currency type, we support only JPY and USD!');
348-
return false;
345+
346+
if (bidRequest.params.hasOwnProperty('currency')) {
347+
const bidCurrency = bidRequest.params.currency;
348+
349+
if (!ALLOWED_CURRENCIES.includes(bidCurrency)) {
350+
utils.logError(`[${BIDDER_CODE}] Currency "${bidCurrency}" in bid params is not supported. Supported are: ${ALLOWED_CURRENCIES.join(', ')}.`);
351+
return false;
352+
}
353+
} else {
354+
const adServerCurrency = config.getConfig('currency.adServerCurrency');
355+
if (typeof adServerCurrency === 'string' && !ALLOWED_CURRENCIES.includes(adServerCurrency)) {
356+
utils.logError(`[${BIDDER_CODE}] adServerCurrency "${adServerCurrency}" is not supported. Supported are: ${ALLOWED_CURRENCIES.join(', ')}.`);
357+
return false;
358+
}
349359
}
360+
350361
return true;
351362
},
352363
/**

test/spec/modules/ssp_genieeBidAdapter_spec.js

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,42 +82,56 @@ describe('ssp_genieeBidAdapter', function () {
8282

8383
afterEach(function () {
8484
sandbox.restore();
85+
config.resetConfig();
8586
});
8687

8788
describe('isBidRequestValid', function () {
88-
it('should return true when params.zoneId exists and params.currency does not exist', function () {
89-
expect(spec.isBidRequestValid(BANNER_BID)).to.be.true;
89+
it('should return false when params.zoneId does not exist', function () {
90+
expect(spec.isBidRequestValid({ ...BANNER_BID, params: {} })).to.be.false;
9091
});
9192

92-
it('should return true when params.zoneId and params.currency exist and params.currency is JPY or USD', function () {
93-
config.setConfig({ currency: { adServerCurrency: 'JPY' } });
94-
expect(
95-
spec.isBidRequestValid({
96-
...BANNER_BID,
97-
params: { ...BANNER_BID.params },
98-
})
99-
).to.be.true;
100-
config.setConfig({ currency: { adServerCurrency: 'USD' } });
101-
expect(
102-
spec.isBidRequestValid({
103-
...BANNER_BID,
104-
params: { ...BANNER_BID.params },
105-
})
106-
).to.be.true;
107-
});
93+
describe('when params.currency is specified', function() {
94+
it('should return true if currency is USD', function() {
95+
const bid = { ...BANNER_BID, params: { ...BANNER_BID.params, currency: 'USD' } };
96+
expect(spec.isBidRequestValid(bid)).to.be.true;
97+
});
10898

109-
it('should return false when params.zoneId does not exist', function () {
110-
expect(spec.isBidRequestValid({ ...BANNER_BID, params: {} })).to.be.false;
99+
it('should return true if currency is JPY', function() {
100+
const bid = { ...BANNER_BID, params: { ...BANNER_BID.params, currency: 'JPY' } };
101+
expect(spec.isBidRequestValid(bid)).to.be.true;
102+
});
103+
104+
it('should return false if currency is not supported (e.g., EUR)', function() {
105+
const bid = { ...BANNER_BID, params: { ...BANNER_BID.params, currency: 'EUR' } };
106+
expect(spec.isBidRequestValid(bid)).to.be.false;
107+
});
108+
109+
it('should return true if currency is valid, ignoring adServerCurrency', function() {
110+
config.setConfig({ currency: { adServerCurrency: 'EUR' } });
111+
const bid = { ...BANNER_BID, params: { ...BANNER_BID.params, currency: 'USD' } };
112+
expect(spec.isBidRequestValid(bid)).to.be.true;
113+
});
111114
});
112115

113-
it('should return false when params.zoneId and params.currency exist and params.currency is neither JPY nor USD', function () {
114-
config.setConfig({ currency: { adServerCurrency: 'EUR' } });
115-
expect(
116-
spec.isBidRequestValid({
117-
...BANNER_BID,
118-
params: { ...BANNER_BID.params },
119-
})
120-
).to.be.false;
116+
describe('when params.currency is NOT specified (fallback to adServerCurrency)', function() {
117+
it('should return true if adServerCurrency is not set', function() {
118+
expect(spec.isBidRequestValid(BANNER_BID)).to.be.true;
119+
});
120+
121+
it('should return true if adServerCurrency is JPY', function() {
122+
config.setConfig({ currency: { adServerCurrency: 'JPY' } });
123+
expect(spec.isBidRequestValid(BANNER_BID)).to.be.true;
124+
});
125+
126+
it('should return true if adServerCurrency is USD', function() {
127+
config.setConfig({ currency: { adServerCurrency: 'USD' } });
128+
expect(spec.isBidRequestValid(BANNER_BID)).to.be.true;
129+
});
130+
131+
it('should return false if adServerCurrency is not supported (e.g., EUR)', function() {
132+
config.setConfig({ currency: { adServerCurrency: 'EUR' } });
133+
expect(spec.isBidRequestValid(BANNER_BID)).to.be.false;
134+
});
121135
});
122136
});
123137

0 commit comments

Comments
 (0)