diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js index af1f0562ba4..86da82753b6 100644 --- a/modules/nextMillenniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -3,8 +3,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; const BIDDER_CODE = 'nextMillennium'; -const HOST = 'https://brainlyads.com'; -const CURRENCY = 'USD'; +const ENDPOINT = 'https://pbs.nextmillmedia.com/openrtb2/auction'; const TIME_TO_LIVE = 360; export const spec = { @@ -13,7 +12,7 @@ export const spec = { isBidRequestValid: function(bid) { return !!( - bid.params.placement_id && utils.isNumber(bid.params.placement_id) + bid.params.placement_id && utils.isStr(bid.params.placement_id) ); }, @@ -23,13 +22,19 @@ export const spec = { utils._each(validBidRequests, function(bid) { requests.push({ method: 'POST', - url: HOST + '/hb/s2s', + url: ENDPOINT, options: { contentType: 'application/json', withCredentials: true }, data: JSON.stringify({ - placement_id: utils.getBidIdParameter('placement_id', bid.params) + 'ext': { + 'prebid': { + 'storedrequest': { + 'id': utils.getBidIdParameter('placement_id', bid.params) + } + } + } }), bidId: bid.bidId }); @@ -39,47 +44,32 @@ export const spec = { }, interpretResponse: function(serverResponse, bidRequest) { - try { - const bidResponse = serverResponse.body; - const bidResponses = []; + const response = serverResponse.body; + const bidResponses = []; - if (Number(bidResponse.cpm) > 0) { - bidResponses.push({ - requestId: bidRequest.bidId, - cpm: bidResponse.cpm, - width: bidResponse.width, - height: bidResponse.height, - creativeId: bidResponse.creativeId, - currency: CURRENCY, - netRevenue: false, - ttl: TIME_TO_LIVE, - ad: bidResponse.ad + try { + utils._each(response.seatbid, (resp) => { + utils._each(resp.bid, (bid) => { + bidResponses.push({ + requestId: bidRequest.bidId, + cpm: bid.price, + width: bid.w, + height: bid.h, + creativeId: bid.adid, + currency: response.cur, + netRevenue: false, + ttl: TIME_TO_LIVE, + meta: { + advertiserDomains: bid.adomain || [] + }, + ad: bid.adm + }); }); - } - - return bidResponses; + }) } catch (err) { utils.logError(err); - return []; - } - }, - - getUserSyncs: function(syncOptions) { - const syncs = [] - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: HOST + '/hb/s2s/matching' - }); - } - - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: HOST + '/hb/s2s/matching' - }); } - return syncs; + return bidResponses; } }; registerBidder(spec); diff --git a/modules/nextMillenniumBidAdapter.md b/modules/nextMillenniumBidAdapter.md index c583969b4af..048fe907ac7 100644 --- a/modules/nextMillenniumBidAdapter.md +++ b/modules/nextMillenniumBidAdapter.md @@ -2,7 +2,7 @@ ``` Module Name: NextMillennium Bid Adapter Module Type: Bidder Adapter -Maintainer: mikhail.ivanchenko@iageengineering.net +Maintainer: mihail.ivanchenko@nextmillennium.io ``` # Description @@ -21,7 +21,7 @@ Currently module supports only banner mediaType. bids: [{ bidder: 'nextMillennium', params: { - placement_id: -1 + placement_id: '-1' } }] }]; diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index f4d929b439c..42032eb03ea 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import * as utils from '../../../src/utils.js'; import { spec } from 'modules/nextMillenniumBidAdapter.js'; describe('nextMillenniumBidAdapterTests', function() { @@ -8,20 +9,19 @@ describe('nextMillenniumBidAdapterTests', function() { bidId: 'transaction_1234', bidder: 'nextMillennium', params: { - placement_id: 12345 + placement_id: '12345' }, sizes: [[300, 250]] } ] }; - let request = []; it('validate_pub_params', function() { expect( spec.isBidRequestValid({ bidder: 'nextMillennium', params: { - placement_id: 12345 + placement_id: '12345' } }) ).to.equal(true); @@ -32,7 +32,7 @@ describe('nextMillenniumBidAdapterTests', function() { { bidId: 'bid1234', bidder: 'nextMillennium', - params: { placement_id: -1 }, + params: { placement_id: '-1' }, sizes: [[300, 250]] } ]; @@ -40,34 +40,36 @@ describe('nextMillenniumBidAdapterTests', function() { expect(request[0].bidId).to.equal('bid1234'); }); - it('validate_getUserSyncs_function', function() { - expect(spec.getUserSyncs({ iframeEnabled: true })).to.have.lengthOf(1); - expect(spec.getUserSyncs({ iframeEnabled: false })).to.have.lengthOf(0); - - let pixel = spec.getUserSyncs({ iframeEnabled: true }); - expect(pixel[0].type).to.equal('iframe'); - expect(pixel[0].url).to.equal('https://brainlyads.com/hb/s2s/matching'); - }); - it('validate_response_params', function() { let serverResponse = { body: { - cpm: 1.7, - width: 300, - height: 250, - creativeId: 'p35t0enob6twbt9mofjc8e', - ad: 'Hello! It\'s a test ad!' + id: 'f7b3d2da-e762-410c-b069-424f92c4c4b2', + seatbid: [ + { + bid: [ + { + id: '7457329903666272789', + price: 0.5, + adm: 'Hello! It\'s a test ad!', + adid: '96846035', + adomain: ['test.addomain.com'], + w: 300, + h: 250 + } + ] + } + ], + cur: 'USD' } }; let bids = spec.interpretResponse(serverResponse, bidRequestData.bids[0]); expect(bids).to.have.lengthOf(1); - let bid = bids[0]; - expect(bid.creativeId).to.equal('p35t0enob6twbt9mofjc8e'); + expect(bid.creativeId).to.equal('96846035'); expect(bid.ad).to.equal('Hello! It\'s a test ad!'); - expect(bid.cpm).to.equal(1.7); + expect(bid.cpm).to.equal(0.5); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); expect(bid.currency).to.equal('USD');