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

Add bidFloor to Yieldmo Adapter #3886

Merged
merged 10 commits into from
Jun 13, 2019
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
28 changes: 17 additions & 11 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ export const spec = {

bidRequests.forEach((request) => {
serverRequest.p.push(addPlacement(request));
const userId = getUserId(request)
if (userId) {
const pubcid = userId.pubcid;
const pubcid = getPubcId(request)
if (pubcid) {
serverRequest.pubcid = pubcid;
} else if (request.crumbs) {
serverRequest.pubcid = request.crumbs.pubcid;
if (request.crumbs.pubcid) {
serverRequest.pubcid = request.crumbs.pubcid;
}
}
});
serverRequest.p = '[' + serverRequest.p.toString() + ']';
Expand Down Expand Up @@ -103,8 +104,13 @@ function addPlacement(request) {
callback_id: request.bidId,
sizes: request.sizes
}
if (request.params && request.params.placementId) {
placementInfo.ym_placement_id = request.params.placementId
if (request.params) {
if (request.params.placementId) {
placementInfo.ym_placement_id = request.params.placementId;
}
if (request.params.bidFloor) {
placementInfo.bidFloor = request.params.bidFloor;
}
}
return JSON.stringify(placementInfo);
}
Expand Down Expand Up @@ -311,10 +317,10 @@ function isMraid() {
return !!(window.mraid);
}

function getUserId(request) {
let userId;
if (request && request.userId && typeof request.userId === 'object') {
userId = request.userId;
function getPubcId(request) {
let pubcid;
if (request && request.userId && request.userId.pubcid && typeof request.userId === 'object') {
HolzAndrew marked this conversation as resolved.
Show resolved Hide resolved
pubcid = request.userId.pubcid;
}
return userId;
return pubcid;
}
3 changes: 2 additions & 1 deletion modules/yieldmoBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var adUnits = [
bids: [{
bidder: 'yieldmo',
params: {
placementId: '1779781193098233305' // string with at most 19 characters (may include numbers only)
placementId: '1779781193098233305', // string with at most 19 characters (may include numbers only)
bidFloor: .28 // optional param
HolzAndrew marked this conversation as resolved.
Show resolved Hide resolved
}
}]
}
Expand Down
21 changes: 13 additions & 8 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ describe('YieldmoAdapter', function () {

let bid = {
bidder: 'yieldmo',
params: {},
params: {
bidFloor: 0.1
},
adUnitCode: 'adunit-code',
sizes: [[300, 250], [300, 600]],
bidId: '30b31c1838de1e',
Expand Down Expand Up @@ -59,11 +61,13 @@ describe('YieldmoAdapter', function () {

it('should place bid information into the p parameter of data', function () {
let placementInfo = spec.buildRequests(bidArray).data.p;
expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]]}]');
expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]');

bidArray.push({
bidder: 'yieldmo',
params: {},
params: {
bidFloor: 0.2
},
adUnitCode: 'adunit-code-1',
sizes: [[300, 250], [300, 600]],
bidId: '123456789',
Expand All @@ -77,19 +81,19 @@ describe('YieldmoAdapter', function () {

// multiple placements
placementInfo = spec.buildRequests(bidArray).data.p;
expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]]},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]]}]');
expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]');
});

it('should add placement id if given', function () {
bidArray[0].params.placementId = 'ym_1293871298';
let placementInfo = spec.buildRequests(bidArray).data.p;
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"}');
expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"}');
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"');
expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"');

bidArray[1].params.placementId = 'ym_0987654321';
placementInfo = spec.buildRequests(bidArray).data.p;
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"}');
expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"}');
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"');
expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"');
});

it('should add additional information to data parameter of request', function () {
Expand All @@ -104,6 +108,7 @@ describe('YieldmoAdapter', function () {
expect(data.hasOwnProperty('title')).to.be.true;
expect(data.hasOwnProperty('h')).to.be.true;
expect(data.hasOwnProperty('w')).to.be.true;
expect(data.hasOwnProperty('pubcid')).to.be.true;
})

it('should add pubcid as parameter of request', function () {
Expand Down