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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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' + }]; + } } } From 1548a0c3d53bbcae839db560bd1dc5c4cefc91f3 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Wed, 14 Mar 2018 13:37:48 +0700 Subject: [PATCH 24/46] add vastUrl --- modules/gammaBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 516f716fa76..9a6690a332f 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -85,6 +85,7 @@ function newBid(serverBid) { if (serverBid.type == 'video') { Object.assign(bid, { vastXml: serverBid.seatbid[0].bid[0].vastXml, + vastUrl: serverBid.seatbid[0].bid[0].vastUrl, ttl: 3600 }); } From 7e5f905561494733a7e82ca2178ca446c83115e4 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 15 Mar 2018 14:18:41 +0700 Subject: [PATCH 25/46] add supportedMediaTypes to bidder spec --- modules/gammaBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 9a6690a332f..1fba73fd6ab 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -8,6 +8,7 @@ const BIDDER_CODE = 'gamma'; export const spec = { code: BIDDER_CODE, aliases: ['gamma'], + supportedMediaTypes: ['banner', 'video'], /** * Determines whether or not the given bid request is valid. From 316313098b026ee79290fe7485e58525e7ffd7cf Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 15 Mar 2018 14:27:43 +0700 Subject: [PATCH 26/46] add Test Parameters: For Video --- modules/gammaBidAdapter.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/gammaBidAdapter.md b/modules/gammaBidAdapter.md index 83c1fdf4853..2902be78492 100644 --- a/modules/gammaBidAdapter.md +++ b/modules/gammaBidAdapter.md @@ -12,7 +12,7 @@ Connects to Gamma exchange for bids. Gamma bid adapter supports Banner, Video. -# Test Parameters +# Test Parameters: For Banner ``` var adUnits = [{ code: 'gamma-hb-ad-123456-0', @@ -29,6 +29,23 @@ var adUnits = [{ }]; ``` +# Test Parameters: For Video +``` +var adUnits = [{ + code: 'gamma-hb-ad-78910-0', + sizes: [[640, 480]], + + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'gamma', + params: { + siteId: '1465446377', + zoneId: '1493280341' + } + }] + + }]; +``` # Ad Unit and Setup: For Testing In order to receive bids please map localhost to (any) test domain. From 146f7e23c34fd09875522b78e19caa6ad834ae3e Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 24 May 2018 15:03:34 +0700 Subject: [PATCH 27/46] Add encodeURIComponent for referer url --- modules/gammaBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 1fba73fd6ab..ce5c4ef2544 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -30,7 +30,7 @@ export const spec = { const gaxObjParams = find(bidRequests, hasParamInfo); return { method: 'GET', - url: '//' + ENDPOINT + '/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=' + encodeURIComponent(utils.getTopWindowUrl()) }; }, From d140fd4506f9499f3c6a387d20b1cad9c577b6ff Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Wed, 6 Jun 2018 17:23:31 +0700 Subject: [PATCH 28/46] support send multi request --- modules/gammaBidAdapter.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index ce5c4ef2544..9ca7dd75d19 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -27,11 +27,15 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests) { - const gaxObjParams = find(bidRequests, hasParamInfo); - return { - method: 'GET', - url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) - }; + const serverRequests = []; + for (var i = 0, len = bidRequests.length; i < len; i++) { + const gaxObjParams = bidRequests[i]; + serverRequests.push({ + method: 'GET', + url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) + }); + } + return serverRequests; }, /** From c6e570a5f68cf85d4011ad9ba0826d44f4606e4a Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Wed, 6 Jun 2018 17:27:05 +0700 Subject: [PATCH 29/46] support send multi request From 2464c4ad56b3238b15723c06f7ac97bee0e4f6cd Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Wed, 6 Jun 2018 17:31:28 +0700 Subject: [PATCH 30/46] fix confict --- modules/gammaBidAdapter.js | 105 ------------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 modules/gammaBidAdapter.js diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js deleted file mode 100644 index 9ca7dd75d19..00000000000 --- a/modules/gammaBidAdapter.js +++ /dev/null @@ -1,105 +0,0 @@ -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 = { - code: BIDDER_CODE, - aliases: ['gamma'], - supportedMediaTypes: ['banner', 'video'], - - /** - * 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); - }, - - /** - * 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 serverRequests = []; - for (var i = 0, len = bidRequests.length; i < len; i++) { - const gaxObjParams = bidRequests[i]; - serverRequests.push({ - method: 'GET', - url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) - }); - } - return serverRequests; - }, - - /** - * 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.id) { - const bid = newBid(serverResponse); - bids.push(bid); - } - - return bids; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//' + ENDPOINT + '/adx/usersync' - }]; - } - } -} - -/** - * 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 - }; - - if (serverBid.type == 'video') { - Object.assign(bid, { - vastXml: serverBid.seatbid[0].bid[0].vastXml, - vastUrl: serverBid.seatbid[0].bid[0].vastUrl, - ttl: 3600 - }); - } - - return bid; -} - -function hasParamInfo(bid) { - return !!bid.params; -} - -registerBidder(spec); From 3375209d197024da425c269ee5b7f3dc675be7b3 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Wed, 6 Jun 2018 17:32:00 +0700 Subject: [PATCH 31/46] fix conflict --- modules/gammaBidAdapter.js | 105 +++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 modules/gammaBidAdapter.js diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js new file mode 100644 index 00000000000..9ca7dd75d19 --- /dev/null +++ b/modules/gammaBidAdapter.js @@ -0,0 +1,105 @@ +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 = { + code: BIDDER_CODE, + aliases: ['gamma'], + supportedMediaTypes: ['banner', 'video'], + + /** + * 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); + }, + + /** + * 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 serverRequests = []; + for (var i = 0, len = bidRequests.length; i < len; i++) { + const gaxObjParams = bidRequests[i]; + serverRequests.push({ + method: 'GET', + url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) + }); + } + return serverRequests; + }, + + /** + * 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.id) { + const bid = newBid(serverResponse); + bids.push(bid); + } + + return bids; + }, + + getUserSyncs: function(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: '//' + ENDPOINT + '/adx/usersync' + }]; + } + } +} + +/** + * 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 + }; + + if (serverBid.type == 'video') { + Object.assign(bid, { + vastXml: serverBid.seatbid[0].bid[0].vastXml, + vastUrl: serverBid.seatbid[0].bid[0].vastUrl, + ttl: 3600 + }); + } + + return bid; +} + +function hasParamInfo(bid) { + return !!bid.params; +} + +registerBidder(spec); From 6462bbdec7f7282c0a1b91e9f7533bd0690c1beb Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Wed, 6 Jun 2018 17:42:08 +0700 Subject: [PATCH 32/46] support multi request From 39d82865a08a0c1033302873ea8eb14ddad2b6f7 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 09:07:01 +0700 Subject: [PATCH 33/46] fix indent --- modules/gammaBidAdapter.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 9ca7dd75d19..add3aad520b 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -1,6 +1,5 @@ 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'; @@ -27,15 +26,15 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests) { - const serverRequests = []; - for (var i = 0, len = bidRequests.length; i < len; i++) { + const serverRequests = []; + for (var i = 0, len = bidRequests.length; i < len; i++) { const gaxObjParams = bidRequests[i]; serverRequests.push({ method: 'GET', url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) }); - } - return serverRequests; + } + return serverRequests; }, /** @@ -98,8 +97,4 @@ function newBid(serverBid) { return bid; } -function hasParamInfo(bid) { - return !!bid.params; -} - registerBidder(spec); From c597ce31975615da08719f4fa54bb7578d87b70c Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:33:49 +0700 Subject: [PATCH 34/46] multi request --- test/spec/modules/gammaBidAdapter_spec.js | 83 ++++++++++------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 1f3f225336e..24120111c68 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -5,14 +5,14 @@ import { newBidder } from 'src/adapters/bidderFactory'; describe('gammaBidAdapter', function() { const adapter = newBidder(spec); + const ENDPOINT = 'hb.gammaplatform.com'; - describe('isBidRequestValid', () => { - let bid = { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', + let bid = { + 'bidder': 'gamma', + 'params': { + siteId: '1465446377', zoneId: '1515999290' - }, + }, 'adUnitCode': 'adunit-code', 'sizes': [ [300, 250] @@ -20,8 +20,10 @@ describe('gammaBidAdapter', function() { 'bidId': '23beaa6af6cdde', 'bidderRequestId': '19c0c1efdf37e7', 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - + }; + let bidArray = [bid]; + + describe('isBidRequestValid', () => { it('should return true when required params found', () => { expect(spec.isBidRequestValid(bid)).to.equal(true); }); @@ -40,56 +42,43 @@ describe('gammaBidAdapter', function() { }); 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); + const request = spec.buildRequests(bidArray); 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`)); + expect(request.url).to.be.equal(ENDPOINT); }); }); 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 + let serverResponse; + + beforeEach(() => { + 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 = [{ From 94650f05aaf62bec06d8c8af6cd47639f2e3e595 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:48:25 +0700 Subject: [PATCH 35/46] fix indent --- test/spec/modules/gammaBidAdapter_spec.js | 25 +++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 24120111c68..2e4084539d3 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -11,18 +11,18 @@ describe('gammaBidAdapter', function() { 'bidder': 'gamma', 'params': { siteId: '1465446377', - zoneId: '1515999290' + zoneId: '1515999290' }, - 'adUnitCode': 'adunit-code', - 'sizes': [ + 'adUnitCode': 'adunit-code', + 'sizes': [ [300, 250] ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', }; let bidArray = [bid]; - + describe('isBidRequestValid', () => { it('should return true when required params found', () => { expect(spec.isBidRequestValid(bid)).to.equal(true); @@ -42,17 +42,12 @@ describe('gammaBidAdapter', function() { }); describe('buildRequests', () => { - const request = spec.buildRequests(bidArray); - - it('sends bid request to our endpoint via GET', () => { + it('should attempt to send bid requests to the endpoint via GET', () => { + const request = spec.buildRequests(bidArray); expect(request.method).to.equal('GET'); + expect(request.url).to.be.equal(ENDPOINT); }); - it('bidRequest url', () => { - expect(request.url).to.be.equal(ENDPOINT); - }); - }); - describe('interpretResponse', () => { let serverResponse; From 85fc8dd3e64d0f48c2c1fd134b26402942990869 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:01:28 +0700 Subject: [PATCH 36/46] Add files via upload --- test/spec/gammaBidAdapter_spec.js | 106 ++++++++++++++++++++++++++++++ 1 file changed, 106 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..58e4bd555f1 --- /dev/null +++ b/test/spec/gammaBidAdapter_spec.js @@ -0,0 +1,106 @@ +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); + const ENDPOINT = 'hb.gammaplatform.com'; + + 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', + }; + let bidArray = [bid]; + + describe('isBidRequestValid', () => { + 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', () => { + it('should attempt to send bid requests to the endpoint via GET', () => { + const requests = spec.buildRequests(bidArray); + requests.forEach(function(requestItem) { + expect(requestItem.method).to.equal('GET'); + expect(request.url).to.be.equal(ENDPOINT); + }); + }); + }); + + describe('interpretResponse', () => { + let serverResponse; + + beforeEach(() => { + 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); + }); + }); +}); \ No newline at end of file From 977ebda152db17c3a583cf5e7a0657beff871054 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:12:43 +0700 Subject: [PATCH 37/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 2e4084539d3..92d43165581 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -15,8 +15,8 @@ describe('gammaBidAdapter', function() { }, 'adUnitCode': 'adunit-code', 'sizes': [ - [300, 250] - ], + [300, 250] + ], 'bidId': '23beaa6af6cdde', 'bidderRequestId': '19c0c1efdf37e7', 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', @@ -43,10 +43,13 @@ describe('gammaBidAdapter', function() { describe('buildRequests', () => { it('should attempt to send bid requests to the endpoint via GET', () => { - const request = spec.buildRequests(bidArray); - expect(request.method).to.equal('GET'); - expect(request.url).to.be.equal(ENDPOINT); + const requests = spec.buildRequests(bidArray); + requests.forEach(function(requestItem) { + expect(requestItem.method).to.equal('GET'); + expect(request.url).to.be.equal(ENDPOINT); + }); }); + }); describe('interpretResponse', () => { let serverResponse; @@ -93,9 +96,9 @@ describe('gammaBidAdapter', function() { }); it('handles empty bid response', () => { - let response = { + let response = [{ body: {} - }; + }]; let result = spec.interpretResponse(response); expect(result.length).to.equal(0); }); From 8a39e9abeaaea9a21391439734e84f5506cdb730 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:25:53 +0700 Subject: [PATCH 38/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 92d43165581..aa255830737 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -46,7 +46,7 @@ describe('gammaBidAdapter', function() { const requests = spec.buildRequests(bidArray); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('GET'); - expect(request.url).to.be.equal(ENDPOINT); + expect(requestItem.url).to.be.equal(ENDPOINT); }); }); }); From 4afbf3a77068f74fc21e6ee876c8c43ddfd0e18b Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:36:10 +0700 Subject: [PATCH 39/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index aa255830737..bdbbed014bc 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -5,7 +5,6 @@ import { newBidder } from 'src/adapters/bidderFactory'; describe('gammaBidAdapter', function() { const adapter = newBidder(spec); - const ENDPOINT = 'hb.gammaplatform.com'; let bid = { 'bidder': 'gamma', @@ -46,7 +45,7 @@ describe('gammaBidAdapter', function() { const requests = spec.buildRequests(bidArray); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('GET'); - expect(requestItem.url).to.be.equal(ENDPOINT); + expect(requestItem.url).to.match(new RegExp(`hb.gammaplatform.com`)); }); }); }); From 47240d99011f6919c5b72a2fe862f03a2eafc67c Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:47:28 +0700 Subject: [PATCH 40/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index bdbbed014bc..5ff959cfb21 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -95,9 +95,9 @@ describe('gammaBidAdapter', function() { }); it('handles empty bid response', () => { - let response = [{ + let response = { body: {} - }]; + }; let result = spec.interpretResponse(response); expect(result.length).to.equal(0); }); From fbd887ffd91dadfff04f5707a0553981f76d0b9e Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 13:32:17 +0700 Subject: [PATCH 41/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 5ff959cfb21..7473f4ab2dc 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -41,6 +41,21 @@ describe('gammaBidAdapter', function() { }); describe('buildRequests', () => { + bidArray.push({ + '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 attempt to send bid requests to the endpoint via GET', () => { const requests = spec.buildRequests(bidArray); requests.forEach(function(requestItem) { From 920c2d4cbb174eb7c4e021cd060e81da1fddbc4a Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 14:06:19 +0700 Subject: [PATCH 42/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 28 ++++------------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 7473f4ab2dc..f9800dab8a8 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -13,14 +13,11 @@ describe('gammaBidAdapter', function() { zoneId: '1515999290' }, 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], + 'sizes': [[300, 250]], 'bidId': '23beaa6af6cdde', 'bidderRequestId': '19c0c1efdf37e7', 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', }; - let bidArray = [bid]; describe('isBidRequestValid', () => { it('should return true when required params found', () => { @@ -41,27 +38,10 @@ describe('gammaBidAdapter', function() { }); describe('buildRequests', () => { - bidArray.push({ - '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 attempt to send bid requests to the endpoint via GET', () => { - const requests = spec.buildRequests(bidArray); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - expect(requestItem.url).to.match(new RegExp(`hb.gammaplatform.com`)); - }); + const requests = spec.buildRequests([bid]); + expect(requests[0].method).to.equal('GET'); + expect(requests[0].url).to.match(new RegExp(`hb.gammaplatform.com`)); }); }); From d17ed8fbdf950e3e8b07c98a1327179ccc7763a4 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 14:12:50 +0700 Subject: [PATCH 43/46] Delete gammaBidAdapter_spec.js --- test/spec/modules/gammaBidAdapter_spec.js | 100 ---------------------- 1 file changed, 100 deletions(-) delete mode 100644 test/spec/modules/gammaBidAdapter_spec.js diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js deleted file mode 100644 index f9800dab8a8..00000000000 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ /dev/null @@ -1,100 +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); - - 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', - }; - - describe('isBidRequestValid', () => { - 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', () => { - it('should attempt to send bid requests to the endpoint via GET', () => { - const requests = spec.buildRequests([bid]); - expect(requests[0].method).to.equal('GET'); - expect(requests[0].url).to.match(new RegExp(`hb.gammaplatform.com`)); - }); - }); - - describe('interpretResponse', () => { - let serverResponse; - - beforeEach(() => { - 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 09c970a70ac40c6195d1c7d3335c237083324bb1 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 14:14:07 +0700 Subject: [PATCH 44/46] Delete gammaBidAdapter_spec.js --- test/spec/gammaBidAdapter_spec.js | 106 ------------------------------ 1 file changed, 106 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 58e4bd555f1..00000000000 --- a/test/spec/gammaBidAdapter_spec.js +++ /dev/null @@ -1,106 +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); - const ENDPOINT = 'hb.gammaplatform.com'; - - 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', - }; - let bidArray = [bid]; - - describe('isBidRequestValid', () => { - 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', () => { - it('should attempt to send bid requests to the endpoint via GET', () => { - const requests = spec.buildRequests(bidArray); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - expect(request.url).to.be.equal(ENDPOINT); - }); - }); - }); - - describe('interpretResponse', () => { - let serverResponse; - - beforeEach(() => { - 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); - }); - }); -}); \ No newline at end of file From 1d9002b3a92dc13beba8959271ea96d9b192565a Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 14:14:26 +0700 Subject: [PATCH 45/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 100 ++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 test/spec/modules/gammaBidAdapter_spec.js diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js new file mode 100644 index 00000000000..f9800dab8a8 --- /dev/null +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -0,0 +1,100 @@ +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); + + 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', + }; + + describe('isBidRequestValid', () => { + 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', () => { + it('should attempt to send bid requests to the endpoint via GET', () => { + const requests = spec.buildRequests([bid]); + expect(requests[0].method).to.equal('GET'); + expect(requests[0].url).to.match(new RegExp(`hb.gammaplatform.com`)); + }); + }); + + describe('interpretResponse', () => { + let serverResponse; + + beforeEach(() => { + 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 81824600fb1c0827844e63fc2ac67a42349a8bf7 Mon Sep 17 00:00:00 2001 From: gammassp <35954362+gammassp@users.noreply.github.com> Date: Thu, 7 Jun 2018 14:23:23 +0700 Subject: [PATCH 46/46] Add files via upload --- test/spec/modules/gammaBidAdapter_spec.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index f9800dab8a8..5ff959cfb21 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -13,11 +13,14 @@ describe('gammaBidAdapter', function() { zoneId: '1515999290' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], + 'sizes': [ + [300, 250] + ], 'bidId': '23beaa6af6cdde', 'bidderRequestId': '19c0c1efdf37e7', 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', }; + let bidArray = [bid]; describe('isBidRequestValid', () => { it('should return true when required params found', () => { @@ -39,9 +42,11 @@ describe('gammaBidAdapter', function() { describe('buildRequests', () => { it('should attempt to send bid requests to the endpoint via GET', () => { - const requests = spec.buildRequests([bid]); - expect(requests[0].method).to.equal('GET'); - expect(requests[0].url).to.match(new RegExp(`hb.gammaplatform.com`)); + const requests = spec.buildRequests(bidArray); + requests.forEach(function(requestItem) { + expect(requestItem.method).to.equal('GET'); + expect(requestItem.url).to.match(new RegExp(`hb.gammaplatform.com`)); + }); }); });