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

Update adapter to prebid v1.0 #1908

Merged
merged 9 commits into from
Jan 23, 2018
30 changes: 12 additions & 18 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ export const spec = {
// to find which one the ad server needs

// pull requested transaction ID from bidderRequest.bids[].transactionId
if (!Array.isArray(validBidRequests)) {
validBidRequests = [validBidRequests];
}
var bid = validBidRequests[0];
const payload = {
siteid: bid.params.siteId,
pageid: bid.params.pageId,
formatid: bid.params.formatId,
currencyCode: config.getConfig('currency'),
currencyCode: config.getConfig('currency').adServerCurrency,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use config.getConfig('currency.adServerCurency') since the config module does safe deep access. The way you have it here if currency hasn't been set then it will throw "can't read adServerCurrency of undefined" error.

bidfloor: bid.params.bidfloor || 0.0,
targeting: bid.params.target && bid.params.target != '' ? bid.params.target : undefined,
tagId: bid.adUnitCode,
Expand All @@ -66,28 +63,25 @@ export const spec = {
*/
interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
if (serverResponse) {
var response = serverResponse.body;
if (response) {
const bidResponse = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bidderCode will be set automatically by bidderFactory now, this line can be dropped

cpm: serverResponse.cpm,
width: serverResponse.width,
height: serverResponse.height,
creativeId: serverResponse.creativeId,
dealId: serverResponse.dealId,
currency: serverResponse.currency,
netRevenue: serverResponse.isNetCpm,
ttl: serverResponse.ttl,
cpm: response.cpm,
width: response.width,
height: response.height,
creativeId: response.creativeId,
dealId: response.dealId,
currency: response.currency,
netRevenue: response.isNetCpm,
ttl: response.ttl,
referrer: utils.getTopWindowUrl(),
ad: serverResponse.ad
ad: response.ad
};
bidResponses.push(bidResponse);
}
return bidResponses;
},
getUserSyncs: function (syncOptions) {
// iframe || image
return undefined;
}
}
registerBidder(spec);