From 1139ef1067df0d72816f49142d16413f206a8910 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 1 Feb 2018 11:41:45 +0700 Subject: [PATCH 01/23] commit gamma adapter --- modules/gammaBidAdapter.js | 85 ++++++++++++++++++++++++++++++++++++++ modules/gammaBidAdapter.md | 69 +++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 modules/gammaBidAdapter.js create mode 100644 modules/gammaBidAdapter.md diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js new file mode 100644 index 00000000000..37faaa6127f --- /dev/null +++ b/modules/gammaBidAdapter.js @@ -0,0 +1,85 @@ +import * as utils from 'src/utils'; +import { registerBidder } from 'src/adapters/bidderFactory'; +import find from 'core-js/library/fn/array/find'; + +const BIDDER_CODE = 'gamma'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['gamma'], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.siteId || bid.params.zoneId || bid.params.gaxDomain); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(bidRequests) { + const gaxObjParams = find(bidRequests, hasParamInfo); + return { + method: 'GET', + url: '//' + gaxObjParams.params.gaxDomain + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + utils.getTopWindowUrl() + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + serverResponse = serverResponse.body; + + const bids = []; + + if (!serverResponse) { + return bids; + } + + const bid = newBid(serverResponse); + bids.push(bid); + + return bids; + } +} + +/** + * Unpack the Server's Bid into a Prebid-compatible one. + * @param serverBid + * @return Bid + */ +function newBid(serverBid) { + const bid = { + ad: serverBid.seatbid[0].bid[0].adm, + cpm: serverBid.seatbid[0].bid[0].price, + creativeId: serverBid.seatbid[0].bid[0].adid, + currency: serverBid.cur, + dealId: serverBid.seatbid[0].bid[0].dealid, + width: serverBid.seatbid[0].bid[0].w, + height: serverBid.seatbid[0].bid[0].h, + mediaType: serverBid.type, + netRevenue: true, + requestId: serverBid.id, + ttl: serverBid.seatbid[0].bid[0].ttl || 300, + vastXml: serverBid.seatbid[0].bid[0].vastXml + }; + + return bid; +} + +function hasParamInfo(bid) { + return !!bid.params; +} + +registerBidder(spec); diff --git a/modules/gammaBidAdapter.md b/modules/gammaBidAdapter.md new file mode 100644 index 00000000000..6d7058ce42a --- /dev/null +++ b/modules/gammaBidAdapter.md @@ -0,0 +1,69 @@ +# Overview + +``` +Module Name: Gamma Bid Adapter +Module Type: Bidder Adapter +Maintainer: support@gammassp.com +``` + +# Description + +Connects to Gamma exchange for bids. + +Gamma bid adapter supports Banner, Video. + +# Test Parameters +``` +var adUnits = [{ + code: 'gamma-hb-ad-123456-0', + sizes: [[300, 250]], + + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'gamma', + params: { + siteId: '1465446377', + zoneId: '1515999290', + gaxDomain: 'hb.gammaplatform.com' + } + }] + + }]; +``` +# Ad Unit and Setup: For Testing +In order to receive bids please map localhost to (any) test domain. + +``` +<--! Prebid Config section > + + ', + 'h': 90, + 'w': 728 + }] + }] + } + }; + + it('should get the correct bid response', () => { + let expectedResponse = [{ + 'requestId': '23beaa6af6cdde', + 'cpm': 0.45, + 'width': 300, + 'height': 250, + 'creativeId': '1515999070', + 'dealId': 'gax-paj2qarjf2g', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'ad': '' + }]; + let result = spec.interpretResponse(serverResponse); + expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); + }); + + it('handles empty bid response', () => { + let response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}); From ffbfddbf04fd81be0a551c8ba3db3611a142d36f Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 13:37:51 +0700 Subject: [PATCH 08/23] fixed Travis CI build --- test/spec/modules/gammaBidAdapter_spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index b0bd8a085cf..7358ed434c9 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -26,8 +26,8 @@ describe('gammaBidAdapter', function() { it('should return true when required params found', () => { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - - it('should return false when require params are not passed', () => { + + it('should return false when require params are not passed', () => { let bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); @@ -37,13 +37,13 @@ describe('gammaBidAdapter', function() { bid.params.siteId = ''; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - - it('should return false when zoneId not passed correctly', () => { + + it('should return false when zoneId not passed correctly', () => { bid.params.zoneId = ''; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - - it('should return false when gaxDomain not passed correctly', () => { + + it('should return false when gaxDomain not passed correctly', () => { bid.params.gaxDomain = ''; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -71,13 +71,13 @@ describe('gammaBidAdapter', function() { const request = spec.buildRequests(bidRequests); it('sends bid request to our endpoint via GET', () => { - const request = spec.buildRequests(bidRequests)[0]; + const request = spec.buildRequests(bidRequests)[0]; expect(request.method).to.equal('GET'); expect(request.url).to.match(new RegExp(`//${bidRequests[0].params.gaxDomain}/adx/request`)); }); it('attaches source to endpoint URL as query params', () => { - const request = spec.buildRequests(bidRequests)[0]; + const request = spec.buildRequests(bidRequests)[0]; expect(request.url).to.include('wid=' + bidRequests[0].params.siteId + '&zid=' + bidRequests[0].params.zoneId + '&hb=pbjs&bidid=' + bidRequests[0].bidId + '&urf=' + utils.getTopWindowUrl()); }); }); From 57d241c2a484bab8e9da3e10e6d741ecb4cbaf60 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 14:00:06 +0700 Subject: [PATCH 09/23] fix spec --- test/spec/modules/gammaBidAdapter_spec.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 7358ed434c9..b092664f086 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -7,7 +7,7 @@ describe('gammaBidAdapter', function() { const adapter = newBidder(spec); describe('isBidRequestValid', () => { - let bid = { + const bid = { 'bidder': 'gamma', 'params': { siteId: '1465446377', @@ -28,7 +28,7 @@ describe('gammaBidAdapter', function() { }); it('should return false when require params are not passed', () => { - let bid = Object.assign({}, bid); + const bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -50,7 +50,7 @@ describe('gammaBidAdapter', function() { }); describe('buildRequests', () => { - let bidRequests = [ + const bidRequests = [ { 'bidder': 'gamma', 'params': { @@ -68,8 +68,6 @@ describe('gammaBidAdapter', function() { } ]; - const request = spec.buildRequests(bidRequests); - it('sends bid request to our endpoint via GET', () => { const request = spec.buildRequests(bidRequests)[0]; expect(request.method).to.equal('GET'); From ce3f6ea0c01338f98eb1b375c3d4e20a0f255392 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 14:30:42 +0700 Subject: [PATCH 10/23] fix spec --- test/spec/modules/gammaBidAdapter_spec.js | 27 +++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index b092664f086..349b562f14b 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -7,7 +7,7 @@ describe('gammaBidAdapter', function() { const adapter = newBidder(spec); describe('isBidRequestValid', () => { - const bid = { + let bid = { 'bidder': 'gamma', 'params': { siteId: '1465446377', @@ -28,29 +28,21 @@ describe('gammaBidAdapter', function() { }); it('should return false when require params are not passed', () => { - const bid = Object.assign({}, bid); + let bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when siteId not passed correctly', () => { + it('should return false when params not passed correctly', () => { bid.params.siteId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when zoneId not passed correctly', () => { bid.params.zoneId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when gaxDomain not passed correctly', () => { bid.params.gaxDomain = ''; expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); describe('buildRequests', () => { - const bidRequests = [ + let bidRequests = [ { 'bidder': 'gamma', 'params': { @@ -68,15 +60,16 @@ describe('gammaBidAdapter', function() { } ]; + const request = spec.buildRequests(bidRequests); + it('sends bid request to our endpoint via GET', () => { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`//${bidRequests[0].params.gaxDomain}/adx/request`)); + expect(request[0].method).to.equal('GET'); + expect(request[0].url).to.match(new RegExp(`//${request[0].params.gaxDomain}/adx/request`)); }); it('attaches source to endpoint URL as query params', () => { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.include('wid=' + bidRequests[0].params.siteId + '&zid=' + bidRequests[0].params.zoneId + '&hb=pbjs&bidid=' + bidRequests[0].bidId + '&urf=' + utils.getTopWindowUrl()); + + expect(request[0].url).to.include('wid=' + request[0].params.siteId + '&zid=' + request[0].params.zoneId + '&hb=pbjs&bidid=' + request[0].bidId + '&urf=' + utils.getTopWindowUrl()); }); }); From f63f0ec3fff80ff5e838ad297045832ffa3da16c Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 14:40:35 +0700 Subject: [PATCH 11/23] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 349b562f14b..0049ca000e4 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -63,13 +63,12 @@ describe('gammaBidAdapter', function() { const request = spec.buildRequests(bidRequests); it('sends bid request to our endpoint via GET', () => { - expect(request[0].method).to.equal('GET'); - expect(request[0].url).to.match(new RegExp(`//${request[0].params.gaxDomain}/adx/request`)); + expect(request.method).to.equal('GET'); + expect(request.url).to.match(new RegExp(`//${request[0].params.gaxDomain}/adx/request`)); }); it('attaches source to endpoint URL as query params', () => { - - expect(request[0].url).to.include('wid=' + request[0].params.siteId + '&zid=' + request[0].params.zoneId + '&hb=pbjs&bidid=' + request[0].bidId + '&urf=' + utils.getTopWindowUrl()); + expect(request.url).to.include('wid=' + request.params.siteId + '&zid=' + request.params.zoneId + '&hb=pbjs&bidid=' + request.bidId + '&urf=' + utils.getTopWindowUrl()); }); }); From 489a8f1c12c41809d29232a9d69325e774b7170e Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 14:58:32 +0700 Subject: [PATCH 12/23] Add files via upload --- test/spec/gammaBidAdapter_spec.js | 113 ++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 test/spec/gammaBidAdapter_spec.js diff --git a/test/spec/gammaBidAdapter_spec.js b/test/spec/gammaBidAdapter_spec.js new file mode 100644 index 00000000000..d2586e58651 --- /dev/null +++ b/test/spec/gammaBidAdapter_spec.js @@ -0,0 +1,113 @@ +import * as utils from 'src/utils'; +import { expect } from 'chai'; +import { spec } from 'modules/gammaBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +describe('gammaBidAdapter', function() { + const adapter = newBidder(spec); + + describe('isBidRequestValid', () => { + let bid = { + 'bidder': 'gamma', + 'params': { + siteId: '1465446377', + zoneId: '1515999290', + gaxDomain: 'hb.gammaplatform.com' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + }; + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when require params are not passed', () => { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when params not passed correctly', () => { + bid.params.siteId = ''; + bid.params.zoneId = ''; + bid.params.gaxDomain = ''; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', () => { + let bidRequests = [ + { + 'bidder': 'gamma', + 'params': { + siteId: '1465446377', + zoneId: '1515999290', + gaxDomain: 'hb.gammaplatform.com' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + } + ]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via GET', () => { + expect(request.method).to.equal('GET'); + expect(request.url).to.match(new RegExp(`${bidRequests[0].params.gaxDomain}`)); + }); + }); + + describe('interpretResponse', () => { + let serverResponse = { + body: { + 'id': '23beaa6af6cdde', + 'seatbid': [{ + 'bid': [{ + 'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28', + 'impid': '263c448586f5a1', + 'price': 0.45, + 'adm': '', + 'h': 90, + 'w': 728 + }] + }] + } + }; + + it('should get the correct bid response', () => { + let expectedResponse = [{ + 'requestId': '23beaa6af6cdde', + 'cpm': 0.45, + 'width': 300, + 'height': 250, + 'creativeId': '1515999070', + 'dealId': 'gax-paj2qarjf2g', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'ad': '' + }]; + let result = spec.interpretResponse(serverResponse); + expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); + }); + + it('handles empty bid response', () => { + let response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}); From 718a4e7d96ac489714daf5c307bce927ee212ea7 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 15:08:11 +0700 Subject: [PATCH 13/23] fix spec --- test/spec/modules/gammaBidAdapter_spec.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 0049ca000e4..379fff6e2bb 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -64,11 +64,10 @@ describe('gammaBidAdapter', function() { it('sends bid request to our endpoint via GET', () => { expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`//${request[0].params.gaxDomain}/adx/request`)); }); - - it('attaches source to endpoint URL as query params', () => { - expect(request.url).to.include('wid=' + request.params.siteId + '&zid=' + request.params.zoneId + '&hb=pbjs&bidid=' + request.bidId + '&urf=' + utils.getTopWindowUrl()); + + it('bidRequest url', () => { + expect(request.url).to.match(new RegExp(`${bidRequests[0].params.gaxDomain}`)); }); }); @@ -82,8 +81,8 @@ describe('gammaBidAdapter', function() { 'impid': '263c448586f5a1', 'price': 0.45, 'adm': '', - 'h': 90, - 'w': 728 + 'h': 250, + 'w': 300 }] }] } From efba42f2c3caef7876a96e0a60b7bcf3eebcfa53 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 15:20:23 +0700 Subject: [PATCH 14/23] fix Travis CI build --- test/spec/modules/gammaBidAdapter_spec.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 379fff6e2bb..15e01801c4f 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -65,8 +65,8 @@ describe('gammaBidAdapter', function() { it('sends bid request to our endpoint via GET', () => { expect(request.method).to.equal('GET'); }); - - it('bidRequest url', () => { + + it('bidRequest url', () => { expect(request.url).to.match(new RegExp(`${bidRequests[0].params.gaxDomain}`)); }); }); @@ -75,12 +75,18 @@ describe('gammaBidAdapter', function() { let serverResponse = { body: { 'id': '23beaa6af6cdde', + 'bid': '5611802021800040585', + 'type': 'banner', + 'cur': 'USD', 'seatbid': [{ + 'seat': '5611802021800040585', 'bid': [{ - 'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28', - 'impid': '263c448586f5a1', + 'id': '1515999070', + 'impid': '1', 'price': 0.45, 'adm': '', + 'adid': '1515999070', + 'dealid': 'gax-paj2qarjf2g', 'h': 250, 'w': 300 }] From 94e1f10f0fad1ae41fe5380fa442e68ebc18403b Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Feb 2018 15:28:03 +0700 Subject: [PATCH 15/23] move to module --- test/spec/gammaBidAdapter_spec.js | 113 ------------------------------ 1 file changed, 113 deletions(-) delete mode 100644 test/spec/gammaBidAdapter_spec.js diff --git a/test/spec/gammaBidAdapter_spec.js b/test/spec/gammaBidAdapter_spec.js deleted file mode 100644 index d2586e58651..00000000000 --- a/test/spec/gammaBidAdapter_spec.js +++ /dev/null @@ -1,113 +0,0 @@ -import * as utils from 'src/utils'; -import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('gammaBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', () => { - let bid = { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', - zoneId: '1515999290', - gaxDomain: 'hb.gammaplatform.com' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - - it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when require params are not passed', () => { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when params not passed correctly', () => { - bid.params.siteId = ''; - bid.params.zoneId = ''; - bid.params.gaxDomain = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', () => { - let bidRequests = [ - { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', - zoneId: '1515999290', - gaxDomain: 'hb.gammaplatform.com' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - } - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via GET', () => { - expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`${bidRequests[0].params.gaxDomain}`)); - }); - }); - - describe('interpretResponse', () => { - let serverResponse = { - body: { - 'id': '23beaa6af6cdde', - 'seatbid': [{ - 'bid': [{ - 'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28', - 'impid': '263c448586f5a1', - 'price': 0.45, - 'adm': '', - 'h': 90, - 'w': 728 - }] - }] - } - }; - - it('should get the correct bid response', () => { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 0.45, - 'width': 300, - 'height': 250, - 'creativeId': '1515999070', - 'dealId': 'gax-paj2qarjf2g', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles empty bid response', () => { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); From 25e2520a059555519b391bd99ed7eca222b6e82c Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 12 Feb 2018 15:31:21 +0700 Subject: [PATCH 16/23] remove gaxDomain param and move to adapter --- modules/gammaBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 1d3b82c562d..35ca70fa478 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -2,6 +2,7 @@ import * as utils from 'src/utils'; import { registerBidder } from 'src/adapters/bidderFactory'; import find from 'core-js/library/fn/array/find'; +const ENDPOINT = 'hb.gammaplatform.com'; const BIDDER_CODE = 'gamma'; export const spec = { @@ -28,7 +29,7 @@ export const spec = { const gaxObjParams = find(bidRequests, hasParamInfo); return { method: 'GET', - url: '//' + gaxObjParams.params.gaxDomain + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + utils.getTopWindowUrl() + url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + utils.getTopWindowUrl() }; }, From b9889ad5d2b6bb2105e8110c6e608720baf60560 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 12 Feb 2018 15:33:14 +0700 Subject: [PATCH 17/23] remove check isBidRequestValid for gaxDomain --- modules/gammaBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 35ca70fa478..8240df3d151 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -16,7 +16,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function(bid) { - return !!(bid.params.siteId || bid.params.zoneId || bid.params.gaxDomain); + return !!(bid.params.siteId || bid.params.zoneId); }, /** From eca96a9fa9f3d1f5733dcf68836e3031bae21f77 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 12 Feb 2018 15:43:11 +0700 Subject: [PATCH 18/23] remove gaxDomain param --- modules/gammaBidAdapter_spec.js | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 modules/gammaBidAdapter_spec.js diff --git a/modules/gammaBidAdapter_spec.js b/modules/gammaBidAdapter_spec.js new file mode 100644 index 00000000000..1f3f225336e --- /dev/null +++ b/modules/gammaBidAdapter_spec.js @@ -0,0 +1,119 @@ +import * as utils from 'src/utils'; +import { expect } from 'chai'; +import { spec } from 'modules/gammaBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +describe('gammaBidAdapter', function() { + const adapter = newBidder(spec); + + describe('isBidRequestValid', () => { + let bid = { + 'bidder': 'gamma', + 'params': { + siteId: '1465446377', + zoneId: '1515999290' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + }; + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when require params are not passed', () => { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when params not passed correctly', () => { + bid.params.siteId = ''; + bid.params.zoneId = ''; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', () => { + let bidRequests = [ + { + 'bidder': 'gamma', + 'params': { + siteId: '1465446377', + zoneId: '1515999290' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1' + } + ]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via GET', () => { + expect(request.method).to.equal('GET'); + }); + + it('bidRequest url', () => { + expect(request.url).to.match(new RegExp(`hb.gammaplatform.com`)); + }); + }); + + describe('interpretResponse', () => { + let serverResponse = { + body: { + 'id': '23beaa6af6cdde', + 'bid': '5611802021800040585', + 'type': 'banner', + 'cur': 'USD', + 'seatbid': [{ + 'seat': '5611802021800040585', + 'bid': [{ + 'id': '1515999070', + 'impid': '1', + 'price': 0.45, + 'adm': '', + 'adid': '1515999070', + 'dealid': 'gax-paj2qarjf2g', + 'h': 250, + 'w': 300 + }] + }] + } + }; + + it('should get the correct bid response', () => { + let expectedResponse = [{ + 'requestId': '23beaa6af6cdde', + 'cpm': 0.45, + 'width': 300, + 'height': 250, + 'creativeId': '1515999070', + 'dealId': 'gax-paj2qarjf2g', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'ad': '' + }]; + let result = spec.interpretResponse(serverResponse); + expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); + }); + + it('handles empty bid response', () => { + let response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}); From f5cf69e8f504ee486a6c14fcc4987ddfafc0905e Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 12 Feb 2018 15:43:57 +0700 Subject: [PATCH 19/23] remove gaxDomain param --- modules/gammaBidAdapter.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/gammaBidAdapter.md b/modules/gammaBidAdapter.md index 6d7058ce42a..83c1fdf4853 100644 --- a/modules/gammaBidAdapter.md +++ b/modules/gammaBidAdapter.md @@ -23,8 +23,7 @@ var adUnits = [{ bidder: 'gamma', params: { siteId: '1465446377', - zoneId: '1515999290', - gaxDomain: 'hb.gammaplatform.com' + zoneId: '1515999290' } }] @@ -44,8 +43,7 @@ In order to receive bids please map localhost to (any) test domain. bidder: 'gamma', params: { siteId: '1465446377', - zoneId: '1515999290', - gaxDomain: 'hb.gammaplatform.com' + zoneId: '1515999290' } }] }]; From a7bbbb269c8518955a5387a51dfd693020329325 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 12 Feb 2018 15:46:13 +0700 Subject: [PATCH 20/23] remove gaxDomain param --- test/spec/modules/gammaBidAdapter_spec.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 15e01801c4f..1f3f225336e 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -11,8 +11,7 @@ describe('gammaBidAdapter', function() { 'bidder': 'gamma', 'params': { siteId: '1465446377', - zoneId: '1515999290', - gaxDomain: 'hb.gammaplatform.com' + zoneId: '1515999290' }, 'adUnitCode': 'adunit-code', 'sizes': [ @@ -36,7 +35,6 @@ describe('gammaBidAdapter', function() { it('should return false when params not passed correctly', () => { bid.params.siteId = ''; bid.params.zoneId = ''; - bid.params.gaxDomain = ''; expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); @@ -47,8 +45,7 @@ describe('gammaBidAdapter', function() { 'bidder': 'gamma', 'params': { siteId: '1465446377', - zoneId: '1515999290', - gaxDomain: 'hb.gammaplatform.com' + zoneId: '1515999290' }, 'adUnitCode': 'adunit-code', 'sizes': [ @@ -56,7 +53,7 @@ describe('gammaBidAdapter', function() { ], 'bidId': '23beaa6af6cdde', 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1' } ]; @@ -67,7 +64,7 @@ describe('gammaBidAdapter', function() { }); it('bidRequest url', () => { - expect(request.url).to.match(new RegExp(`${bidRequests[0].params.gaxDomain}`)); + expect(request.url).to.match(new RegExp(`hb.gammaplatform.com`)); }); }); From 81ed069cf946fa8f83e3d1b2829f480118a5378e Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 12 Feb 2018 15:46:43 +0700 Subject: [PATCH 21/23] Delete gammaBidAdapter_spec.js --- modules/gammaBidAdapter_spec.js | 119 -------------------------------- 1 file changed, 119 deletions(-) delete mode 100644 modules/gammaBidAdapter_spec.js diff --git a/modules/gammaBidAdapter_spec.js b/modules/gammaBidAdapter_spec.js deleted file mode 100644 index 1f3f225336e..00000000000 --- a/modules/gammaBidAdapter_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import * as utils from 'src/utils'; -import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('gammaBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', () => { - let bid = { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', - zoneId: '1515999290' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - - it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when require params are not passed', () => { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when params not passed correctly', () => { - bid.params.siteId = ''; - bid.params.zoneId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', () => { - let bidRequests = [ - { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', - zoneId: '1515999290' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1' - } - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via GET', () => { - expect(request.method).to.equal('GET'); - }); - - it('bidRequest url', () => { - expect(request.url).to.match(new RegExp(`hb.gammaplatform.com`)); - }); - }); - - describe('interpretResponse', () => { - let serverResponse = { - body: { - 'id': '23beaa6af6cdde', - 'bid': '5611802021800040585', - 'type': 'banner', - 'cur': 'USD', - 'seatbid': [{ - 'seat': '5611802021800040585', - 'bid': [{ - 'id': '1515999070', - 'impid': '1', - 'price': 0.45, - 'adm': '', - 'adid': '1515999070', - 'dealid': 'gax-paj2qarjf2g', - 'h': 250, - 'w': 300 - }] - }] - } - }; - - it('should get the correct bid response', () => { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 0.45, - 'width': 300, - 'height': 250, - 'creativeId': '1515999070', - 'dealId': 'gax-paj2qarjf2g', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles empty bid response', () => { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); From bb4169c8ff3e2e1f23460044976e808261bf3842 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Mar 2018 13:14:19 +0700 Subject: [PATCH 22/23] add usersync endpoid --- modules/gammaBidAdapter.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 8240df3d151..516f716fa76 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -50,6 +50,15 @@ export const spec = { } return bids; + }, + + getUserSyncs: function(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: '//' + ENDPOINT + '/adx/usersync' + }]; + } } } From 6ca18f444f767ee5c62f905c23987811c0f65700 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Mon, 5 Mar 2018 13:26:22 +0700 Subject: [PATCH 23/23] add usersync --- modules/gammaBidAdapter.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 8240df3d151..516f716fa76 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -50,6 +50,15 @@ export const spec = { } return bids; + }, + + getUserSyncs: function(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: '//' + ENDPOINT + '/adx/usersync' + }]; + } } }