modules/ucfunnelBidAdapter.js
function (ucfunnelResponseObj, request) {
    const bidRequest = request.bidRequest;
    const ad = ucfunnelResponseObj ? ucfunnelResponseObj.body : {};
    const videoPlayerSize = parseSizes(bidRequest);

    let bid = {
      requestId: bidRequest.bidId,
      cpm: ad.cpm || 0,
      creativeId: ad.ad_id,
      dealId: ad.deal || null,
      currency: 'USD',
      netRevenue: true,
      ttl: 1800
    };

    if (ad.creative_type) {
      bid.mediaType = ad.creative_type;
    }

    switch (ad.creative_type) {
      case NATIVE:
        let nativeAd = ad.native;
        Object.assign(bid, {
          width: 1,
          height: 1,
          native: {
            title: nativeAd.title,
            body: nativeAd.desc,
            cta: nativeAd.ctatext,
            sponsoredBy: nativeAd.sponsored,
            image: nativeAd.image || nativeAd.image.url,
            icon: nativeAd.icon || nativeAd.icon.url,
            clickUrl: nativeAd.clickUrl,
            impressionTrackers: nativeAd.impressionTrackers,
          }
        });
        break;
      case VIDEO:
        Object.assign(bid, {
          vastUrl: ad.vastUrl,
          vastXml: ad.vastXml
        });

        if (videoPlayerSize && videoPlayerSize.length === 2) {
          Object.assign(bid, {
            width: videoPlayerSize[0],
            height: videoPlayerSize[1]
          });
        }
        break;
      case BANNER:
      default:
        Object.assign(bid, {
          width: ad.width,
          height: ad.height,
          ad: ad.adm
        });
    }

    return [bid];
  }
function (ucfunnelResponseObj, request) {
    const bidRequest = request.bidRequest;
    const ad = ucfunnelResponseObj ? ucfunnelResponseObj.body : {};
    const videoPlayerSize = parseSizes(bidRequest);

    let bid = {
      requestId: bidRequest.bidId,
      cpm: ad.cpm || 0,
      creativeId: ad.ad_id,
      dealId: ad.deal || null,
      currency: 'USD',
      netRevenue: true,
      ttl: 1800
    };

    if (ad.creative_type) {
      bid.mediaType = ad.creative_type;
    }

    switch (ad.creative_type) {
      case NATIVE:
        let nativeAd = ad.native;
        Object.assign(bid, {
          width: 1,
          height: 1,
          native: {
            title: nativeAd.title,
            body: nativeAd.desc,
            cta: nativeAd.ctatext,
            sponsoredBy: nativeAd.sponsored,
            image: nativeAd.image || nativeAd.image.url,
            icon: nativeAd.icon || nativeAd.icon.url,
            clickUrl: nativeAd.clickUrl,
            impressionTrackers: nativeAd.impressionTrackers,
          }
        });
        break;
      case VIDEO:
        Object.assign(bid, {
          vastUrl: ad.vastUrl,
          vastXml: ad.vastXml
        });

        if (videoPlayerSize && videoPlayerSize.length === 2) {
          Object.assign(bid, {
            width: videoPlayerSize[0],
            height: videoPlayerSize[1]
          });
        }
        break;
      case BANNER:
      default:
        Object.assign(bid, {
          width: ad.width,
          height: ad.height,
          ad: ad.adm
        });
    }

    return [bid];
  }
function ( ucfunnelResponseObj , request ) { const bidRequest = request . bidRequest ; const ad = ucfunnelResponseObj ? ucfunnelResponseObj . body : { } ; const videoPlayerSize = parseSizes ( bidRequest ) ; let bid = { requestId : bidRequest . bidId , cpm : ad . cpm || 0 , creativeId : ad . ad_id , dealId : ad . deal || null , currency : 'USD' , netRevenue : true , ttl : 1800 } ; if ( ad . creative_type ) { bid . mediaType = ad . creative_type ; } switch ( ad . creative_type ) { case NATIVE : let nativeAd = ad . native ; Object . assign ( bid , { width : 1 , height : 1 , native : { title : nativeAd . title , body : nativeAd . desc , cta : nativeAd . ctatext , sponsoredBy : nativeAd . sponsored , image : nativeAd . image || nativeAd . image . url , icon : nativeAd . icon || nativeAd . icon . url , clickUrl : nativeAd . clickUrl , impressionTrackers : nativeAd . impressionTrackers , } } ) ; break ; case VIDEO : Object . assign ( bid , { vastUrl : ad . vastUrl , vastXml : ad . vastXml } ) ; if ( videoPlayerSize && videoPlayerSize . length === 2 ) { Object . assign ( bid , { width : videoPlayerSize [ 0 ] , height : videoPlayerSize [ 1 ] } ) ; } break ; case BANNER : default : Object . assign ( bid , { width : ad . width , height : ad . height , ad : ad . adm } ) ; } return [ bid ] ; }
Format ucfunnel responses as Prebid bid responses
@param {ucfunnelResponseObj} ucfunnelResponse A successful response from ucfunnel.
@return {Bid[]} An array of formatted bids.
Format ucfunnel responses as Prebid bid responses