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

Expose native image-type asset dimensions on bid response object #1919

Merged
merged 2 commits into from
Dec 6, 2017
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
12 changes: 10 additions & 2 deletions modules/appnexusAstBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,16 @@ function newBid(serverBid, rtbBid) {
body: nativeAd.desc,
cta: nativeAd.ctatext,
sponsoredBy: nativeAd.sponsored,
image: nativeAd.main_img && nativeAd.main_img.url,
icon: nativeAd.icon && nativeAd.icon.url,
image: {
url: nativeAd.main_img && nativeAd.main_img.url,
height: nativeAd.main_img && nativeAd.main_img.height,
width: nativeAd.main_img && nativeAd.main_img.width,
},
icon: {
url: nativeAd.icon && nativeAd.icon.url,
height: nativeAd.icon && nativeAd.icon.height,
width: nativeAd.icon && nativeAd.icon.width,
},
clickUrl: nativeAd.link.url,
clickTrackers: nativeAd.link.click_trackers,
impressionTrackers: nativeAd.impression_trackers,
Expand Down
8 changes: 7 additions & 1 deletion src/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ export function getNativeTargeting(bid) {

Object.keys(bid['native']).forEach(asset => {
const key = NATIVE_KEYS[asset];
const value = bid['native'][asset];
let value = bid['native'][asset];

// native image-type assets can be a string or an object with a url prop
if (typeof value === 'object' && value.url) {
value = value.url;
}

if (key) {
keyValues[key] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/appnexusAstBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ describe('AppNexusAdapter', () => {
expect(result[0].native.title).to.equal('Native Creative');
expect(result[0].native.body).to.equal('Cool description great stuff');
expect(result[0].native.cta).to.equal('Do it');
expect(result[0].native.image).to.equal('http://cdn.adnxs.com/img.png');
expect(result[0].native.image.url).to.equal('http://cdn.adnxs.com/img.png');
});
});
});