Skip to content

Commit

Permalink
oneVideo Adapter - Custom Key Value Pair targeting support (SAPR-1547…
Browse files Browse the repository at this point in the history
…8) (#6053)

* Custom key value pair support

* validate values are string or number terary

* validate values are string or number if statement

* custom key value pair unit tests

* restored LiveIntentIdSystem failing unit tests

* keep version 3.0.4

* fix double quotes eslint

* updated md file
  • Loading branch information
adam-browning authored Dec 2, 2020
1 parent 03ed221 commit 6d29360
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/oneVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ function getRequestData(bid, consentData, bidRequest) {
bidData.site.ref = 'https://verizonmedia.com';
bidData.tmax = 1000;
}
if (bid.params.video.custom && Object.prototype.toString.call(bid.params.video.custom) === '[object Object]') {
bidData.imp[0].ext.custom = {};
for (const key in bid.params.video.custom) {
if (typeof bid.params.video.custom[key] === 'string' || typeof bid.params.video.custom[key] === 'number') {
bidData.imp[0].ext.custom[key] = bid.params.video.custom[key];
}
}
}
return bidData;
}

Expand Down
4 changes: 4 additions & 0 deletions modules/oneVideoBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Connects to Verizon Media's Video SSP (AKA ONE Video / Adap.tv) demand source to
inventoryid: 123,
minduration: 10,
maxduration: 30,
custom: {
key1: "value1",
key2: 123345
}
},
site: {
id: 1,
Expand Down
58 changes: 58 additions & 0 deletions test/spec/modules/oneVideoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,64 @@ describe('OneVideoBidAdapter', function () {
const schain = data.source.ext.schain;
expect(schain.nodes[0].hp).to.equal(bidRequest.params.video.hp);
})
it('should not accept key values pairs if custom is Undefined ', function () {
bidRequest.params.video.custom = null;
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].ext.custom).to.be.undefined;
});
it('should not accept key values pairs if custom is Array ', function () {
bidRequest.params.video.custom = [];
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].ext.custom).to.be.undefined;
});
it('should not accept key values pairs if custom is Number ', function () {
bidRequest.params.video.custom = 123456;
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].ext.custom).to.be.undefined;
});
it('should not accept key values pairs if custom is String ', function () {
bidRequest.params.video.custom = 'keyValuePairs';
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].ext.custom).to.be.undefined;
});
it('should not accept key values pairs if custom is Boolean ', function () {
bidRequest.params.video.custom = true;
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].ext.custom).to.be.undefined;
});
it('should accept key values pairs if custom is Object ', function () {
bidRequest.params.video.custom = {};
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].ext.custom).to.be.a('object');
});
it('should accept key values pairs if custom is Object ', function () {
bidRequest.params.video.custom = {
key1: 'value1',
key2: 'value2',
key3: 4444444,
key4: false,
key5: {nested: 'object'},
key6: ['string', 2, true, null],
key7: null,
key8: undefined
};
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const custom = requests[0].data.imp[0].ext.custom;
expect(custom['key1']).to.be.a('string');
expect(custom['key2']).to.be.a('string');
expect(custom['key3']).to.be.a('number');
expect(custom['key4']).to.not.exist;
expect(custom['key5']).to.not.exist;
expect(custom['key6']).to.not.exist;
expect(custom['key7']).to.not.exist;
expect(custom['key8']).to.not.exist;
});
});

describe('spec.interpretResponse', function () {
Expand Down

0 comments on commit 6d29360

Please sign in to comment.