From 534012dd796f68e04829e8f77c32eac3cc67bed0 Mon Sep 17 00:00:00 2001 From: varashellov Date: Tue, 14 Nov 2017 07:07:23 -0800 Subject: [PATCH] Platform.io Bidder Adapter update (#1817) * Add PlatformioBidAdapter * Update platformioBidAdapter.js * Add files via upload * Update hello_world.html * Update platformioBidAdapter.js * Update platformioBidAdapter_spec.js * Update hello_world.html * Update platformioBidAdapter_spec.js * Update platformioBidAdapter.js * Update hello_world.html * Add files via upload * Update platformioBidAdapter ## Type of change - [x] Other ## Description of change 1. RequestURL changes 2. Add placementCode to request params * Update platformioBidAdapter * Update platformioBidAdapter ## Type of change - [x] Other ## Description of change 1. RequestURL changes 2. Add placementCode to request params * Add files via upload * Add files via upload * Add files via upload * Update platformioBidAdapter.js Endpoint URL change * Update platformioBidAdapter_spec.js Endpoint URL change * Update platformioBidAdapter_spec.js * Update platformioBidAdapter_spec.js * Update platformioBidAdapter.js * Update platformioBidAdapter.js * Update platformioBidAdapter_spec.js * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update platformioBidAdapter.js * Update platformioBidAdapter_spec.js --- modules/platformioBidAdapter.js | 16 ++++++++-------- modules/platformioBidAdapter.md | 7 ++++--- test/spec/modules/platformioBidAdapter_spec.js | 17 +++++++++++------ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/platformioBidAdapter.js b/modules/platformioBidAdapter.js index 2fb23ab92b3..fa841dc6026 100644 --- a/modules/platformioBidAdapter.js +++ b/modules/platformioBidAdapter.js @@ -42,13 +42,13 @@ function bidResponseAvailable(bidRequest, bidResponse) { const bids = []; Object.keys(idToImpMap).forEach(id => { if (idToBidMap[id]) { - const bid = { - requestId: id, - cpm: idToBidMap[id].price, - creative_id: id, - creativeId: id, - adId: id, - }; + const bid = {}; + bid.requestId = id; + bid.creativeId = idToBidMap[id].adid; + bid.cpm = idToBidMap[id].price; + bid.currency = bidResponse.cur; + bid.ttl = 360; + bid.netRevenue = true; bid.ad = idToBidMap[id].adm; bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_IMP_ID(%7D|\})/gi, idToBidMap[id].impid); bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_AD_ID(%7D|\})/gi, idToBidMap[id].adid); @@ -66,7 +66,7 @@ function impression(slot) { return { id: slot.bidId, banner: banner(slot), - bidfloor: '0.000001', + bidfloor: slot.params.bidFloor || '0.000001', tagid: slot.params.placementId.toString(), }; } diff --git a/modules/platformioBidAdapter.md b/modules/platformioBidAdapter.md index 74f6adbf256..0d019d1fe96 100644 --- a/modules/platformioBidAdapter.md +++ b/modules/platformioBidAdapter.md @@ -17,10 +17,11 @@ Please use ```platformio``` as the bidder code. bids: [{ bidder: 'platformio', params: { - pubId: '28082', - siteId: '26047', + pubId: '28082', // required + siteId: '26047', // required + size: '250X250', // required placementId: '123', - size: '250X250' + bidFloor: '0.001' } }] }]; diff --git a/test/spec/modules/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js index 86bf52cac72..d775229c9e3 100644 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ b/test/spec/modules/platformioBidAdapter_spec.js @@ -11,7 +11,8 @@ describe('Platformio Adapter Tests', () => { pubId: '28082', siteId: '26047', placementId: '123', - size: '300x250' + size: '300x250', + bidFloor: '0.001' } }, { placementCode: '/DfpAccount2/slot2', @@ -44,11 +45,13 @@ describe('Platformio Adapter Tests', () => { expect(ortbRequest.imp[0].banner).to.not.equal(null); expect(ortbRequest.imp[0].banner.w).to.equal(300); expect(ortbRequest.imp[0].banner.h).to.equal(250); + expect(ortbRequest.imp[0].bidfloor).to.equal('0.001'); // slot 2 expect(ortbRequest.imp[1].tagid).to.equal('456'); expect(ortbRequest.imp[1].banner).to.not.equal(null); expect(ortbRequest.imp[1].banner.w).to.equal(250); expect(ortbRequest.imp[1].banner.h).to.equal(250); + expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); }); it('Verify parse response', () => { @@ -59,9 +62,11 @@ describe('Platformio Adapter Tests', () => { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'This is an Ad' + adm: 'This is an Ad', + adid: '471810', }] - }] + }], + cur: 'USD' }; const bids = spec.interpretResponse({ body: ortbResponse }, request); expect(bids).to.have.lengthOf(1); @@ -71,9 +76,9 @@ describe('Platformio Adapter Tests', () => { expect(bid.ad).to.equal('This is an Ad'); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); - expect(bid.creative_id).to.equal('bid12345'); - expect(bid.creativeId).to.equal('bid12345'); + expect(bid.creativeId).to.equal('471810'); + expect(bid.currency).to.equal('USD'); + expect(bid.ttl).to.equal(360); }); it('Verify full passback', () => {