Skip to content

Commit

Permalink
AdMatic Bid Adapter: added Video / Banner params (#9856)
Browse files Browse the repository at this point in the history
* Admatic Bidder Adaptor

* Update admaticBidAdapter.md

* Update admaticBidAdapter.md

* remove floor parameter

* Update admaticBidAdapter.js

* Admatic Bid Adapter: alias and bid floor features activated

* Admatic adapter: host param control changed

* Alias name changed.

* Revert "Admatic adapter: host param control changed"

This reverts commit de7ac85.

* added alias feature and host param

* Revert "added alias feature and host param"

This reverts commit 6ec8f45.

* Revert "Alias name changed."

This reverts commit 661c54f.

* Revert "Admatic Bid Adapter: alias and bid floor features activated"

This reverts commit 7a2e0e2.

* Revert "Update admaticBidAdapter.js"

This reverts commit 7a845b7.

* Revert "remove floor parameter"

This reverts commit 7a23b05.

* Admatic adapter: host param control && Add new Bidder

* Revert "Admatic adapter: host param control && Add new Bidder"

This reverts commit 3c797b1.

* commit new features

* Update admaticBidAdapter.js

* updated for coverage

* sync updated

* Update adloader.js

* AdMatic Bidder: development of user sync url

* Update admaticBidAdapter.js

* Set currency for AdserverCurrency: bug fix

* Update admaticBidAdapter.js

* update

* admatic adapter video params update

* Update admaticBidAdapter.js

* update

* Update admaticBidAdapter.js

* update

* update

* Update admaticBidAdapter_spec.js

* Update admaticBidAdapter.js

* Update admaticBidAdapter.js

* Revert "Update admaticBidAdapter.js"

This reverts commit 1216892.

* Revert "Update admaticBidAdapter.js"

This reverts commit b1929ec.

* Revert "Update admaticBidAdapter_spec.js"

This reverts commit 1ca6597.

* Revert "update"

This reverts commit 689ce9d.

* Revert "update"

This reverts commit f381a45.

* Revert "Update admaticBidAdapter.js"

This reverts commit 38fd7ab.

* Revert "update"

This reverts commit a5316e7.

* Revert "Update admaticBidAdapter.js"

This reverts commit 60a28ca.

* Revert "admatic adapter video params update"

This reverts commit 31e69e8.

* update
  • Loading branch information
fatihkaya84 authored May 1, 2023
1 parent 1ac3572 commit 0cf7c75
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 16 deletions.
37 changes: 32 additions & 5 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const spec = {
*/
buildRequests: (validBidRequests, bidderRequest) => {
const bids = validBidRequests.map(buildRequestObject);
const blacklist = bidderRequest.ortb2 || {};
const blacklist = bidderRequest.ortb2;
const networkId = getValue(validBidRequests[0].params, 'networkId');
const host = getValue(validBidRequests[0].params, 'host');
const currency = config.getConfig('currency.adServerCurrency') || 'TRY';
Expand Down Expand Up @@ -93,7 +93,7 @@ export const spec = {
* @return {Bid[]}
*/
interpretResponse: (response, request) => {
const body = response.body || response;
const body = response.body;
const bidResponses = [];
if (body && body?.data && isArray(body.data)) {
body.data.forEach(bid => {
Expand All @@ -104,13 +104,23 @@ export const spec = {
height: bid.height,
currency: body.cur || 'TRY',
netRevenue: true,
ad: bid.party_tag,
creativeId: bid.creative_id,
meta: {
advertiserDomains: bid && bid.adomain ? bid.adomain : []
},
ttl: 360,
bidder: bid.bidder
bidder: bid.bidder,
mediaType: bid.type,
ttl: 60
};

if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) {
resbid.vastUrl = bid.party_tag;
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'video') {
resbid.vastXml = bid.party_tag;
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'banner') {
resbid.ad = bid.party_tag;
};

bidResponses.push(resbid);
Expand All @@ -120,6 +130,15 @@ export const spec = {
}
};

function isUrl(str) {
try {
URL(str);
return true;
} catch (error) {
return false;
}
};

function enrichSlotWithFloors(slot, bidRequest) {
try {
const slotFloors = {};
Expand Down Expand Up @@ -168,6 +187,14 @@ function parseSize(size) {
function buildRequestObject(bid) {
const reqObj = {};
reqObj.size = getSizes(bid);
if (bid.mediaTypes?.banner) {
reqObj.type = 'banner';
reqObj.mediatype = {};
}
if (bid.mediaTypes?.video) {
reqObj.type = 'video';
reqObj.mediatype = bid.mediaTypes.video;
}
reqObj.id = getBidIdParameter('bidId', bid);

enrichSlotWithFloors(reqObj, bid);
Expand Down
175 changes: 164 additions & 11 deletions test/spec/modules/admaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,25 @@ describe('admaticBidAdapter', () => {
'host': 'layer.serve.admatic.com.tr'
},
'adUnitCode': 'adunit-code',
'mediaType': 'banner',
'sizes': [[300, 250], [300, 600]],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'creativeId': 'er2ee'
'creativeId': 'er2ee',
'ortb2': { 'badv': ['admatic.com.tr'] }
};

it('should return true when required params found', function() {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});

it('should return false when required params are not passed', function() {
let bid = Object.assign({}, bid);
delete bid.params;

bid.params = {
'networkId': 0,
'host': 'layer.serve.admatic.com.tr'
let bid2 = {};
bid2.params = {
'someIncorrectParam': 0
};

expect(spec.isBidRequestValid(bid)).to.equal(false);
expect(spec.isBidRequestValid(bid2)).to.equal(false);
});
});

Expand All @@ -54,6 +52,7 @@ describe('admaticBidAdapter', () => {
'networkId': 10433394,
'host': 'layer.serve.admatic.com.tr'
},
'ortb2': { 'badv': ['admatic.com.tr'] },
'mediaTypes': {
'banner': {
'sizes': [[300, 250], [728, 90]]
Expand Down Expand Up @@ -98,13 +97,58 @@ describe('admaticBidAdapter', () => {
'h': 90
}
],
'mediatype': {},
'type': 'banner',
'id': '2205da7a81846b',
'floors': {
'banner': {
'300x250': { 'currency': 'USD', 'floor': 1 },
'728x90': { 'currency': 'USD', 'floor': 2 }
}
}
},
{
'size': [
{
'w': 338,
'h': 280
}
],
'type': 'video',
'mediatype': {
'context': 'instream',
'mimes': [
'video/mp4'
],
'maxduration': 240,
'api': [
1,
2
],
'playerSize': [
[
338,
280
]
],
'protocols': [
1,
2,
3,
4,
5,
6,
7,
8
],
'skip': 1,
'playbackmethod': [
2
],
'linearity': 1,
'placement': 2
},
'id': '45e86fc7ce7fc93'
}
],
'ext': {
Expand All @@ -118,6 +162,7 @@ describe('admaticBidAdapter', () => {
'networkId': 10433394,
'host': 'layer.serve.admatic.com.tr'
},
'ortb2': { 'badv': ['admatic.com.tr'] },
'mediaTypes': {
'banner': {
'sizes': [[300, 250], [728, 90]]
Expand Down Expand Up @@ -163,12 +208,57 @@ describe('admaticBidAdapter', () => {
}
],
'id': '2205da7a81846b',
'mediatype': {},
'type': 'banner',
'floors': {
'banner': {
'300x250': { 'currency': 'USD', 'floor': 1 },
'728x90': { 'currency': 'USD', 'floor': 2 }
}
}
},
{
'size': [
{
'w': 338,
'h': 280
}
],
'type': 'video',
'mediatype': {
'context': 'instream',
'mimes': [
'video/mp4'
],
'maxduration': 240,
'api': [
1,
2
],
'playerSize': [
[
338,
280
]
],
'protocols': [
1,
2,
3,
4,
5,
6,
7,
8
],
'skip': 1,
'playbackmethod': [
2
],
'linearity': 1,
'placement': 2
},
'id': '45e86fc7ce7fc93'
}
],
'ext': {
Expand All @@ -194,6 +284,7 @@ describe('admaticBidAdapter', () => {
'sizes': [[300, 250], [728, 90]]
}
},
'ortb2': { 'badv': ['admatic.com.tr'] },
getFloor: inputParams => {
if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
return {
Expand All @@ -217,6 +308,7 @@ describe('admaticBidAdapter', () => {
'networkId': 10433394,
'host': 'layer.serve.admatic.com.tr'
},
'ortb2': { 'badv': ['admatic.com.tr'] },
'adUnitCode': 'adunit-code',
'sizes': [[300, 250], [728, 90]],
'bidId': '30b31c1838de1e',
Expand Down Expand Up @@ -249,9 +341,35 @@ describe('admaticBidAdapter', () => {
'width': 300,
'height': 250,
'price': 0.01,
'type': 'banner',
'bidder': 'admatic',
'adomain': ['admatic.com.tr'],
'party_tag': '<div></div>'
'party_tag': '<div></div>',
'iurl': 'https://www.admatic.com.tr'
},
{
'id': 2,
'creative_id': '3741',
'width': 300,
'height': 250,
'price': 0.01,
'type': 'video',
'bidder': 'admatic',
'adomain': ['admatic.com.tr'],
'party_tag': '<VAST></VAST>',
'iurl': 'https://www.admatic.com.tr'
},
{
'id': 3,
'creative_id': '3741',
'width': 300,
'height': 250,
'price': 0.01,
'type': 'video',
'bidder': 'admatic',
'adomain': ['admatic.com.tr'],
'party_tag': 'https://www.admatic.com.tr',
'iurl': 'https://www.admatic.com.tr'
}
],
'queryId': 'cdnbh24rlv0hhkpfpln0',
Expand All @@ -265,13 +383,48 @@ describe('admaticBidAdapter', () => {
width: 300,
height: 250,
currency: 'TRY',
mediaType: 'banner',
netRevenue: true,
ad: '<div></div>',
creativeId: '374',
meta: {
advertiserDomains: ['admatic.com.tr']
},
ttl: 360,
ttl: 60,
bidder: 'admatic'
},
{
requestId: 2,
cpm: 0.01,
width: 300,
height: 250,
currency: 'TRY',
mediaType: 'video',
netRevenue: true,
vastImpUrl: 'https://www.admatic.com.tr',
vastXml: '<VAST></VAST>',
creativeId: '3741',
meta: {
advertiserDomains: ['admatic.com.tr']
},
ttl: 60,
bidder: 'admatic'
},
{
requestId: 3,
cpm: 0.01,
width: 300,
height: 250,
currency: 'TRY',
mediaType: 'video',
netRevenue: true,
vastImpUrl: 'https://www.admatic.com.tr',
vastXml: 'https://www.admatic.com.tr',
creativeId: '3741',
meta: {
advertiserDomains: ['admatic.com.tr']
},
ttl: 60,
bidder: 'admatic'
}
];
Expand Down

0 comments on commit 0cf7c75

Please sign in to comment.