From 1e7dd77f5596b951f838bd33e3fbeef8d682e669 Mon Sep 17 00:00:00 2001 From: naoto0822 Date: Fri, 25 Jan 2019 15:50:58 +0900 Subject: [PATCH 1/4] aja adapter support native format --- modules/ajaBidAdapter.js | 39 ++++++- modules/ajaBidAdapter.md | 32 ++++++ test/spec/modules/ajaBidAdapter_spec.js | 134 ++++++++++++++++++++---- 3 files changed, 181 insertions(+), 24 deletions(-) diff --git a/modules/ajaBidAdapter.js b/modules/ajaBidAdapter.js index 4cbe9a840ea..f729fcce7a8 100644 --- a/modules/ajaBidAdapter.js +++ b/modules/ajaBidAdapter.js @@ -1,7 +1,7 @@ import { Renderer } from '../src/Renderer'; import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; -import { VIDEO, BANNER } from '../src/mediaTypes'; +import { VIDEO, BANNER, NATIVE } from '../src/mediaTypes'; const BIDDER_CODE = 'aja'; const URL = '//ad.as.amanad.adtdp.com/v2/prebid'; @@ -14,7 +14,7 @@ const AD_TYPE = { export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [VIDEO, BANNER], + supportedMediaTypes: [VIDEO, BANNER, NATIVE], isBidRequestValid: function(bid) { return !!(bid.params.asi); @@ -86,6 +86,41 @@ export const spec = { } catch (error) { utils.logError('Error appending tracking pixel', error); } + } else if (AD_TYPE.NATIVE === ad.ad_type) { + const nativeAds = ad.native.template_and_ads.ads; + + nativeAds.forEach(nativeAd => { + const assets = nativeAd.assets; + + Object.assign(bid, { + mediaType: NATIVE + }); + + bid.native = { + title: assets.title, + body: assets.description, + cta: assets.cta_text, + sponsoredBy: assets.sponsor, + clickUrl: encodeURIComponent(assets.lp_link), + impressionTrackers: nativeAd.imps, + }; + + if (assets.img_main !== undefined) { + bid.native.image = { + url: assets.img_main, + width: parseInt(assets.img_main_width, 10), + height: parseInt(assets.img_main_height, 10) + }; + } + + if (assets.img_icon !== undefined) { + bid.native.icon = { + url: assets.img_icon, + width: parseInt(assets.img_icon_width, 10), + height: parseInt(assets.img_icon_height, 10) + }; + } + }); } return [bid]; diff --git a/modules/ajaBidAdapter.md b/modules/ajaBidAdapter.md index 6e513b94ff0..fdfbbb18c61 100644 --- a/modules/ajaBidAdapter.md +++ b/modules/ajaBidAdapter.md @@ -45,6 +45,38 @@ var adUnits = [ asi: 'Kp2O2tFig' } }] + }, + // Native adUnit + { + code: 'prebid_native', + mediaTypes: { + native: { + image: { + required: true + }, + title: { + required: true + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: true + }, + icon: { + required: true + } + } + }, + bids: [{ + bidder: 'aja', + params: { + asi: 'tduu7HBmR' + } + }] } ]; ``` diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 00dafcb7b11..47aaaa77ff3 100644 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ b/test/spec/modules/ajaBidAdapter_spec.js @@ -54,30 +54,31 @@ describe('AjaAdapter', function () { expect(requests[0].method).to.equal('GET'); }); }); - describe('interpretResponse', function () { - let response = { - 'is_ad_return': true, - 'ad': { - 'ad_type': 1, - 'prebid_id': '51ef8751f9aead', - 'price': 12.34, - 'currency': 'USD', - 'creative_id': '123abc', - 'banner': { - 'w': 300, - 'h': 250, - 'tag': '
', - 'imps': [ - '//as.amanad.adtdp.com/v1/imp' - ] - } - }, - 'syncs': [ - 'https://example.com' - ] - }; + describe('interpretResponse', function () { it('should get correct banner bid response', function () { + let response = { + 'is_ad_return': true, + 'ad': { + 'ad_type': 1, + 'prebid_id': '51ef8751f9aead', + 'price': 12.34, + 'currency': 'USD', + 'creative_id': '123abc', + 'banner': { + 'w': 300, + 'h': 250, + 'tag': '
', + 'imps': [ + '//as.amanad.adtdp.com/v1/imp' + ] + } + }, + 'syncs': [ + 'https://example.com' + ] + }; + let expectedResponse = [ { 'requestId': '51ef8751f9aead', @@ -130,6 +131,95 @@ describe('AjaAdapter', function () { expect(result[0]).to.have.property('mediaType', 'video'); }); + it('handles native response', function () { + let response = { + 'is_ad_return': true, + 'ad': { + 'ad_type': 2, + 'prebid_id': '51ef8751f9aead', + 'price': 12.34, + 'currency': 'JPY', + 'creative_id': '123abc', + 'native': { + 'template_and_ads': { + 'head': '', + 'body_wrapper': '', + 'body': '', + 'ads': [ + { + 'ad_format_id': 10, + 'assets': { + 'ad_spot_id': '123abc', + 'index': 0, + 'adchoice_url': 'https://aja-kk.co.jp/optout', + 'cta_text': 'cta', + 'img_icon': 'https://example.com/img_icon', + 'img_icon_width': '50', + 'img_icon_height': '50', + 'img_main': 'https://example.com/img_main', + 'img_main_width': '200', + 'img_main_height': '100', + 'lp_link': 'https://example.com/lp?k=v', + 'sponsor': 'sponsor', + 'title': 'ad_title', + 'description': 'ad_desc' + }, + 'imps': [ + 'https://example.com/imp' + ], + 'inviews': [ + 'https://example.com/inview' + ], + 'jstracker': '', + 'disable_trimming': false + } + ] + } + } + }, + 'syncs': [ + 'https://example.com' + ] + }; + + let expectedResponse = [ + { + 'requestId': '51ef8751f9aead', + 'cpm': 12.34, + 'creativeId': '123abc', + 'dealId': undefined, + 'mediaType': 'native', + 'currency': 'JPY', + 'ttl': 300, + 'netRevenue': true, + 'native': { + 'title': 'ad_title', + 'body': 'ad_desc', + 'cta': 'cta', + 'sponsoredBy': 'sponsor', + 'image': { + 'url': 'https://example.com/img_main', + 'width': 200, + 'height': 100 + }, + 'icon': { + 'url': 'https://example.com/img_icon', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https%3A%2F%2Fexample.com%2Flp%3Fk%3Dv', + 'impressionTrackers': [ + 'https://example.com/imp' + ] + } + } + ]; + + let bidderRequest; + let result = spec.interpretResponse({ body: response }, {bidderRequest}) + expect(result).to.deep.equal(expectedResponse) + }); + it('handles nobid responses', function () { let response = { 'is_ad_return': false, From ea3a69132d34d3ebc761d2a24db66717c3a58056 Mon Sep 17 00:00:00 2001 From: naoto0822 Date: Mon, 4 Feb 2019 14:37:42 +0900 Subject: [PATCH 2/4] not encode lp link --- modules/ajaBidAdapter.js | 2 +- test/spec/modules/ajaBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ajaBidAdapter.js b/modules/ajaBidAdapter.js index f729fcce7a8..5b826d1e725 100644 --- a/modules/ajaBidAdapter.js +++ b/modules/ajaBidAdapter.js @@ -101,7 +101,7 @@ export const spec = { body: assets.description, cta: assets.cta_text, sponsoredBy: assets.sponsor, - clickUrl: encodeURIComponent(assets.lp_link), + clickUrl: assets.lp_link, impressionTrackers: nativeAd.imps, }; diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 47aaaa77ff3..7539848d5bd 100644 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ b/test/spec/modules/ajaBidAdapter_spec.js @@ -207,7 +207,7 @@ describe('AjaAdapter', function () { 'width': 50, 'height': 50 }, - 'clickUrl': 'https%3A%2F%2Fexample.com%2Flp%3Fk%3Dv', + 'clickUrl': 'https://example.com/lp?k=v', 'impressionTrackers': [ 'https://example.com/imp' ] From 2862bd7bd2e79bc7a4b93b80fc4bcb7f04824589 Mon Sep 17 00:00:00 2001 From: naoto0822 Date: Thu, 7 Feb 2019 16:56:43 +0900 Subject: [PATCH 3/4] update adapter md --- modules/ajaBidAdapter.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/ajaBidAdapter.md b/modules/ajaBidAdapter.md index fdfbbb18c61..f948dbe6cdf 100644 --- a/modules/ajaBidAdapter.md +++ b/modules/ajaBidAdapter.md @@ -11,11 +11,11 @@ Connects to Aja exchange for bids. Aja bid adapter supports Banner and Outstream Video. # Test Parameters -``` +```js var adUnits = [ // Banner adUnit { - code: 'banner-div', + code: 'prebid_banner', mediaTypes: { banner: { sizes: [ @@ -26,13 +26,13 @@ var adUnits = [ bids: [{ bidder: 'aja', params: { - asi: 'szs4htFiR' + asi: 'tk82gbLmg' } }] }, // Video outstream adUnit { - code: 'video-outstream', + code: 'prebid_video', mediaTypes: { video: { context: 'outstream', @@ -42,7 +42,7 @@ var adUnits = [ bids: [{ bidder: 'aja', params: { - asi: 'Kp2O2tFig' + asi: '1-KwEG_iR' } }] }, @@ -52,29 +52,29 @@ var adUnits = [ mediaTypes: { native: { image: { - required: true + required: true }, title: { - required: true + required: true }, sponsoredBy: { - required: true + required: false }, clickUrl: { - required: true + required: false }, body: { - required: true + required: false }, icon: { - required: true + required: false } } }, bids: [{ bidder: 'aja', params: { - asi: 'tduu7HBmR' + asi: 'qxueUGliR' } }] } From 9fd646b1ea937842604ef9910df3beb16cdb3a4c Mon Sep 17 00:00:00 2001 From: naoto0822 Date: Mon, 4 Mar 2019 16:51:07 +0900 Subject: [PATCH 4/4] update aja adaptor md --- modules/ajaBidAdapter.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/ajaBidAdapter.md b/modules/ajaBidAdapter.md index f948dbe6cdf..4f5aa7074cb 100644 --- a/modules/ajaBidAdapter.md +++ b/modules/ajaBidAdapter.md @@ -52,22 +52,28 @@ var adUnits = [ mediaTypes: { native: { image: { - required: true + required: true, + sendId: false }, title: { - required: true + required: true, + sendId: true }, sponsoredBy: { - required: false + required: false, + sendId: true }, clickUrl: { - required: false + required: false, + sendId: true }, body: { - required: false + required: false, + sendId: true }, icon: { - required: false + required: false, + sendId: false } } },