fetchAd method

void fetchAd(
  1. String? slotId
)

Implementation

void fetchAd(String? slotId) async{
  adSlot = slotId;
  if(Ads.config!.apiConfig!.baseUrl.isEmpty) {
    change(null, status: RxStatus.error("Base url not initialized"));
    throw("Base url not initialized");
  }
  if(Ads.config!.userConfig!.reseller.isEmpty) {
    change(null, status: RxStatus.error("Reseller id not initialized"));
    throw("Reseller id not initialized");
  }
    if(Ads.config!.userConfig!.subscriber.isEmpty) {
      change(null, status: RxStatus.error("Subscriber id not initialized"));
      throw("Subscriber id not initialized");
    }

    if(slotId == null){
      change(null, status: RxStatus.error("Slot id cannot be empty"));
      printError(info:"Slot id cannot be empty   ");
    }

    adsRepository.getBannerAds(slotId!).then((value){
      if(value != null){
        change(value, status: RxStatus.success());
        autoRefresh(value.token());
      }else{
        change(null, status: RxStatus.empty());
      }
    });
}