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

Gjirafa Bid Adapter: added data object as a param #6231

Merged
merged 3 commits into from Feb 3, 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/gjirafaBidAdapter.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
62 changes: 42 additions & 20 deletions modules/gjirafaBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,67 @@
# Overview
Module Name: Gjirafa Bidder Adapter Module
Type: Bidder Adapter
Maintainer: [email protected]
Module Name: Gjirafa Bidder Adapter Module

Type: Bidder Adapter

Maintainer: [email protected]

# Description
Gjirafa Bidder Adapter for Prebid.js.

# Test Parameters
```js
var adUnits = [
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[728, 90]]
sizes: [
[728, 90]
]
}
},
bids: [
{
bidder: 'gjirafa',
params: {
propertyId: '105227',
placementId: '846841'
bids: [{
bidder: 'gjirafa',
params: {
propertyId: '105227', //Required
placementId: '846841', //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: 'gjirafa',
params: {
propertyId: '105227',
placementId: '846836'
bids: [{
bidder: 'gjirafa',
params: {
propertyId: '105227', //Required
placementId: '846836', //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/gjirafaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ describe('gjirafaAdapterTest', () => {
it('bidRequest without propertyId or placementId', () => {
expect(spec.isBidRequestValid({
bidder: 'gjirafa',
params: {
propertyId: '{propertyId}',
}
params: {}
})).to.equal(false);
});
});
Expand All @@ -46,7 +44,17 @@ describe('gjirafaAdapterTest', () => {
'bidder': 'gjirafa',
'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('gjirafaAdapterTest', () => {
expect(requestItem.data.placements[0].sizes).to.equal('728x90');
});
});

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