modules/pulsepointBidAdapter.js
function bidResponseAvailable(bidRequest, bidResponse) {
  const idToImpMap = {};
  const idToBidMap = {};
  bidResponse = bidResponse.body
  // extract the request bids and the response bids, keyed by impr-id
  const ortbRequest = parse(bidRequest.data);
  ortbRequest.imp.forEach(imp => {
    idToImpMap[imp.id] = imp;
  });
  if (bidResponse) {
    bidResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => {
      idToBidMap[bid.impid] = bid;
    }));
  }
  const bids = [];
  Object.keys(idToImpMap).forEach(id => {
    if (idToBidMap[id]) {
      const bid = {
        requestId: id,
        cpm: idToBidMap[id].price,
        creative_id: idToBidMap[id].crid,
        creativeId: idToBidMap[id].crid,
        adId: id,
        ttl: DEFAULT_BID_TTL,
        netRevenue: DEFAULT_NET_REVENUE,
        currency: DEFAULT_CURRENCY
      };
      if (idToImpMap[id]['native']) {
        bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
        bid.mediaType = 'native';
      } else {
        bid.ad = idToBidMap[id].adm;
        bid.width = idToImpMap[id].banner.w;
        bid.height = idToImpMap[id].banner.h;
      }
      applyExt(bid, idToBidMap[id])
      bids.push(bid);
    }
  });
  return bids;
}
function bidResponseAvailable(bidRequest, bidResponse) {
  const idToImpMap = {};
  const idToBidMap = {};
  bidResponse = bidResponse.body
  // extract the request bids and the response bids, keyed by impr-id
  const ortbRequest = parse(bidRequest.data);
  ortbRequest.imp.forEach(imp => {
    idToImpMap[imp.id] = imp;
  });
  if (bidResponse) {
    bidResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => {
      idToBidMap[bid.impid] = bid;
    }));
  }
  const bids = [];
  Object.keys(idToImpMap).forEach(id => {
    if (idToBidMap[id]) {
      const bid = {
        requestId: id,
        cpm: idToBidMap[id].price,
        creative_id: idToBidMap[id].crid,
        creativeId: idToBidMap[id].crid,
        adId: id,
        ttl: DEFAULT_BID_TTL,
        netRevenue: DEFAULT_NET_REVENUE,
        currency: DEFAULT_CURRENCY
      };
      if (idToImpMap[id]['native']) {
        bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
        bid.mediaType = 'native';
      } else {
        bid.ad = idToBidMap[id].adm;
        bid.width = idToImpMap[id].banner.w;
        bid.height = idToImpMap[id].banner.h;
      }
      applyExt(bid, idToBidMap[id])
      bids.push(bid);
    }
  });
  return bids;
}
function bidResponseAvailable ( bidRequest , bidResponse ) { const idToImpMap = { } ; const idToBidMap = { } ; bidResponse = bidResponse . body // extract the request bids and the response bids, keyed by impr-id const ortbRequest = parse ( bidRequest . data ) ; ortbRequest . imp . forEach ( imp => { idToImpMap [ imp . id ] = imp ; } ) ; if ( bidResponse ) { bidResponse . seatbid . forEach ( seatBid => seatBid . bid . forEach ( bid => { idToBidMap [ bid . impid ] = bid ; } ) ) ; } const bids = [ ] ; Object . keys ( idToImpMap ) . forEach ( id => { if ( idToBidMap [ id ] ) { const bid = { requestId : id , cpm : idToBidMap [ id ] . price , creative_id : idToBidMap [ id ] . crid , creativeId : idToBidMap [ id ] . crid , adId : id , ttl : DEFAULT_BID_TTL , netRevenue : DEFAULT_NET_REVENUE , currency : DEFAULT_CURRENCY } ; if ( idToImpMap [ id ] [ 'native' ] ) { bid [ 'native' ] = nativeResponse ( idToImpMap [ id ] , idToBidMap [ id ] ) ; bid . mediaType = 'native' ; } else { bid . ad = idToBidMap [ id ] . adm ; bid . width = idToImpMap [ id ] . banner . w ; bid . height = idToImpMap [ id ] . banner . h ; } applyExt ( bid , idToBidMap [ id ] ) bids . push ( bid ) ; } } ) ; return bids ; }
Callback for bids, after the call to PulsePoint completes.
Callback for bids after the call to PulsePoint completes .