trialDurationInDays method

int trialDurationInDays()

Implementation

int trialDurationInDays() {
  SGOfferPhase? offer = offerPhases?.firstOrNull;
  SGBillinPeriodUnit unit = offer?.billingPeriodUnit ?? SGBillinPeriodUnit.unknown;
  int billingPeriodNumberOfUnit = offer?.billingPeriodNumberOfUnit ?? 0;

  if (offer != null) {
    switch (unit) {
      case SGBillinPeriodUnit.day:
        return billingPeriodNumberOfUnit;
      case SGBillinPeriodUnit.week:
        return (billingPeriodNumberOfUnit * 7);
      case SGBillinPeriodUnit.month:
        return (billingPeriodNumberOfUnit * 30);
      case SGBillinPeriodUnit.year:
        return (billingPeriodNumberOfUnit * 365);
      case SGBillinPeriodUnit.unknown:
        return billingPeriodNumberOfUnit;
    }
  } else {
    return 0;
  }
}