diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js index 44c9b7a509a..2e5342e6f9e 100644 --- a/modules/oguryBidAdapter.js +++ b/modules/oguryBidAdapter.js @@ -3,6 +3,7 @@ import { BANNER } from '../src/mediaTypes.js'; import { getAdUnitSizes, logWarn, isFn } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { ajax } from '../src/ajax.js' const BIDDER_CODE = 'ogury'; const DEFAULT_TIMEOUT = 1000; @@ -112,7 +113,8 @@ function interpretResponse(openRtbBidResponse) { ext: bid.ext, meta: { advertiserDomains: bid.adomain - } + }, + nurl: bid.nurl }; bidResponse.ad = bid.adm; @@ -135,6 +137,10 @@ function getFloor(bid) { return floorResult.currency === 'USD' ? floorResult.floor : 0; } +function onBidWon(bid) { + if (bid && bid.hasOwnProperty('nurl') && bid.nurl.length > 0) ajax(bid['nurl'], null); +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], @@ -142,7 +148,8 @@ export const spec = { getUserSyncs, buildRequests, interpretResponse, - getFloor + getFloor, + onBidWon } registerBidder(spec); diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index 57de2162789..0a57690db27 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -338,7 +338,8 @@ describe('OguryBidAdapter', function () { netRevenue: true, meta: { advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain - } + }, + nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl }, { requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid, cpm: openRtbBidResponse.body.seatbid[0].bid[1].price, @@ -352,7 +353,8 @@ describe('OguryBidAdapter', function () { netRevenue: true, meta: { advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain - } + }, + nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl }] let request = spec.buildRequests(bidRequests, bidderRequest); @@ -370,4 +372,39 @@ describe('OguryBidAdapter', function () { expect(result.length).to.equal(0) }) }); + + describe('onBidWon', function() { + const nurl = 'https://fakewinurl.test'; + let xhr; + let requests; + + beforeEach(function() { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = (xhr) => { + requests.push(xhr); + }; + }) + + afterEach(function() { + xhr.restore(); + }) + + it('Should not create nurl request if bid is undefined', function() { + spec.onBidWon(); + expect(requests.length).to.equal(0); + }) + + it('Should not create nurl request if bid does not contains nurl', function() { + spec.onBidWon({}) + expect(requests.length).to.equal(0); + }) + + it('Should create nurl request if bid nurl', function() { + spec.onBidWon({ nurl }) + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal(nurl); + expect(requests[0].method).to.equal('GET') + }) + }) });