src/ads/fetchAds.js
function _buildImageFields(data){

  var newUnits = [];

  for (var i = 0, len = data.length; i < len; i++){

    adUnit = data[i];

    // todo: create adUnit object to encapsulate this logic
    if ('images' in adUnit){
      if ('banner' in adUnit.images){
        adUnit.campaign_banner_url = adUnit.images.banner.url;
      }
      if ('icon' in adUnit.images){
        adUnit.campaign_icon_url = adUnit.images.icon.url;
      }
      if ('hq_icon' in adUnit.images){
        adUnit.campaign_hq_icon_url = adUnit.images.hq_icon.url;
      }
    }

    newUnits.push(adUnit);
  }
  return newUnits;
}
function _buildImageFields(data){

  var newUnits = [];

  for (var i = 0, len = data.length; i < len; i++){

    adUnit = data[i];

    // todo: create adUnit object to encapsulate this logic
    if ('images' in adUnit){
      if ('banner' in adUnit.images){
        adUnit.campaign_banner_url = adUnit.images.banner.url;
      }
      if ('icon' in adUnit.images){
        adUnit.campaign_icon_url = adUnit.images.icon.url;
      }
      if ('hq_icon' in adUnit.images){
        adUnit.campaign_hq_icon_url = adUnit.images.hq_icon.url;
      }
    }

    newUnits.push(adUnit);
  }
  return newUnits;
}
function _buildImageFields ( data ) { var newUnits = [ ] ; for ( var i = 0 , len = data . length ; i < len ; i ++ ) { adUnit = data [ i ] ; // todo: create adUnit object to encapsulate this logic if ( 'images' in adUnit ) { if ( 'banner' in adUnit . images ) { adUnit . campaign_banner_url = adUnit . images . banner . url ; } if ( 'icon' in adUnit . images ) { adUnit . campaign_icon_url = adUnit . images . icon . url ; } if ( 'hq_icon' in adUnit . images ) { adUnit . campaign_hq_icon_url = adUnit . images . hq_icon . url ; } } newUnits . push ( adUnit ) ; } return newUnits ; }
Fills some image fields with JSON data
@param data The data coming from the server
@returns processed data
@private
Fills some image fields with JSON data