From ea56cd2173e6c3a15c1d035628c392e843169e83 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 10 Mar 2021 12:22:54 +0100 Subject: [PATCH 1/3] replace shrorthand "image" native type --- modules/adyoulikeBidAdapter.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index e5777f1e627..026c4192ec6 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -8,6 +8,30 @@ const VERSION = '1.0'; const BIDDER_CODE = 'adyoulike'; const DEFAULT_DC = 'hb-api'; +const NATIVE_IMAGE = { + image: { + required: true + }, + title: { + required: true + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: false + }, + icon: { + required: false + }, + cta: { + required: false + } +}; + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, NATIVE], @@ -44,7 +68,13 @@ export const spec = { accumulator[bid.bidId].Width = size.width; accumulator[bid.bidId].Height = size.height; accumulator[bid.bidId].AvailableSizes = sizesArray.join(','); - if (bid.mediaTypes && bid.mediaTypes.native) accumulator[bid.bidId].Native = bid.mediaTypes.native; + if (bid.mediaTypes && bid.mediaTypes.native) { + let nativeReq = bid.mediaTypes.native; + if (nativeReq.type === 'image') { + nativeReq = NATIVE_IMAGE; + } + accumulator[bid.bidId].Native = nativeReq; + } return accumulator; }, {}), PageRefreshed: getPageRefreshed() From 26a0d8653de0cf6be22a1a5656c6902645d8ee10 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Mar 2021 11:26:42 +0100 Subject: [PATCH 2/3] merge publisher native config with image type config --- modules/adyoulikeBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 026c4192ec6..e46a9b6bed2 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -71,7 +71,7 @@ export const spec = { if (bid.mediaTypes && bid.mediaTypes.native) { let nativeReq = bid.mediaTypes.native; if (nativeReq.type === 'image') { - nativeReq = NATIVE_IMAGE; + nativeReq = Object.assign({}, NATIVE_IMAGE, nativeReq); } accumulator[bid.bidId].Native = nativeReq; } From cf503d294790b44f76fa8ee0b259e55003f9692d Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 18 Mar 2021 16:24:07 +0100 Subject: [PATCH 3/3] add unit tests on native image config type --- test/spec/modules/adyoulikeBidAdapter_spec.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 4c108ed9f1d..8f60cbbbe3e 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -95,6 +95,29 @@ describe('Adyoulike Adapter', function () { } ]; + const bidRequestWithNativeImageType = [ + { + 'bidId': 'bid_id_0', + 'bidder': 'adyoulike', + 'placementCode': 'adunit/hb-0', + 'params': { + 'placement': 'placement_0' + }, + 'sizes': '300x250', + 'mediaTypes': + { + 'native': { + 'type': 'image', + 'additional': { + 'will': 'be', + 'sent': ['300x250'] + } + }, + }, + 'transactionId': 'bid_id_0_transaction_id' + } + ]; + const sentBidNative = { 'bid_id_0': { 'PlacementID': 'e622af275681965d3095808561a1e510', @@ -135,6 +158,37 @@ describe('Adyoulike Adapter', function () { } }; + const sentNativeImageType = { + 'additional': { + 'sent': [ + '300x250' + ], + 'will': 'be' + }, + 'body': { + 'required': false + }, + 'clickUrl': { + 'required': true + }, + 'cta': { + 'required': false + }, + 'icon': { + 'required': false + }, + 'image': { + 'required': true + }, + 'sponsoredBy': { + 'required': true + }, + 'title': { + 'required': true + }, + 'type': 'image' + }; + const bidRequestWithDCPlacement = [ { 'bidId': 'bid_id_0', @@ -341,6 +395,23 @@ describe('Adyoulike Adapter', function () { canonicalQuery.restore(); }); + it('Should expand short native image config type', function() { + const request = spec.buildRequests(bidRequestWithNativeImageType, bidderRequest); + const payload = JSON.parse(request.data); + + expect(request.url).to.contain(getEndpoint()); + expect(request.method).to.equal('POST'); + expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); + expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); + expect(request.url).to.contains('PublisherDomain=http%3A%2F%2Flocalhost%3A9876'); + + expect(payload.Version).to.equal('1.0'); + expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); + expect(payload.PageRefreshed).to.equal(false); + expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id'); + expect(payload.Bids['bid_id_0'].Native).deep.equal(sentNativeImageType); + }); + it('should add gdpr/usp consent information to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let uspConsentData = '1YCC';