Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdMatic Bid Adapter: added Video / Banner params #9856

Merged
merged 52 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d49b56a
Admatic Bidder Adaptor
fatihkaya84 Oct 19, 2022
e582645
Update admaticBidAdapter.md
fatihkaya84 Oct 19, 2022
4c4c06a
Update admaticBidAdapter.md
fatihkaya84 Oct 28, 2022
7a23b05
remove floor parameter
fatihkaya84 Oct 31, 2022
7a845b7
Update admaticBidAdapter.js
fatihkaya84 Oct 31, 2022
7a2e0e2
Admatic Bid Adapter: alias and bid floor features activated
fatihkaya84 Nov 4, 2022
de7ac85
Admatic adapter: host param control changed
fatihkaya84 Nov 4, 2022
661c54f
Alias name changed.
fatihkaya84 Nov 4, 2022
42675a0
Revert "Admatic adapter: host param control changed"
fatihkaya84 Nov 4, 2022
6ec8f45
added alias feature and host param
fatihkaya84 Nov 4, 2022
63e1fc6
Revert "added alias feature and host param"
fatihkaya84 Nov 5, 2022
6da6565
Revert "Alias name changed."
fatihkaya84 Nov 5, 2022
549f349
Revert "Admatic Bid Adapter: alias and bid floor features activated"
fatihkaya84 Nov 5, 2022
0b8718e
Revert "Update admaticBidAdapter.js"
fatihkaya84 Nov 5, 2022
e7f6902
Revert "remove floor parameter"
fatihkaya84 Nov 5, 2022
3c797b1
Admatic adapter: host param control && Add new Bidder
fatihkaya84 Nov 5, 2022
f44bbeb
Revert "Admatic adapter: host param control && Add new Bidder"
fatihkaya84 Nov 5, 2022
fb6e36e
Merge branch 'prebid:master' into master
fatihkaya84 Nov 5, 2022
68f2596
commit new features
fatihkaya84 Nov 5, 2022
7fd1f26
Update admaticBidAdapter.js
fatihkaya84 Nov 6, 2022
e883ef6
updated for coverage
fatihkaya84 Nov 12, 2022
6961cae
sync updated
fatihkaya84 Nov 14, 2022
a3b299f
Update adloader.js
fatihkaya84 Nov 14, 2022
84c7b7b
Merge branch 'prebid:master' into master
fatihkaya84 Nov 18, 2022
e254707
AdMatic Bidder: development of user sync url
fatihkaya84 Nov 18, 2022
ba99adf
Update admaticBidAdapter.js
fatihkaya84 Nov 18, 2022
4083ae0
Merge branch 'prebid:master' into master
fatihkaya84 Jan 23, 2023
2fc2b1c
Set currency for AdserverCurrency: bug fix
fatihkaya84 Jan 23, 2023
325d94d
Merge branch 'prebid:master' into master
fatihkaya84 Apr 17, 2023
74f135b
Update admaticBidAdapter.js
fatihkaya84 Apr 17, 2023
e6b1672
update
fatihkaya84 Apr 17, 2023
dcfc9fe
Merge branch 'prebid:master' into master
fatihkaya84 Apr 26, 2023
31e69e8
admatic adapter video params update
fatihkaya84 Apr 26, 2023
60a28ca
Update admaticBidAdapter.js
fatihkaya84 Apr 26, 2023
a5316e7
update
fatihkaya84 Apr 26, 2023
38fd7ab
Update admaticBidAdapter.js
fatihkaya84 Apr 27, 2023
f381a45
update
fatihkaya84 Apr 27, 2023
689ce9d
update
fatihkaya84 Apr 27, 2023
1ca6597
Update admaticBidAdapter_spec.js
fatihkaya84 Apr 27, 2023
b1929ec
Update admaticBidAdapter.js
fatihkaya84 Apr 27, 2023
1216892
Update admaticBidAdapter.js
fatihkaya84 Apr 28, 2023
5d486e3
Revert "Update admaticBidAdapter.js"
fatihkaya84 Apr 28, 2023
473e417
Revert "Update admaticBidAdapter.js"
fatihkaya84 Apr 28, 2023
13b25ff
Revert "Update admaticBidAdapter_spec.js"
fatihkaya84 Apr 28, 2023
93b0e7d
Revert "update"
fatihkaya84 Apr 28, 2023
1c904d1
Revert "update"
fatihkaya84 Apr 28, 2023
c762aeb
Revert "Update admaticBidAdapter.js"
fatihkaya84 Apr 28, 2023
0520e1c
Revert "update"
fatihkaya84 Apr 28, 2023
578c49b
Revert "Update admaticBidAdapter.js"
fatihkaya84 Apr 28, 2023
6b04200
Revert "admatic adapter video params update"
fatihkaya84 Apr 28, 2023
246787c
Merge branch 'prebid:master' into master
fatihkaya84 Apr 28, 2023
941bb03
update
fatihkaya84 Apr 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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