Skip to content

Commit

Permalink
Malltv Bid Adapter : added data object as a param (prebid#6232)
Browse files Browse the repository at this point in the history
* Updated malltv adapter

* Updated markdown

* Added test for malltvBidAdapter
  • Loading branch information
ardit-baloku authored Jan 29, 2021
1 parent 136ad4c commit f613117
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 26 deletions.
7 changes: 5 additions & 2 deletions modules/malltvBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export const spec = {
let bidderRequestId = '';
let url = '';
let contents = [];
let data = {};

let placements = validBidRequests.map(bidRequest => {
if (!propertyId) { propertyId = bidRequest.params.propertyId; }
if (!pageViewGuid && bidRequest.params) { pageViewGuid = bidRequest.params.pageViewGuid || ''; }
if (!storageId && bidRequest.params) { storageId = bidRequest.params.storageId || ''; }
if (!bidderRequestId) { bidderRequestId = bidRequest.bidderRequestId; }
if (!url && bidderRequest) { url = bidderRequest.refererInfo.referer; }
if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents }
if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents; }
if (Object.keys(data).length === 0 && bidRequest.params.data && Object.keys(bidRequest.params.data).length !== 0) { data = bidRequest.params.data; }

let adUnitId = bidRequest.adUnitCode;
let placementId = bidRequest.params.placementId;
Expand All @@ -61,7 +63,8 @@ export const spec = {
url: url,
requestid: bidderRequestId,
placements: placements,
contents: contents
contents: contents,
data: data
}

return [{
Expand Down
63 changes: 43 additions & 20 deletions modules/malltvBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
# Overview
Module Name: MallTV Bidder Adapter Module
Type: Bidder Adapter
Maintainer: [email protected]
Module Name: MallTV Bidder Adapter Module

Type: Bidder Adapter

Maintainer: [email protected]

# Description
MallTV Bidder Adapter for Prebid.js.

# Test Parameters
```js
var adUnits = [
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 300]]
sizes: [
[300, 250],
[300, 300]
]
}
},
bids: [
{
bidder: 'malltv',
params: {
propertyId: '105134',
placementId: '846832'
bids: [{
bidder: 'malltv',
params: {
propertyId: '105134', //Required
placementId: '846832', //Required
data: { //Optional
catalogs: [{
catalogId: 9,
items: ["193", "4", "1"]
}],
inventory: {
category: ["tech"],
query: ["iphone 12"]
}
}
}
]
}]
},
{
code: 'test-div',
mediaTypes: {
video: {
video: {
context: 'instream'
}
}
},
bids: [
{
bidder: 'malltv',
params: {
propertyId: '105134',
placementId: '846841'
bids: [{
bidder: 'malltv',
params: {
propertyId: '105134', //Required
placementId: '846832', //Required
data: { //Optional
catalogs: [{
catalogId: 9,
items: ["193", "4", "1"]
}],
inventory: {
category: ["tech"],
query: ["iphone 12"]
}
}
}
]
}]
}
];
```
30 changes: 26 additions & 4 deletions test/spec/modules/malltvBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ describe('malltvAdapterTest', () => {
it('bidRequest without propertyId or placementId', () => {
expect(spec.isBidRequestValid({
bidder: 'malltv',
params: {
propertyId: '{propertyId}',
}
params: {}
})).to.equal(false);
});
});
Expand All @@ -46,7 +44,17 @@ describe('malltvAdapterTest', () => {
'bidder': 'malltv',
'params': {
'propertyId': '{propertyId}',
'placementId': '{placementId}'
'placementId': '{placementId}',
'data': {
'catalogs': [{
'catalogId': 1,
'items': ['1', '2', '3']
}],
'inventory': {
'category': ['category1', 'category2'],
'query': ['query']
}
}
},
'adUnitCode': 'hb-leaderboard',
'transactionId': 'b6b889bb-776c-48fd-bc7b-d11a1cf0425e',
Expand Down Expand Up @@ -86,6 +94,20 @@ describe('malltvAdapterTest', () => {
expect(requestItem.data.placements[0].sizes).to.equal('300x250');
});
});

it('bidRequest data param', () => {
const requests = spec.buildRequests(bidRequests);
requests.forEach((requestItem) => {
expect(requestItem.data.data).to.exist;
expect(requestItem.data.data.catalogs).to.exist;
expect(requestItem.data.data.inventory).to.exist;
expect(requestItem.data.data.catalogs.length).to.equal(1);
expect(requestItem.data.data.catalogs[0].items.length).to.equal(3);
expect(Object.keys(requestItem.data.data.inventory).length).to.equal(2);
expect(requestItem.data.data.inventory.category.length).to.equal(2);
expect(requestItem.data.data.inventory.query.length).to.equal(1);
});
});
});

describe('interpretResponse', () => {
Expand Down

0 comments on commit f613117

Please sign in to comment.