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

Malltv Bid Adapter : added data object as a param #6232

Merged
merged 3 commits into from Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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: drilon@gjirafa.com
Module Name: MallTV Bidder Adapter Module

Type: Bidder Adapter

Maintainer: arditb@gjirafa.com

# 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