Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native support to ablida Bid Adapter #5545

Merged
merged 5 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions modules/ablidaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as utils from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {ajax} from '../src/ajax.js';
import { BANNER, NATIVE } from '../src/mediaTypes.js';

const BIDDER_CODE = 'ablida';
const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, NATIVE],

/**
* Determines whether or not the given bid request is valid.
Expand All @@ -31,20 +32,22 @@ export const spec = {
return [];
}
return validBidRequests.map(bidRequest => {
const sizes = utils.parseSizesInput(bidRequest.sizes)[0];
const size = sizes.split('x');
let sizes = []
if (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER] && bidRequest.mediaTypes[BANNER].sizes) {
sizes = bidRequest.mediaTypes[BANNER].sizes;
}
const jaySupported = 'atob' in window && 'currentScript' in document;
const device = getDevice();
const payload = {
placementId: bidRequest.params.placementId,
width: size[0],
height: size[1],
sizes: sizes,
bidId: bidRequest.bidId,
categories: bidRequest.params.categories,
referer: bidderRequest.refererInfo.referer,
jaySupported: jaySupported,
device: device,
adapterVersion: 2
adapterVersion: 3,
mediaTypes: bidRequest.mediaTypes
};
return {
method: 'POST',
Expand Down Expand Up @@ -72,9 +75,8 @@ export const spec = {
return bidResponses;
},
onBidWon: function (bid) {
if (!bid['nurl']) { return false; }
ajax(bid['nurl'], null);
return true;
if (!bid['nurl']) { return; }
utils.triggerPixel(bid['nurl']);
}
};

Expand Down
26 changes: 25 additions & 1 deletion modules/ablidaBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ Module that connects to Ablida's bidder for bids.
}
}
]
}, {
code: 'native-ad-div',
mediaTypes: {
native: {
image: {
sendId: true,
required: true
},
title: {
required: true
},
body: {
required: true
}
}
},
bids: [
{
bidder: 'ablida',
params: {
placementId: 'native-demo'
}
}
]
}
];
];
```
16 changes: 12 additions & 4 deletions test/spec/modules/ablidaBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {assert, expect} from 'chai';
import {spec} from 'modules/ablidaBidAdapter.js';
import {newBidder} from 'src/adapters/bidderFactory.js';
import * as utils from 'src/utils.js';

const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';

Expand Down Expand Up @@ -104,16 +105,23 @@ describe('ablidaBidAdapter', function () {
});

describe('onBidWon', function() {
it('Should not ajax call if bid does not contain nurl', function() {
beforeEach(function() {
sinon.stub(utils, 'triggerPixel');
});
afterEach(function() {
utils.triggerPixel.restore();
});

it('Should not trigger pixel if bid does not contain nurl', function() {
const result = spec.onBidWon({});
expect(result).to.equal(false)
expect(utils.triggerPixel.callCount).to.equal(0)
})

it('Should ajax call if bid nurl', function() {
it('Should trigger pixel if bid nurl', function() {
const result = spec.onBidWon({
nurl: 'https://example.com/some-tracker'
});
expect(result).to.equal(true)
expect(utils.triggerPixel.callCount).to.equal(1)
})
})
});