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

oneVideo Adapter - Custom Key Value Pair targeting support (SAPR-15478) #6053

Merged
merged 9 commits into from
Dec 2, 2020
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
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]') {
adam-browning marked this conversation as resolved.
Show resolved Hide resolved
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