Skip to content

Commit

Permalink
Doceree Bid Adaptor: bidwon and timeout hooks added (#10543)
Browse files Browse the repository at this point in the history
* doceree adapter

* add fix for impression register

* update doceree adaptor with hooks

* lint changes and testcases
  • Loading branch information
sourbh-doceree authored Oct 6, 2023
1 parent 2c878c7 commit 25bd335
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/docereeBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { triggerPixel } from '../src/utils.js';
import { config } from '../src/config.js';
import { BANNER } from '../src/mediaTypes.js';
import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js';
const BIDDER_CODE = 'doceree';
const END_POINT = 'https://bidder.doceree.com'
const TRACKING_END_POINT = 'https://tracking.doceree.com'

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -69,6 +71,33 @@ export const spec = {
}
};
return [bidResponse];
},
onTimeout: function(timeoutData) {
if (timeoutData == null || !timeoutData.length) {
return;
}
timeoutData.forEach(td => {
const encodedBuf = window.btoa(encodeURIComponent(JSON.stringify({
bidId: td.bidId,
timeout: td.timeout,
})));
triggerPixel(TRACKING_END_POINT + '/v1/hbTimeout?adp=prebidjs&data=' + encodedBuf);
})
},
onBidWon: function (bidWon) {
if (bidWon == null) {
return;
}
const encodedBuf = window.btoa(encodeURIComponent(JSON.stringify({
requestId: bidWon.requestId,
cpm: bidWon.cpm,
adId: bidWon.adId,
currency: bidWon.currency,
netRevenue: bidWon.netRevenue,
status: bidWon.status,
hb_pb: bidWon.adserverTargeting && bidWon.adserverTargeting.hb_pb,
})));
triggerPixel(TRACKING_END_POINT + '/v1/hbBidWon?adp=prebidjs&data=' + encodedBuf);
}
};

Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/docereeBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {expect} from 'chai';
import {spec} from '../../../modules/docereeBidAdapter.js';
import { config } from '../../../src/config.js';
import * as utils from 'src/utils.js';

describe('BidlabBidAdapter', function () {
config.setConfig({
Expand Down Expand Up @@ -102,4 +103,36 @@ describe('BidlabBidAdapter', function () {
expect(dataItem.meta.advertiserDomains[0]).to.equal('doceree.com')
});
})
describe('onBidWon', function () {
beforeEach(function() {
sinon.stub(utils, 'triggerPixel');
});
afterEach(function() {
utils.triggerPixel.restore();
});
it('exists and is a function', () => {
expect(spec.onBidWon).to.exist.and.to.be.a('function');
});
it('should return nothing', function () {
var response = spec.onBidWon({});
expect(response).to.be.an('undefined')
expect(utils.triggerPixel.called).to.equal(true);
});
});
describe('onTimeout', function () {
beforeEach(function() {
sinon.stub(utils, 'triggerPixel');
});
afterEach(function() {
utils.triggerPixel.restore();
});
it('exists and is a function', () => {
expect(spec.onTimeout).to.exist.and.to.be.a('function');
});
it('should return nothing', function () {
var response = spec.onBidWon([]);
expect(response).to.be.an('undefined')
expect(utils.triggerPixel.called).to.equal(true);
});
});
});

0 comments on commit 25bd335

Please sign in to comment.