Skip to content

Commit

Permalink
ogury Bid Adapter: handle onBidWon event on prebid.js (#7298)
Browse files Browse the repository at this point in the history
* oguryBidAdapter: handle onBidWon event on prebid.js

* oguryBidAdapter: remove blank space at end of file

* oguryBidAdapter: fix new line at end of file

* trigger rebuild on CI

* trigger rebuild on CI
  • Loading branch information
jogury authored Aug 17, 2021
1 parent 6aa63d6 commit 51eb7d0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
11 changes: 9 additions & 2 deletions modules/oguryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -112,7 +113,8 @@ function interpretResponse(openRtbBidResponse) {
ext: bid.ext,
meta: {
advertiserDomains: bid.adomain
}
},
nurl: bid.nurl
};

bidResponse.ad = bid.adm;
Expand All @@ -135,14 +137,19 @@ 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],
isBidRequestValid,
getUserSyncs,
buildRequests,
interpretResponse,
getFloor
getFloor,
onBidWon
}

registerBidder(spec);
41 changes: 39 additions & 2 deletions test/spec/modules/oguryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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')
})
})
});

0 comments on commit 51eb7d0

Please sign in to comment.