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

AdYouLike bidder adapter: handle size given in bid params #7198

Merged
merged 19 commits into from
Jul 23, 2021
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
11 changes: 10 additions & 1 deletion modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const spec = {
const sizes = getSize(getSizeArray(bid));
const sizeValid = sizes.width > 0 && sizes.height > 0;

// allows no size fornative only
// allows no size for native only
return (bid.params && bid.params.placement &&
(sizeValid || (bid.mediaTypes && bid.mediaTypes.native)));
},
Expand Down Expand Up @@ -242,10 +242,19 @@ function createEndpointQS(bidderRequest) {

function getSizeArray(bid) {
let inputSize = bid.sizes || [];

if (bid.mediaTypes && bid.mediaTypes.banner) {
inputSize = bid.mediaTypes.banner.sizes || [];
}

// handle size in bid.params in formats: [w, h] and [[w,h]].
if (bid.params && Array.isArray(bid.params.size)) {
inputSize = bid.params.size;
if (!Array.isArray(inputSize[0])) {
inputSize = [inputSize]
}
}

return utils.parseSizesInput(inputSize);
}

Expand Down
15 changes: 15 additions & 0 deletions test/spec/modules/adyoulikeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ describe('Adyoulike Adapter', function () {
'transactionId': 'bid_id_1_transaction_id'
};

let bidWSize = {
'bidId': 'bid_id_1',
'bidder': 'adyoulike',
'placementCode': 'adunit/hb-1',
'params': {
'placement': 'placement_1',
'size': [250, 300],
},
'transactionId': 'bid_id_1_transaction_id'
};

let nativeBid = {
'bidId': 'bid_id_1',
'bidder': 'adyoulike',
Expand All @@ -441,6 +452,10 @@ describe('Adyoulike Adapter', function () {
expect(!!spec.isBidRequestValid(bid)).to.equal(true);
});

it('should return true when required params found with size in bid params', function () {
expect(!!spec.isBidRequestValid(bidWSize)).to.equal(true);
});

it('should return true when required params found for native ad', function () {
expect(!!spec.isBidRequestValid(nativeBid)).to.equal(true);
});
Expand Down