From 27872b3f7fd861898c331e5b5ad56eca3e4b1b84 Mon Sep 17 00:00:00 2001 From: cykimh Date: Tue, 5 Dec 2017 15:33:02 +0900 Subject: [PATCH 1/8] add NasmediaAdmixer adapter for Perbid.js 1.0 --- modules/nasmediaAdmixerBidAdapter.js | 95 ++++++++++++ modules/nasmediaAdmixerBidAdapter.md | 32 ++++ .../modules/nasmediaAdmixerBidAdapter_spec.js | 138 ++++++++++++++++++ 3 files changed, 265 insertions(+) create mode 100644 modules/nasmediaAdmixerBidAdapter.js create mode 100644 modules/nasmediaAdmixerBidAdapter.md create mode 100644 test/spec/modules/nasmediaAdmixerBidAdapter_spec.js diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js new file mode 100644 index 00000000000..f554677e9e5 --- /dev/null +++ b/modules/nasmediaAdmixerBidAdapter.js @@ -0,0 +1,95 @@ +import * as utils from 'src/utils'; +import {registerBidder} from 'src/adapters/bidderFactory'; + +// const ADMIXER_ENDPOINT = '//prebid.admixer.co.kr/nasmediaAdMixerAdServer.php'; +const ADMIXER_ENDPOINT = '//adn2.admixer.co.kr:25846/prebid'; +const DEFAULT_BID_TTL = 360; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_REVENUE = false; + +export const spec = { + code: 'nasmediaAdmixer', + + aliases: ['nasmediaAdmixerLite'], + + isBidRequestValid: function (bid) { + return !!(bid && bid.params && bid.params.ax_key); + }, + + buildRequests: function (validBidRequests) { + return validBidRequests.map(bid => { + let adSizes = getSize(bid.sizes); + + return { + method: 'GET', + url: ADMIXER_ENDPOINT, + data: { + ax_key: utils.getBidIdParameter('ax_key', bid.params), + req_id: bid.bidId, + width: adSizes[0], + height: adSizes[1], + referrer: utils.getTopWindowUrl(), + os: getOsType() + } + } + }) + }, + + interpretResponse: function (serverResponse, bidRequest) { + const serverBody = serverResponse.body; + const bidResponses = []; + + if (serverBody && serverBody.error_code === 0 && serverBody.body && serverBody.body.length > 0) { + let bidData = serverBody.body[0]; + + const bidResponse = { + ad: bidData.ad, + requestId: serverBody.req_id, + creativeId: bidData.ad_id, + cpm: bidData.cpm, + width: bidData.width, + height: bidData.height, + currency: bidData.currency ? bidData.currency : DEFAULT_CURRENCY, + netRevenue: bidData.revenue ? bidData.revenue : DEFAULT_REVENUE, + ttl: bidData.ttl ? bidData.ttl : DEFAULT_BID_TTL + }; + + bidResponses.push(bidResponse); + } else { + utils.logWarn('nasmediaAdmixer Error' + serverBody.error_msg, 'nasmediaAdmixer') + } + return bidResponses; + } +} + +function getOsType() { + let ua = navigator.userAgent.toLowerCase(); + + if (ua.match(/android/i)) { + return 'android'; + } else if (ua.match(/iphone/i) || ua.match(/ipad/i)) { + return 'ios'; + } else if (ua.match(/mac/i)) { + return 'mac'; + } else if (ua.match(/linux/i)) { + return 'linux'; + } else if (ua.match(/window/i)) { + return 'window'; + } else { + return 'etc'; + } +} + +function getSize(sizes) { + let width = 0; + let height = 0; + if (sizes.length === 2 && typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { + width = sizes[0]; + height = sizes[1]; + } else { + width = sizes[0][0]; + height = sizes[0][1]; + } + return [width, height]; +} +registerBidder(spec); diff --git a/modules/nasmediaAdmixerBidAdapter.md b/modules/nasmediaAdmixerBidAdapter.md new file mode 100644 index 00000000000..29b1dfe7f33 --- /dev/null +++ b/modules/nasmediaAdmixerBidAdapter.md @@ -0,0 +1,32 @@ +# Overview + +``` +Module Name: NasmeidaAdmixer Bidder Adapter +Module Type: Bidder Adapter +Maintainer: mobilep1@nasmedia.co.kr +``` + +# Description + +Module that connects to NasmediaAdmixer demand sources. +Banner formats are supported. +The NasmediaAdmixer adapter doesn't support multiple sizes per ad-unit and will use the first one if multiple sizes are defined. + + +# Test Parameters +``` + var adUnits = [ + { + code: 'banner-ad-div', + sizes: [[320, 480]], // banner size + bids: [ + { + bidder: 'nasmediaAdmixer', + params: { + ax_key: 'thdaa110', //required parameter + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js new file mode 100644 index 00000000000..cfe1aa399dd --- /dev/null +++ b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js @@ -0,0 +1,138 @@ +import {expect} from 'chai'; +import {spec} from 'modules/nasmediaAdmixerBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory'; + +describe('nasmediaAdmixerBidAdapter', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', () => { + const bid = { + 'bidder': 'nasmediaAdmixer', + 'params': { + 'ax_key': 'ax_key' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[320, 480]], + 'bidId': '3361d01e67dbd6', + 'bidderRequestId': '2b60dcd392628a', + 'auctionId': '124cb070528662', + }; + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', () => { + const bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'ax_key': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', () => { + const bidRequests = [ + { + 'bidder': 'nasmediaAdmixer', + 'params': { + 'ax_key': 'thdaa110' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[320, 480]], + 'bidId': '3361d01e67dbd6', + 'bidderRequestId': '2b60dcd392628a', + 'auctionId': '124cb070528662', + } + ]; + + it('sends bid request to url via GET', () => { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.method).to.equal('GET'); + expect(request.url).to.match(new RegExp(`//adn2.admixer.co.kr:25846/prebid`)); + }); + }); + + describe('interpretResponse', () => { + const response = { + 'body': { + 'bidder': 'nasmedia_admixer', + 'req_id': '861a8e7952c82c', + 'error_code': 0, + 'error_msg': 'OK', + 'body': [{ + 'ad_id': '20049', + 'width': 320, + 'height': 480, + 'currency': 'USD', + 'cpm': 1.769221, + 'ad': '' + }] + }, + 'headers': { + 'get': function () { + } + } + }; + + const bidRequest = { + 'bidder': 'nasmediaAdmixer', + 'params': { + 'ax_key': 'thdaa110', + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[320, 480], [300, 250]], + 'bidId': '31300c8b9697cd', + 'bidderRequestId': '2bf570adcf83fa', + 'auctionId': '169827a33f03cc', + }; + + it('should get correct bid response', () => { + const expectedResponse = [ + { + 'requestId': '861a8e7952c82c', + 'cpm': 1.769221, + 'currency': 'USD', + 'width': 320, + 'height': 480, + 'ad': '', + 'creativeId': '20049', + 'ttl': 360, + 'netRevenue': false + } + ]; + + const result = spec.interpretResponse(response, bidRequest); + expect(result).to.have.lengthOf(1); + let resultKeys = Object.keys(result[0]); + expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort()); + resultKeys.forEach(function (k) { + if (k === 'ad') { + expect(result[0][k]).to.match(/$/); + } else { + expect(result[0][k]).to.equal(expectedResponse[0][k]); + } + }); + }); + + it('handles nobid responses', () => { + response.body = { + 'bidder': 'nasmedia_admixer', + 'req_id': '861a8e7952c82c', + 'error_code': 0, + 'error_msg': 'OK', + 'body': [] + }; + + const result = spec.interpretResponse(response, bidRequest); + expect(result).to.have.lengthOf(0); + }); + }); +}); From 54f39fb38905f2a6c012d26ee575adca7916fba4 Mon Sep 17 00:00:00 2001 From: cykimh Date: Tue, 5 Dec 2017 16:25:02 +0900 Subject: [PATCH 2/8] add NasmediaAdmixer adapter for Perbid.js 1.0 --- modules/nasmediaAdmixerBidAdapter.js | 134 +++++----- .../modules/nasmediaAdmixerBidAdapter_spec.js | 232 +++++++++--------- 2 files changed, 183 insertions(+), 183 deletions(-) diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js index f554677e9e5..a47f1bc76b5 100644 --- a/modules/nasmediaAdmixerBidAdapter.js +++ b/modules/nasmediaAdmixerBidAdapter.js @@ -8,88 +8,88 @@ const DEFAULT_CURRENCY = 'USD'; const DEFAULT_REVENUE = false; export const spec = { - code: 'nasmediaAdmixer', + code: 'nasmediaAdmixer', - aliases: ['nasmediaAdmixerLite'], + aliases: ['nasmediaAdmixerLite'], - isBidRequestValid: function (bid) { - return !!(bid && bid.params && bid.params.ax_key); - }, + isBidRequestValid: function (bid) { + return !!(bid && bid.params && bid.params.ax_key); + }, - buildRequests: function (validBidRequests) { - return validBidRequests.map(bid => { - let adSizes = getSize(bid.sizes); + buildRequests: function (validBidRequests) { + return validBidRequests.map(bid => { + let adSizes = getSize(bid.sizes); - return { - method: 'GET', - url: ADMIXER_ENDPOINT, - data: { - ax_key: utils.getBidIdParameter('ax_key', bid.params), - req_id: bid.bidId, - width: adSizes[0], - height: adSizes[1], - referrer: utils.getTopWindowUrl(), - os: getOsType() - } - } - }) - }, + return { + method: 'GET', + url: ADMIXER_ENDPOINT, + data: { + ax_key: utils.getBidIdParameter('ax_key', bid.params), + req_id: bid.bidId, + width: adSizes[0], + height: adSizes[1], + referrer: utils.getTopWindowUrl(), + os: getOsType() + } + } + }) + }, - interpretResponse: function (serverResponse, bidRequest) { - const serverBody = serverResponse.body; - const bidResponses = []; + interpretResponse: function (serverResponse, bidRequest) { + const serverBody = serverResponse.body; + const bidResponses = []; - if (serverBody && serverBody.error_code === 0 && serverBody.body && serverBody.body.length > 0) { - let bidData = serverBody.body[0]; + if (serverBody && serverBody.error_code === 0 && serverBody.body && serverBody.body.length > 0) { + let bidData = serverBody.body[0]; - const bidResponse = { - ad: bidData.ad, - requestId: serverBody.req_id, - creativeId: bidData.ad_id, - cpm: bidData.cpm, - width: bidData.width, - height: bidData.height, - currency: bidData.currency ? bidData.currency : DEFAULT_CURRENCY, - netRevenue: bidData.revenue ? bidData.revenue : DEFAULT_REVENUE, - ttl: bidData.ttl ? bidData.ttl : DEFAULT_BID_TTL - }; + const bidResponse = { + ad: bidData.ad, + requestId: serverBody.req_id, + creativeId: bidData.ad_id, + cpm: bidData.cpm, + width: bidData.width, + height: bidData.height, + currency: bidData.currency ? bidData.currency : DEFAULT_CURRENCY, + netRevenue: bidData.revenue ? bidData.revenue : DEFAULT_REVENUE, + ttl: bidData.ttl ? bidData.ttl : DEFAULT_BID_TTL + }; - bidResponses.push(bidResponse); - } else { - utils.logWarn('nasmediaAdmixer Error' + serverBody.error_msg, 'nasmediaAdmixer') - } - return bidResponses; + bidResponses.push(bidResponse); + } else { + utils.logWarn('nasmediaAdmixer Error' + serverBody.error_msg, 'nasmediaAdmixer') } + return bidResponses; + } } function getOsType() { - let ua = navigator.userAgent.toLowerCase(); + let ua = navigator.userAgent.toLowerCase(); - if (ua.match(/android/i)) { - return 'android'; - } else if (ua.match(/iphone/i) || ua.match(/ipad/i)) { - return 'ios'; - } else if (ua.match(/mac/i)) { - return 'mac'; - } else if (ua.match(/linux/i)) { - return 'linux'; - } else if (ua.match(/window/i)) { - return 'window'; - } else { - return 'etc'; - } + if (ua.match(/android/i)) { + return 'android'; + } else if (ua.match(/iphone/i) || ua.match(/ipad/i)) { + return 'ios'; + } else if (ua.match(/mac/i)) { + return 'mac'; + } else if (ua.match(/linux/i)) { + return 'linux'; + } else if (ua.match(/window/i)) { + return 'window'; + } else { + return 'etc'; + } } function getSize(sizes) { - let width = 0; - let height = 0; - if (sizes.length === 2 && typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { - width = sizes[0]; - height = sizes[1]; - } else { - width = sizes[0][0]; - height = sizes[0][1]; - } - return [width, height]; + let width = 0; + let height = 0; + if (sizes.length === 2 && typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { + width = sizes[0]; + height = sizes[1]; + } else { + width = sizes[0][0]; + height = sizes[0][1]; + } + return [width, height]; } registerBidder(spec); diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js index cfe1aa399dd..666629ad79f 100644 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js @@ -3,136 +3,136 @@ import {spec} from 'modules/nasmediaAdmixerBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; describe('nasmediaAdmixerBidAdapter', () => { - const adapter = newBidder(spec); + const adapter = newBidder(spec); - describe('inherited functions', () => { - it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); }); + }); - describe('isBidRequestValid', () => { - const bid = { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ax_key' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[320, 480]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - }; + describe('isBidRequestValid', () => { + const bid = { + 'bidder': 'nasmediaAdmixer', + 'params': { + 'ax_key': 'ax_key' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[320, 480]], + 'bidId': '3361d01e67dbd6', + 'bidderRequestId': '2b60dcd392628a', + 'auctionId': '124cb070528662', + }; - it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); - it('should return false when required params are not passed', () => { - const bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'ax_key': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); + it('should return false when required params are not passed', () => { + const bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'ax_key': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); }); + }); - describe('buildRequests', () => { - const bidRequests = [ - { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'thdaa110' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[320, 480]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - } - ]; + describe('buildRequests', () => { + const bidRequests = [ + { + 'bidder': 'nasmediaAdmixer', + 'params': { + 'ax_key': 'thdaa110' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[320, 480]], + 'bidId': '3361d01e67dbd6', + 'bidderRequestId': '2b60dcd392628a', + 'auctionId': '124cb070528662', + } + ]; - it('sends bid request to url via GET', () => { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`//adn2.admixer.co.kr:25846/prebid`)); - }); + it('sends bid request to url via GET', () => { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.method).to.equal('GET'); + expect(request.url).to.match(new RegExp(`//adn2.admixer.co.kr:25846/prebid`)); }); + }); - describe('interpretResponse', () => { - const response = { - 'body': { - 'bidder': 'nasmedia_admixer', - 'req_id': '861a8e7952c82c', - 'error_code': 0, - 'error_msg': 'OK', - 'body': [{ - 'ad_id': '20049', - 'width': 320, - 'height': 480, - 'currency': 'USD', - 'cpm': 1.769221, - 'ad': '' - }] - }, - 'headers': { - 'get': function () { - } - } - }; + describe('interpretResponse', () => { + const response = { + 'body': { + 'bidder': 'nasmedia_admixer', + 'req_id': '861a8e7952c82c', + 'error_code': 0, + 'error_msg': 'OK', + 'body': [{ + 'ad_id': '20049', + 'width': 320, + 'height': 480, + 'currency': 'USD', + 'cpm': 1.769221, + 'ad': '' + }] + }, + 'headers': { + 'get': function () { + } + } + }; - const bidRequest = { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'thdaa110', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[320, 480], [300, 250]], - 'bidId': '31300c8b9697cd', - 'bidderRequestId': '2bf570adcf83fa', - 'auctionId': '169827a33f03cc', - }; + const bidRequest = { + 'bidder': 'nasmediaAdmixer', + 'params': { + 'ax_key': 'thdaa110', + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[320, 480], [300, 250]], + 'bidId': '31300c8b9697cd', + 'bidderRequestId': '2bf570adcf83fa', + 'auctionId': '169827a33f03cc', + }; - it('should get correct bid response', () => { - const expectedResponse = [ - { - 'requestId': '861a8e7952c82c', - 'cpm': 1.769221, - 'currency': 'USD', - 'width': 320, - 'height': 480, - 'ad': '', - 'creativeId': '20049', - 'ttl': 360, - 'netRevenue': false - } - ]; + it('should get correct bid response', () => { + const expectedResponse = [ + { + 'requestId': '861a8e7952c82c', + 'cpm': 1.769221, + 'currency': 'USD', + 'width': 320, + 'height': 480, + 'ad': '', + 'creativeId': '20049', + 'ttl': 360, + 'netRevenue': false + } + ]; - const result = spec.interpretResponse(response, bidRequest); - expect(result).to.have.lengthOf(1); - let resultKeys = Object.keys(result[0]); - expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort()); - resultKeys.forEach(function (k) { - if (k === 'ad') { - expect(result[0][k]).to.match(/$/); - } else { - expect(result[0][k]).to.equal(expectedResponse[0][k]); - } - }); - }); + const result = spec.interpretResponse(response, bidRequest); + expect(result).to.have.lengthOf(1); + let resultKeys = Object.keys(result[0]); + expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort()); + resultKeys.forEach(function (k) { + if (k === 'ad') { + expect(result[0][k]).to.match(/$/); + } else { + expect(result[0][k]).to.equal(expectedResponse[0][k]); + } + }); + }); - it('handles nobid responses', () => { - response.body = { - 'bidder': 'nasmedia_admixer', - 'req_id': '861a8e7952c82c', - 'error_code': 0, - 'error_msg': 'OK', - 'body': [] - }; + it('handles nobid responses', () => { + response.body = { + 'bidder': 'nasmedia_admixer', + 'req_id': '861a8e7952c82c', + 'error_code': 0, + 'error_msg': 'OK', + 'body': [] + }; - const result = spec.interpretResponse(response, bidRequest); - expect(result).to.have.lengthOf(0); - }); + const result = spec.interpretResponse(response, bidRequest); + expect(result).to.have.lengthOf(0); }); + }); }); From d065e82649d45284068e52264373584dbdc0d6bb Mon Sep 17 00:00:00 2001 From: cykimh Date: Thu, 7 Dec 2017 15:34:03 +0900 Subject: [PATCH 3/8] add NasmediaAdmixer adapter for Perbid.js 1.0 --- modules/nasmediaAdmixerBidAdapter.js | 6 +++--- modules/nasmediaAdmixerBidAdapter.md | 4 ++-- test/spec/modules/nasmediaAdmixerBidAdapter_spec.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js index a47f1bc76b5..8c202720c7f 100644 --- a/modules/nasmediaAdmixerBidAdapter.js +++ b/modules/nasmediaAdmixerBidAdapter.js @@ -1,8 +1,8 @@ import * as utils from 'src/utils'; import {registerBidder} from 'src/adapters/bidderFactory'; -// const ADMIXER_ENDPOINT = '//prebid.admixer.co.kr/nasmediaAdMixerAdServer.php'; -const ADMIXER_ENDPOINT = '//adn2.admixer.co.kr:25846/prebid'; +// const ADMIXER_ENDPOINT = '//adn2.admixer.co.kr:25846/prebid'; +const ADMIXER_ENDPOINT = 'https://adn2.admixer.co.kr:10443/prebid'; const DEFAULT_BID_TTL = 360; const DEFAULT_CURRENCY = 'USD'; const DEFAULT_REVENUE = false; @@ -10,7 +10,7 @@ const DEFAULT_REVENUE = false; export const spec = { code: 'nasmediaAdmixer', - aliases: ['nasmediaAdmixerLite'], + aliases: ['nasmedia_admixer'], isBidRequestValid: function (bid) { return !!(bid && bid.params && bid.params.ax_key); diff --git a/modules/nasmediaAdmixerBidAdapter.md b/modules/nasmediaAdmixerBidAdapter.md index 29b1dfe7f33..aa72b7967f8 100644 --- a/modules/nasmediaAdmixerBidAdapter.md +++ b/modules/nasmediaAdmixerBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: NasmeidaAdmixer Bidder Adapter Module Type: Bidder Adapter -Maintainer: mobilep1@nasmedia.co.kr +Maintainer: prebid@nasmedia.co.kr ``` # Description @@ -23,7 +23,7 @@ The NasmediaAdmixer adapter doesn't support multiple sizes per ad-unit and will { bidder: 'nasmediaAdmixer', params: { - ax_key: 'thdaa110', //required parameter + ax_key: 'ajj7jba3', //required parameter } } ] diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js index 666629ad79f..f663bb81f76 100644 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js @@ -43,7 +43,7 @@ describe('nasmediaAdmixerBidAdapter', () => { { 'bidder': 'nasmediaAdmixer', 'params': { - 'ax_key': 'thdaa110' + 'ax_key': 'ajj7jba3' }, 'adUnitCode': 'adunit-code', 'sizes': [[320, 480]], @@ -85,7 +85,7 @@ describe('nasmediaAdmixerBidAdapter', () => { const bidRequest = { 'bidder': 'nasmediaAdmixer', 'params': { - 'ax_key': 'thdaa110', + 'ax_key': 'ajj7jba3', }, 'adUnitCode': 'adunit-code', 'sizes': [[320, 480], [300, 250]], From 58f4cc5f46611b13e1a812539a0ec0713fa72666 Mon Sep 17 00:00:00 2001 From: cykimh Date: Thu, 7 Dec 2017 15:34:42 +0900 Subject: [PATCH 4/8] add NasmediaAdmixer adapter for Perbid.js 1.0 --- modules/nasmediaAdmixerBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js index 8c202720c7f..d82e03f7e63 100644 --- a/modules/nasmediaAdmixerBidAdapter.js +++ b/modules/nasmediaAdmixerBidAdapter.js @@ -2,7 +2,7 @@ import * as utils from 'src/utils'; import {registerBidder} from 'src/adapters/bidderFactory'; // const ADMIXER_ENDPOINT = '//adn2.admixer.co.kr:25846/prebid'; -const ADMIXER_ENDPOINT = 'https://adn2.admixer.co.kr:10443/prebid'; +const ADMIXER_ENDPOINT = 'https://adn.admixer.co.kr:10443/prebid'; const DEFAULT_BID_TTL = 360; const DEFAULT_CURRENCY = 'USD'; const DEFAULT_REVENUE = false; From 57e2df6f87cce9f41e051a267645b1f9f43175a6 Mon Sep 17 00:00:00 2001 From: cykimh Date: Thu, 7 Dec 2017 15:41:06 +0900 Subject: [PATCH 5/8] add NasmediaAdmixer adapter for Perbid.js 1.0 --- test/spec/modules/nasmediaAdmixerBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js index f663bb81f76..53369a1a593 100644 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js @@ -56,7 +56,7 @@ describe('nasmediaAdmixerBidAdapter', () => { it('sends bid request to url via GET', () => { const request = spec.buildRequests(bidRequests)[0]; expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`//adn2.admixer.co.kr:25846/prebid`)); + expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr:10443/prebid`)); }); }); From 2c26f4ae883ac511dd5ab041cb266e5bd952bd4a Mon Sep 17 00:00:00 2001 From: cykimh Date: Fri, 15 Dec 2017 15:13:27 +0900 Subject: [PATCH 6/8] add NasmediaAdmixer adapter for Perbid.js 1.0 --- modules/nasmediaAdmixerBidAdapter.js | 52 +++++++------------ .../modules/nasmediaAdmixerBidAdapter_spec.js | 16 +++--- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js index d82e03f7e63..e4892f3d0ed 100644 --- a/modules/nasmediaAdmixerBidAdapter.js +++ b/modules/nasmediaAdmixerBidAdapter.js @@ -1,7 +1,6 @@ import * as utils from 'src/utils'; import {registerBidder} from 'src/adapters/bidderFactory'; -// const ADMIXER_ENDPOINT = '//adn2.admixer.co.kr:25846/prebid'; const ADMIXER_ENDPOINT = 'https://adn.admixer.co.kr:10443/prebid'; const DEFAULT_BID_TTL = 360; const DEFAULT_CURRENCY = 'USD'; @@ -10,15 +9,13 @@ const DEFAULT_REVENUE = false; export const spec = { code: 'nasmediaAdmixer', - aliases: ['nasmedia_admixer'], - isBidRequestValid: function (bid) { return !!(bid && bid.params && bid.params.ax_key); }, buildRequests: function (validBidRequests) { return validBidRequests.map(bid => { - let adSizes = getSize(bid.sizes); + let adSize = getSize(bid.sizes); return { method: 'GET', @@ -26,8 +23,8 @@ export const spec = { data: { ax_key: utils.getBidIdParameter('ax_key', bid.params), req_id: bid.bidId, - width: adSizes[0], - height: adSizes[1], + width: adSize.width, + height: adSize.height, referrer: utils.getTopWindowUrl(), os: getOsType() } @@ -50,13 +47,11 @@ export const spec = { width: bidData.width, height: bidData.height, currency: bidData.currency ? bidData.currency : DEFAULT_CURRENCY, - netRevenue: bidData.revenue ? bidData.revenue : DEFAULT_REVENUE, - ttl: bidData.ttl ? bidData.ttl : DEFAULT_BID_TTL + netRevenue: DEFAULT_REVENUE, + ttl: DEFAULT_BID_TTL }; bidResponses.push(bidResponse); - } else { - utils.logWarn('nasmediaAdmixer Error' + serverBody.error_msg, 'nasmediaAdmixer') } return bidResponses; } @@ -64,32 +59,23 @@ export const spec = { function getOsType() { let ua = navigator.userAgent.toLowerCase(); + let os = ['android', 'ios', 'mac', 'linux', 'window', 'etc']; + let regexp_os = [/android/i, /iphone|ipad/i, /mac/i, /linux/i, /window/i, '']; - if (ua.match(/android/i)) { - return 'android'; - } else if (ua.match(/iphone/i) || ua.match(/ipad/i)) { - return 'ios'; - } else if (ua.match(/mac/i)) { - return 'mac'; - } else if (ua.match(/linux/i)) { - return 'linux'; - } else if (ua.match(/window/i)) { - return 'window'; - } else { - return 'etc'; - } + return regexp_os.some((tos, idx) => { + if (ua.match(tos)) { + return os[idx]; + } + }); } function getSize(sizes) { - let width = 0; - let height = 0; - if (sizes.length === 2 && typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { - width = sizes[0]; - height = sizes[1]; - } else { - width = sizes[0][0]; - height = sizes[0][1]; - } - return [width, height]; + let parsedSizes = utils.parseSizesInput(sizes); + let [width, height] = parsedSizes.length ? parsedSizes[0].split('x') : []; + + return { + width: parseInt(width, 10), + height: parseInt(height, 10) + }; } registerBidder(spec); diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js index 53369a1a593..7ed65718657 100644 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js @@ -18,7 +18,7 @@ describe('nasmediaAdmixerBidAdapter', () => { 'ax_key': 'ax_key' }, 'adUnitCode': 'adunit-code', - 'sizes': [[320, 480]], + 'sizes': [[300, 250]], 'bidId': '3361d01e67dbd6', 'bidderRequestId': '2b60dcd392628a', 'auctionId': '124cb070528662', @@ -46,7 +46,7 @@ describe('nasmediaAdmixerBidAdapter', () => { 'ax_key': 'ajj7jba3' }, 'adUnitCode': 'adunit-code', - 'sizes': [[320, 480]], + 'sizes': [[300, 250]], 'bidId': '3361d01e67dbd6', 'bidderRequestId': '2b60dcd392628a', 'auctionId': '124cb070528662', @@ -56,7 +56,7 @@ describe('nasmediaAdmixerBidAdapter', () => { it('sends bid request to url via GET', () => { const request = spec.buildRequests(bidRequests)[0]; expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr:10443/prebid`)); + expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr`)); }); }); @@ -69,8 +69,8 @@ describe('nasmediaAdmixerBidAdapter', () => { 'error_msg': 'OK', 'body': [{ 'ad_id': '20049', - 'width': 320, - 'height': 480, + 'width': 300, + 'height': 250, 'currency': 'USD', 'cpm': 1.769221, 'ad': '' @@ -88,7 +88,7 @@ describe('nasmediaAdmixerBidAdapter', () => { 'ax_key': 'ajj7jba3', }, 'adUnitCode': 'adunit-code', - 'sizes': [[320, 480], [300, 250]], + 'sizes': [[300, 250], [320, 480]], 'bidId': '31300c8b9697cd', 'bidderRequestId': '2bf570adcf83fa', 'auctionId': '169827a33f03cc', @@ -100,8 +100,8 @@ describe('nasmediaAdmixerBidAdapter', () => { 'requestId': '861a8e7952c82c', 'cpm': 1.769221, 'currency': 'USD', - 'width': 320, - 'height': 480, + 'width': 300, + 'height': 250, 'ad': '', 'creativeId': '20049', 'ttl': 360, From ef9610863b088c784012f684f2e2f36dd73b61c8 Mon Sep 17 00:00:00 2001 From: cykimh Date: Mon, 19 Feb 2018 14:30:37 +0900 Subject: [PATCH 7/8] update NasmediaAdmixer adapter --- modules/nasmediaAdmixerBidAdapter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js index e4892f3d0ed..344bf991610 100644 --- a/modules/nasmediaAdmixerBidAdapter.js +++ b/modules/nasmediaAdmixerBidAdapter.js @@ -59,14 +59,14 @@ export const spec = { function getOsType() { let ua = navigator.userAgent.toLowerCase(); - let os = ['android', 'ios', 'mac', 'linux', 'window', 'etc']; - let regexp_os = [/android/i, /iphone|ipad/i, /mac/i, /linux/i, /window/i, '']; + let os = ['android', 'ios', 'mac', 'linux', 'window']; + let regexp_os = [/android/i, /iphone|ipad/i, /mac/i, /linux/i, /window/i]; - return regexp_os.some((tos, idx) => { - if (ua.match(tos)) { + return os.find((tos, idx) => { + if (ua.match(regexp_os[idx])) { return os[idx]; } - }); + }) || 'etc'; } function getSize(sizes) { From 7a49b63e464945a609dba18f780df90efeafcb0a Mon Sep 17 00:00:00 2001 From: cykimh Date: Mon, 19 Feb 2018 17:20:27 +0900 Subject: [PATCH 8/8] update NasmediaAdmixer adapter --- modules/nasmediaAdmixerBidAdapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nasmediaAdmixerBidAdapter.md b/modules/nasmediaAdmixerBidAdapter.md index aa72b7967f8..44797e413a8 100644 --- a/modules/nasmediaAdmixerBidAdapter.md +++ b/modules/nasmediaAdmixerBidAdapter.md @@ -1,7 +1,7 @@ # Overview ``` -Module Name: NasmeidaAdmixer Bidder Adapter +Module Name: NasmediaAdmixer Bidder Adapter Module Type: Bidder Adapter Maintainer: prebid@nasmedia.co.kr ```