Skip to content

Commit

Permalink
Axonix Bid Adapter: Fixed interpretResponse, support email (prebid#6667)
Browse files Browse the repository at this point in the history
* Fixed interpretResponse, support email

* onBidWon gets single bids

* replaceAuctionPrice call fix

* Version bump
  • Loading branch information
cesarfd authored Apr 29, 2021
1 parent 9896409 commit e206244
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 62 deletions.
25 changes: 12 additions & 13 deletions modules/axonixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as utils from '../src/utils.js';
import { ajax } from '../src/ajax.js';

const BIDDER_CODE = 'axonix';
const BIDDER_VERSION = '1.0.1';
const BIDDER_VERSION = '1.0.2';

const CURRENCY = 'USD';
const DEFAULT_REGION = 'us-east-1';
Expand Down Expand Up @@ -140,15 +140,17 @@ export const spec = {
},

interpretResponse: function(serverResponse) {
if (!utils.isArray(serverResponse)) {
const response = serverResponse ? serverResponse.body : [];

if (!utils.isArray(response)) {
return [];
}

const responses = [];

for (const response of serverResponse) {
if (response.requestId) {
responses.push(Object.assign(response, {
for (const resp of response) {
if (resp.requestId) {
responses.push(Object.assign(resp, {
ttl: config.getConfig('_bidderTimeout')
}));
}
Expand All @@ -171,15 +173,12 @@ export const spec = {
}
},

onBidWon: function(bids) {
for (const bid of bids) {
const { nurl } = bid || {};
onBidWon: function(bid) {
const { nurl } = bid || {};

if (bid.nurl) {
utils.replaceAuctionPrice(nurl, bid.cpm)
utils.triggerPixel(nurl);
};
}
if (bid.nurl) {
utils.triggerPixel(utils.replaceAuctionPrice(nurl, bid.cpm));
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/axonixBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```
Module Name : Axonix Bidder Adapter
Module Type : Bidder Adapter
Maintainer : support-prebid@axonix.com
Maintainer : support+prebid@axonix.com
```

# Description
Expand Down
100 changes: 52 additions & 48 deletions test/spec/modules/axonixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,47 +71,51 @@ describe('AxonixBidAdapter', function () {
};

const BANNER_RESPONSE = {
requestId: 'f08b3a8dcff747eabada295dcf94eee0',
cpm: 6,
currency: 'USD',
width: 300,
height: 250,
ad: '<html></html>',
creativeId: 'abc',
netRevenue: false,
meta: {
networkId: 'nid',
advertiserDomains: [
'https://the.url'
],
secondaryCatIds: [
'IAB1'
],
mediaType: 'banner'
},
nurl: 'https://win.url'
body: [{
requestId: 'f08b3a8dcff747eabada295dcf94eee0',
cpm: 6,
currency: 'USD',
width: 300,
height: 250,
ad: '<html></html>',
creativeId: 'abc',
netRevenue: false,
meta: {
networkId: 'nid',
advertiserDomains: [
'https://the.url'
],
secondaryCatIds: [
'IAB1'
],
mediaType: 'banner'
},
nurl: 'https://win.url'
}]
};

const VIDEO_RESPONSE = {
requestId: 'f08b3a8dcff747eabada295dcf94eee0',
cpm: 6,
currency: 'USD',
width: 300,
height: 250,
ad: '<?xml version="1.0" encoding="UTF-8" ?><VAST version="3.0"></VAST>',
creativeId: 'abc',
netRevenue: false,
meta: {
networkId: 'nid',
advertiserDomains: [
'https://the.url'
],
secondaryCatIds: [
'IAB1'
],
mediaType: 'video'
},
nurl: 'https://win.url'
body: [{
requestId: 'f08b3a8dcff747eabada295dcf94eee0',
cpm: 6,
currency: 'USD',
width: 300,
height: 250,
ad: '<?xml version="1.0" encoding="UTF-8" ?><VAST version="3.0"></VAST>',
creativeId: 'abc',
netRevenue: false,
meta: {
networkId: 'nid',
advertiserDomains: [
'https://the.url'
],
secondaryCatIds: [
'IAB1'
],
mediaType: 'video'
},
nurl: 'https://win.url'
}]
};

describe('inherited functions', function () {
Expand Down Expand Up @@ -311,21 +315,21 @@ describe('AxonixBidAdapter', function () {
it('ignores unparseable responses', function() {
expect(spec.interpretResponse('invalid')).to.be.an('array').that.is.empty;
expect(spec.interpretResponse(['invalid'])).to.be.an('array').that.is.empty;
expect(spec.interpretResponse([{ invalid: 'object' }])).to.be.an('array').that.is.empty;
expect(spec.interpretResponse({ body: [{ invalid: 'object' }] })).to.be.an('array').that.is.empty;
});

it('parses banner responses', function () {
const response = spec.interpretResponse([BANNER_RESPONSE]);
const response = spec.interpretResponse(BANNER_RESPONSE);

expect(response).to.be.an('array').that.is.not.empty;
expect(response[0]).to.equal(BANNER_RESPONSE);
expect(response[0]).to.equal(BANNER_RESPONSE.body[0]);
});

it('parses 1 video responses', function () {
const response = spec.interpretResponse([VIDEO_RESPONSE]);
const response = spec.interpretResponse(VIDEO_RESPONSE);

expect(response).to.be.an('array').that.is.not.empty;
expect(response[0]).to.equal(VIDEO_RESPONSE);
expect(response[0]).to.equal(VIDEO_RESPONSE.body[0]);
});

it.skip('parses 1 native responses', function () {
Expand All @@ -346,29 +350,29 @@ describe('AxonixBidAdapter', function () {
});

it('called once', function () {
spec.onBidWon(spec.interpretResponse([BANNER_RESPONSE]));
spec.onBidWon(BANNER_RESPONSE.body[0]);
expect(utils.triggerPixel.calledOnce).to.equal(true);
});

it('called false', function () {
spec.onBidWon([{ cpm: '2.21' }]);
spec.onBidWon({ cpm: '2.21' });
expect(utils.triggerPixel.called).to.equal(false);
});

it('when there is no notification expected server side, none is called', function () {
var response = spec.onBidWon([]);
var response = spec.onBidWon({});
expect(utils.triggerPixel.called).to.equal(false);
expect(response).to.be.an('undefined')
});
});

describe('onTimeout', function () {
it('banner response', () => {
spec.onTimeout(spec.interpretResponse([BANNER_RESPONSE]));
spec.onTimeout(spec.interpretResponse(BANNER_RESPONSE));
});

it('video response', () => {
spec.onTimeout(spec.interpretResponse([VIDEO_RESPONSE]));
spec.onTimeout(spec.interpretResponse(VIDEO_RESPONSE));
});
});
});

0 comments on commit e206244

Please sign in to comment.