Skip to content

Commit

Permalink
add support for min_height field in pbs native requests (#4434)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored Nov 12, 2019
1 parent 5f2a9fe commit fee78e8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
7 changes: 4 additions & 3 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,11 @@ const OPEN_RTB_PROTOCOL = {
type: imgTypeId,
w: utils.deepAccess(params, 'sizes.0'),
h: utils.deepAccess(params, 'sizes.1'),
wmin: utils.deepAccess(params, 'aspect_ratios.0.min_width')
wmin: utils.deepAccess(params, 'aspect_ratios.0.min_width'),
hmin: utils.deepAccess(params, 'aspect_ratios.0.min_height')
});
if (!(asset.w || asset.wmin)) {
throw 'invalid img sizes (must provided sizes or aspect_ratios)';
if (!((asset.w && asset.h) || (asset.hmin && asset.wmin))) {
throw 'invalid img sizes (must provide sizes or min_height & min_width if using aspect_ratios)';
}
if (Array.isArray(params.aspect_ratios)) {
// pass aspect_ratios as ext data I guess?
Expand Down
35 changes: 34 additions & 1 deletion test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const REQUEST = {
'required': true,
'sizes': [989, 742],
},
'icon': {
'required': true,
'aspect_ratios': [{
'min_height': 10,
'min_width': 10,
'ratio_height': 1,
'ratio_width': 1
}]
},
'sponsoredBy': {
'required': true
}
Expand Down Expand Up @@ -418,14 +427,27 @@ const RESPONSE_OPENRTB_NATIVE = {
}
}
},
{
'id': 2,
'img': {
'url': 'https://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png',
'w': 127,
'h': 83,
'ext': {
'appnexus': {
'prevent_crop': 0
}
}
}
},
{
'id': 0,
'title': {
'text': 'This is a Prebid Native Creative'
}
},
{
'id': 2,
'id': 3,
'data': {
'value': 'Prebid.org'
}
Expand Down Expand Up @@ -829,6 +851,17 @@ describe('S2S Adapter', function () {
'h': 742
}
},
{
'required': 1,
'img': {
'type': 1,
'wmin': 10,
'hmin': 10,
'ext': {
'aspectratios': ['1:1']
}
}
},
{
'required': 1,
'data': {
Expand Down

0 comments on commit fee78e8

Please sign in to comment.