Skip to content

Commit

Permalink
Frank fpd issue (prebid#3455)
Browse files Browse the repository at this point in the history
* Changing to requestId in order to align with prebid cores mapping of bidId to responseId

* Rubi Bid Adapter: Do not pass non-array FPD to Frank Video

* Updating based on review + tests
  • Loading branch information
robertrmartinez authored and Pedro López Jiménez committed Mar 18, 2019
1 parent 90024c1 commit 3e000a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
22 changes: 15 additions & 7 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,26 @@ export const spec = {
slotData.language = params.video.language;
}

if (params.inventory && typeof params.inventory === 'object') {
slotData.inventory = params.inventory;
}
// Add visitor and inventory FPD values
// Frank expects the vales in each inventory and visitor fpd to be an array. so params.inventory.something === [] of some sort, otherwise it 400s
['inventory', 'visitor'].forEach(function(key) {
if (params[key] && typeof params[key] === 'object') {
slotData[key] = {};
Object.keys(params[key]).forEach(function(fpdKey) {
let value = params[key][fpdKey];
if (Array.isArray(value)) {
slotData[key][fpdKey] = value;
} else if ((typeof value === 'string' && value !== '') || typeof value === 'number') {
slotData[key][fpdKey] = [value];
}
});
}
});

if (params.keywords && Array.isArray(params.keywords)) {
slotData.keywords = params.keywords;
}

if (params.visitor && typeof params.visitor === 'object') {
slotData.visitor = params.visitor;
}

data.slots.push(slotData);

if (bidderRequest.gdprConsent) {
Expand Down
14 changes: 7 additions & 7 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe('the rubicon adapter', function () {
userId: '12346',
keywords: ['a', 'b', 'c'],
inventory: {
rating: '5-star',
rating: '5-star', // This actually should not be sent to frank!! causes 400
prodtype: ['tech', 'mobile']
},
visitor: {
Expand Down Expand Up @@ -1146,7 +1146,7 @@ describe('the rubicon adapter', function () {
expect(slot.size_id).to.equal(201);

expect(slot).to.have.property('inventory').that.is.an('object');
expect(slot.inventory).to.have.property('rating').that.equals('5-star');
expect(slot.inventory).to.have.property('rating').that.deep.equals(['5-star']);
expect(slot.inventory).to.have.property('prodtype').that.deep.equals(['tech', 'mobile']);

expect(slot).to.have.property('keywords')
Expand All @@ -1155,8 +1155,8 @@ describe('the rubicon adapter', function () {
.that.deep.equals(['a', 'b', 'c']);

expect(slot).to.have.property('visitor').that.is.an('object');
expect(slot.visitor).to.have.property('ucat').that.equals('new');
expect(slot.visitor).to.have.property('lastsearch').that.equals('iphone');
expect(slot.visitor).to.have.property('ucat').that.deep.equals(['new']);
expect(slot.visitor).to.have.property('lastsearch').that.deep.equals(['iphone']);
expect(slot.visitor).to.have.property('likes').that.deep.equals(['sports', 'video games']);
});

Expand Down Expand Up @@ -1210,7 +1210,7 @@ describe('the rubicon adapter', function () {
expect(slot.size_id).to.equal(201);

expect(slot).to.have.property('inventory').that.is.an('object');
expect(slot.inventory).to.have.property('rating').that.equals('5-star');
expect(slot.inventory).to.have.property('rating').that.deep.equals(['5-star']);
expect(slot.inventory).to.have.property('prodtype').that.deep.equals(['tech', 'mobile']);

expect(slot).to.have.property('keywords')
Expand All @@ -1219,8 +1219,8 @@ describe('the rubicon adapter', function () {
.that.deep.equals(['a', 'b', 'c']);

expect(slot).to.have.property('visitor').that.is.an('object');
expect(slot.visitor).to.have.property('ucat').that.equals('new');
expect(slot.visitor).to.have.property('lastsearch').that.equals('iphone');
expect(slot.visitor).to.have.property('ucat').that.deep.equals(['new']);
expect(slot.visitor).to.have.property('lastsearch').that.deep.equals(['iphone']);
expect(slot.visitor).to.have.property('likes').that.deep.equals(['sports', 'video games']);
});

Expand Down

0 comments on commit 3e000a7

Please sign in to comment.