Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (YTSRoamingInternetFabricData *)getUpdatedInternetFabricData
  2. {
  3.     YWAProductModel *option = self.device.roamingInternetOption;
  4.     YWAProductModel *mbsOption = self.device.roamingMBsInternetOption;
  5.     YWARoamingOfferModel *offerForWorkingCountry = [self.roamingOffers internetOfferForRegion:self.selectedOrDefaultCountry product:option];
  6.     YWARoamingOfferModel *offerForSelectedCountry = [self.roamingOffers internetOfferForRegion:self.selectedCountry product:option];
  7.  
  8.  
  9.     YTSRoamingInternetFabricData *data = [YTSRoamingInternetFabricData new];
  10.  
  11.     data.isCurrentOfferAvalibleForSelectedCountry = [option.offer.offerCode isEqualToString:(NSString * _Nonnull)offerForSelectedCountry.code];
  12.  
  13.     data.customerBalance = self.customerBalance;
  14.     data.countrySelected = self.selectedCountry != nil;
  15.     data.isSatelliteCountry = [self isSatelliteCountry];
  16.  
  17.     data.isRoaming = self.isRoaming;
  18.  
  19.     data.hasHomeProduct = self.packageProduct != nil;
  20.     data.homeProductActive = !self.packageProduct.isBlocked;
  21.     data.homeProductTestDrive = self.packageProduct.isStarterProduct;
  22.     data.homeProductFreemium = self.packageProduct.isFreemium;
  23.  
  24.     data.hasOption = option != nil;
  25.     data.optionIsActive = option.isActive;
  26.     data.autoprolongEnabled = option.isAutoprolongEnabled;
  27.     data.selectedCountryHasOffer = offerForWorkingCountry.isAvailable;
  28.  
  29.     if (!data.selectedCountryHasOffer) {
  30.         offerForWorkingCountry = [self.roamingOffers internetOfferForRegion:self.defaultCountry product:option];
  31.     }
  32.  
  33.     data.hasMBsOption = mbsOption != nil;
  34.     data.mbsOptionIsActive = mbsOption.isActive;
  35.     data.isFreeAccumulator = option.offer.freeDataCharacteristic != nil;
  36.     data.selectedCountryEqualToBackendCountry = [self.currentCountry.code isEqualToString:(NSString * _Nonnull)self.retentionSession.customerContext.productRegionCode];
  37.  
  38.     if ((data.hasOption || !data.hasMBsOption) && !data.isSatelliteCountry){
  39.         data.internetFreeDataTotal = offerForWorkingCountry.internetFreeDataTotal;
  40.         data.internetPaidDataTotal = offerForWorkingCountry.internetPaidDataTotal;
  41.         data.internetFreeDataLeft = option.dataOptionFreeAmount;
  42.         data.internetPaidDataLeft = option.dataOptionPaidAmount;
  43.  
  44.         data.total = offerForWorkingCountry.internetFreeDataTotal + offerForWorkingCountry.internetPaidDataTotal;
  45.  
  46.  
  47.         if ([self.selectedCountry.code isEqualToString:self.currentCountryProductCode]) {
  48.             data.amount = option.dataOptionFreeAmount + option.dataOptionPaidAmount;
  49.         } else {
  50.             data.amount = offerForWorkingCountry.internetFreeDataTotal + offerForWorkingCountry.internetPaidDataTotal;
  51.         }
  52.  
  53.         if (data.selectedCountryHasOffer) {
  54.             data.price = [self.personalDataService.selfcareRoamingData.roamingOffers internetPaidOptionPricePerMB:self.selectedOrDefaultCountry];
  55.         } else {
  56.             data.price = [self.personalDataService.selfcareRoamingData.roamingOffers internetPaidOptionPricePerMB:self.defaultCountry];
  57.         }
  58.     } else {
  59.         data.total = 1;
  60.         data.amount = 1;
  61.         data.hasMBsOption = [self.personalDataService.selfcareRoamingData.roamingOffers megabyteWithoutPaidBasePasckageTermForRegion:self.selectedCountry];
  62.         data.price = [self.personalDataService.selfcareRoamingData.roamingOffers megabyteWithoutPaidBasePasckageTermForRegion:self.selectedOrDefaultCountry].numericValue.integerValue;
  63.     }
  64.  
  65.     data.pricePerHundredKb = (CGFloat)(data.price/10.24);
  66.     data.lowLimit = (CGFloat)self.config.apiConfig.roamingProductInfo.minMBytes.doubleValue;
  67.  
  68.     return data;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement