Skip to content

Commit

Permalink
TheMediaGrid Bid Adapter: added support genre and cat from config ort…
Browse files Browse the repository at this point in the history
…b2.site (#8041)

* TheMediaGrid: added support genre and cat from config ortb2.site

* TheMediaGrid: fix bug with possible undefined cat or pagecat
  • Loading branch information
TheMediaGrid authored Mar 2, 2022
1 parent efbeaf0 commit 688d0b9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ export const spec = {
request.regs.coppa = 1;
}

const site = config.getConfig('ortb2.site');
if (site) {
const pageCategory = [...(site.cat || []), ...(site.pagecat || [])].filter((category) => {
return category && typeof category === 'string'
});
if (pageCategory.length) {
request.site.cat = pageCategory;
}
const genre = deepAccess(site, 'content.genre');
if (genre && typeof genre === 'string') {
request.site.content = {...request.site.content, genre};
}
}

return {
method: 'POST',
url: ENDPOINT_URL,
Expand Down
18 changes: 18 additions & 0 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ describe('TheMediaGrid Adapter', function () {
}
];

it('should be content categories and genre', function () {
const site = {
cat: ['IAB2'],
pagecat: ['IAB2-2'],
content: {
genre: 'Adventure'
}
};

const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
arg => arg === 'ortb2.site' ? site : null);
const request = spec.buildRequests([bidRequests[0]], bidderRequest);
const payload = parseRequest(request.data);
expect(payload.site.cat).to.deep.equal([...site.cat, ...site.pagecat]);
expect(payload.site.content.genre).to.deep.equal(site.content.genre);
getConfigStub.restore();
});

it('should attach valid params to the tag', function () {
const fpdUserIdVal = '0b0f84a1-1596-4165-9742-2e1a7dfac57f';
const getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(
Expand Down

0 comments on commit 688d0b9

Please sign in to comment.