From 86ce84e58327ec3dcec9a56f41ee1ff0cc20f5dc Mon Sep 17 00:00:00 2001 From: Andrew Lays Date: Fri, 11 Jun 2021 13:49:41 +0300 Subject: [PATCH 1/6] Add meta.adomain support --- modules/invamiaBidAdapter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/invamiaBidAdapter.js b/modules/invamiaBidAdapter.js index 0cc63d34550..2d36fb77e16 100644 --- a/modules/invamiaBidAdapter.js +++ b/modules/invamiaBidAdapter.js @@ -74,6 +74,10 @@ export const spec = { netRevenue: response.hb.netRevenue, ttl: 600, ad: response.template.html, + mediaType: 'banner', + meta: { + advertiserDomains: response.hb.adomains || [], + }, width, height, }; From 2c3973c4eae0e86fa1b087789908bda2f81565de Mon Sep 17 00:00:00 2001 From: Andrew Lays Date: Fri, 11 Jun 2021 13:50:40 +0300 Subject: [PATCH 2/6] Update test --- test/spec/modules/invamiaBidAdapter_spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/spec/modules/invamiaBidAdapter_spec.js b/test/spec/modules/invamiaBidAdapter_spec.js index ed004b651bd..2f8f0612e44 100644 --- a/test/spec/modules/invamiaBidAdapter_spec.js +++ b/test/spec/modules/invamiaBidAdapter_spec.js @@ -104,6 +104,7 @@ describe('invamia bid adapter tests', function () { hb: { cpm: 0.5, netRevenue: false, + adomains: ['securepubads.g.doubleclick.net'], }, template: { html: '', @@ -128,6 +129,8 @@ describe('invamia bid adapter tests', function () { expect(bids[0].cpm).to.equal(0.5); expect(bids[0].netRevenue).to.equal(false); expect(bids[0].currency).to.equal('USD'); + expect(bids[0].meta.advertiserDomains).to.be.lengthOf(1); + expect(bids[0].meta.advertiserDomains[0]).to.equal('securepubads.g.doubleclick.net'); }); it('should return empty bid response', function () { From 46dc4a9c4608e99059b7221afa2d8dec121409eb Mon Sep 17 00:00:00 2001 From: Andrew Lays Date: Thu, 24 Mar 2022 03:17:52 +0700 Subject: [PATCH 3/6] Add Biddo Adapter --- modules/biddoBidAdapter.js | 92 ++++++++++++ modules/biddoBidAdapter.md | 30 ++++ test/spec/modules/biddoBidAdapter_spec.js | 172 ++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 modules/biddoBidAdapter.js create mode 100644 modules/biddoBidAdapter.md create mode 100644 test/spec/modules/biddoBidAdapter_spec.js diff --git a/modules/biddoBidAdapter.js b/modules/biddoBidAdapter.js new file mode 100644 index 00000000000..2176ed67af7 --- /dev/null +++ b/modules/biddoBidAdapter.js @@ -0,0 +1,92 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'biddo'; +const ENDPOINT_URL = 'https://ad.biddo.net/delivery/impress'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bidRequest The bid request params to validate. + * @return boolean True if this is a valid bid request, and false otherwise. + */ + isBidRequestValid: function(bidRequest) { + return !!bidRequest.params.zoneId; + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {Array} validBidRequests an array of bid requests + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests) { + let serverRequests = []; + + validBidRequests.forEach(bidRequest => { + const sizes = bidRequest.mediaTypes.banner.sizes; + + sizes.forEach(([width, height]) => { + bidRequest.params.requestedSizes = [width, height]; + + const payload = { + ctype: 'div', + pzoneid: bidRequest.params.zoneId, + width, + height, + }; + + const payloadString = Object.keys(payload).map(k => k + '=' + encodeURIComponent(payload[k])).join('&'); + + serverRequests.push({ + method: 'GET', + url: ENDPOINT_URL, + data: payloadString, + bidderRequest: bidRequest, + }); + }); + }); + + return serverRequests; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @param {BidRequest} bidderRequest A matched bid request for this response. + * @return Array An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, {bidderRequest}) { + const response = serverResponse.body; + const bidResponses = []; + + if (response && response.template && response.template.html) { + const {bidId} = bidderRequest; + const [width, height] = bidderRequest.params.requestedSizes; + + const bidResponse = { + requestId: bidId, + cpm: response.hb.cpm, + creativeId: response.banner.hash, + currency: 'USD', + netRevenue: response.hb.netRevenue, + ttl: 600, + ad: response.template.html, + mediaType: 'banner', + meta: { + advertiserDomains: response.hb.adomains || [], + }, + width, + height, + }; + + bidResponses.push(bidResponse); + } + + return bidResponses; + }, +} + +registerBidder(spec); diff --git a/modules/biddoBidAdapter.md b/modules/biddoBidAdapter.md new file mode 100644 index 00000000000..91cb228cd2f --- /dev/null +++ b/modules/biddoBidAdapter.md @@ -0,0 +1,30 @@ +# Overview + +``` +Module Name: Biddo Bidder Adapter +Module Type: Bidder Adapter +Maintainer: contact@biddo.net +``` + +# Description + +Module that connects to Invamia demand sources. + +# Test Parameters + +``` + const adUnits = [{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [{ + bidder: 'biddo', + params: { + zoneId: 379783, + }, + }], + }]; +``` diff --git a/test/spec/modules/biddoBidAdapter_spec.js b/test/spec/modules/biddoBidAdapter_spec.js new file mode 100644 index 00000000000..6f32aaa3ae8 --- /dev/null +++ b/test/spec/modules/biddoBidAdapter_spec.js @@ -0,0 +1,172 @@ +import {expect} from 'chai'; +import {spec} from 'modules/invamiaBidAdapter.js'; + +describe('biddo bid adapter tests', function () { + describe('bid requests', function () { + it('should accept valid bid', function () { + const validBid = { + bidder: 'biddo', + params: {zoneId: 123}, + }; + + expect(spec.isBidRequestValid(validBid)).to.equal(true); + }); + + it('should reject invalid bid', function () { + const invalidBid = { + bidder: 'biddo', + params: {}, + }; + + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + + it('should correctly build payload string', function () { + const bidRequests = [{ + bidder: 'biddo', + params: {zoneId: 123}, + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + }]; + const payload = spec.buildRequests(bidRequests)[0].data; + + expect(payload).to.contain('ctype=div'); + expect(payload).to.contain('pzoneid=123'); + expect(payload).to.contain('width=300'); + expect(payload).to.contain('height=250'); + }); + + it('should support multiple bids', function () { + const bidRequests = [{ + bidder: 'biddo', + params: {zoneId: 123}, + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + }, { + bidder: 'biddo', + params: {zoneId: 321}, + mediaTypes: { + banner: { + sizes: [[728, 90]], + }, + }, + bidId: '23acc48ad47af52', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba992', + bidderRequestId: '1c56ad30b9b8ca82', + transactionId: '92489f71-1bf2-49a0-adf9-000cea9347292', + }]; + const payload = spec.buildRequests(bidRequests); + + expect(payload).to.be.lengthOf(2); + }); + + it('should support multiple sizes', function () { + const bidRequests = [{ + bidder: 'biddo', + params: {zoneId: 123}, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + }]; + const payload = spec.buildRequests(bidRequests); + + expect(payload).to.be.lengthOf(2); + }); + }); + + describe('bid responses', function () { + it('should return complete bid response', function () { + const serverResponse = { + body: { + banner: { + hash: '1c56ad30b9b8ca8', + }, + hb: { + cpm: 0.5, + netRevenue: false, + adomains: ['securepubads.g.doubleclick.net'], + }, + template: { + html: '', + }, + }, + }; + const bidderRequest = { + bidId: '23acc48ad47af5', + params: { + requestedSizes: [300, 250], + }, + }; + + const bids = spec.interpretResponse(serverResponse, {bidderRequest}); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].requestId).to.equal('23acc48ad47af5'); + expect(bids[0].creativeId).to.equal('1c56ad30b9b8ca8'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(250); + expect(bids[0].ttl).to.equal(600); + expect(bids[0].cpm).to.equal(0.5); + expect(bids[0].netRevenue).to.equal(false); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].meta.advertiserDomains).to.be.lengthOf(1); + expect(bids[0].meta.advertiserDomains[0]).to.equal('securepubads.g.doubleclick.net'); + }); + + it('should return empty bid response', function () { + const serverResponse = { + body: {}, + }; + const bidderRequest = { + bidId: '23acc48ad47af5', + params: { + requestedSizes: [300, 250], + }, + }; + + const bids = spec.interpretResponse(serverResponse, {bidderRequest}); + + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response 2', function () { + const serverResponse = { + body: { + template: { + html: '', + } + }, + }; + const bidderRequest = { + bidId: '23acc48ad47af5', + params: { + requestedSizes: [300, 250], + }, + }; + + const bids = spec.interpretResponse(serverResponse, {bidderRequest}); + + expect(bids).to.be.lengthOf(0); + }); + }); +}); From 0fccb799951ef7c73305e130c82a9603a66ac5b3 Mon Sep 17 00:00:00 2001 From: Andrew Lays Date: Tue, 5 Apr 2022 00:49:13 +0700 Subject: [PATCH 4/6] Update endpoint --- modules/biddoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/biddoBidAdapter.js b/modules/biddoBidAdapter.js index 2176ed67af7..5512ca60f8e 100644 --- a/modules/biddoBidAdapter.js +++ b/modules/biddoBidAdapter.js @@ -2,7 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'biddo'; -const ENDPOINT_URL = 'https://ad.biddo.net/delivery/impress'; +const ENDPOINT_URL = 'https://ad.adopx.net/delivery/impress'; export const spec = { code: BIDDER_CODE, From bb269ab33e8201309ae5137e3c3d6385c8a91be1 Mon Sep 17 00:00:00 2001 From: Andrew Lays Date: Tue, 5 Apr 2022 19:00:18 +0700 Subject: [PATCH 5/6] Fix tested module --- test/spec/modules/biddoBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/biddoBidAdapter_spec.js b/test/spec/modules/biddoBidAdapter_spec.js index 6f32aaa3ae8..25986b3407f 100644 --- a/test/spec/modules/biddoBidAdapter_spec.js +++ b/test/spec/modules/biddoBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/invamiaBidAdapter.js'; +import {spec} from 'modules/biddoBidAdapter.js'; describe('biddo bid adapter tests', function () { describe('bid requests', function () { From 1ee786b67a5bbfa9c37521619500325ca37f52fe Mon Sep 17 00:00:00 2001 From: Andrew Lays Date: Tue, 5 Apr 2022 19:01:56 +0700 Subject: [PATCH 6/6] Update zone id for tests --- modules/biddoBidAdapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/biddoBidAdapter.md b/modules/biddoBidAdapter.md index 91cb228cd2f..baea44b22f2 100644 --- a/modules/biddoBidAdapter.md +++ b/modules/biddoBidAdapter.md @@ -23,7 +23,7 @@ Module that connects to Invamia demand sources. bids: [{ bidder: 'biddo', params: { - zoneId: 379783, + zoneId: 7254, }, }], }];