Skip to content

Commit

Permalink
4235 prebid endpoint return empty array instead of 204 when no bids r…
Browse files Browse the repository at this point in the history
…eturned (#3136)

* corrected user sync type

* add alias pxyz
add version to endpoint
add validation for 204 bid response

* add validation with serverResponse is undefined
fix test for 204 (no bid response)

* remove package lock

* restore package-lock
  • Loading branch information
teranchristian authored and harpere committed Oct 2, 2018
1 parent 4e8955e commit e7ad006
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
20 changes: 16 additions & 4 deletions modules/playgroundxyzBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER } from 'src/mediaTypes';

const BIDDER_CODE = 'playgroundxyz';
const URL = 'https://ads.playground.xyz/host-config/prebid';
const URL = 'https://ads.playground.xyz/host-config/prebid?v=2';

export const spec = {
code: BIDDER_CODE,
aliases: ['playgroundxyz'],
aliases: ['playgroundxyz', 'pxyz'],
supportedMediaTypes: [BANNER],

/**
Expand Down Expand Up @@ -69,8 +69,10 @@ export const spec = {

if (!serverResponse || serverResponse.error) {
let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`;
if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; }
utils.logError(errorMessage);
if (serverResponse && serverResponse.error) {
errorMessage += `: ${serverResponse.error}`;
utils.logError(errorMessage);
}
return bids;
}

Expand All @@ -80,6 +82,10 @@ export const spec = {
return bids;
}

if (!serverResponse.seatbid) {
return bids;
}

serverResponse.seatbid.forEach(sBid => {
if (sBid.hasOwnProperty('bid')) {
sBid.bid.forEach(iBid => {
Expand Down Expand Up @@ -131,6 +137,12 @@ function mapImpression(bid) {
ext: {
appnexus: {
placement_id: parseInt(bid.params.placementId, 10)
},
pxyz: {
adapter: {
vendor: 'prebid',
prebid: '$prebid.version$'
}
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions test/spec/modules/playgroundxyzBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spec } from 'modules/playgroundxyzBidAdapter';
import { newBidder } from 'src/adapters/bidderFactory';
import { deepClone } from 'src/utils';

const URL = 'https://ads.playground.xyz/host-config/prebid';
const URL = 'https://ads.playground.xyz/host-config/prebid?v=2';
const GDPR_CONSENT = 'XYZ-CONSENT';

describe('playgroundxyzBidAdapter', function () {
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('playgroundxyzBidAdapter', function () {
const data = JSON.parse(request.data);
const banner = data.imp[0].banner;

expect(Object.keys(data.imp[0].ext)).to.have.members(['appnexus']);
expect(Object.keys(data.imp[0].ext)).to.have.members(['appnexus', 'pxyz']);
expect([banner.w, banner.h]).to.deep.equal([300, 250]);
expect(banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
expect(request.url).to.equal(URL);
Expand Down Expand Up @@ -128,8 +128,8 @@ describe('playgroundxyzBidAdapter', function () {
expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
});

it('handles nobid responses', function () {
let response = '';
it('handles nobid response', function () {
const response = undefined;
let result = spec.interpretResponse({ body: response }, {bidderRequest});
expect(result.length).to.equal(0);
});
Expand Down

0 comments on commit e7ad006

Please sign in to comment.