All files / appsflyer-react-native-plugin/PurchaseConnector/models auto_renewing_plan.ts

100% Statements 9/9
50% Branches 2/4
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 351x             1x           3x   3x 3x 1x     1x               1x            
import { SubscriptionItemPriceChangeDetailsJson, SubscriptionItemPriceChangeDetails } from "./subscription_item_price_change_details";
 
export type AutoRenewingPlanJson = {
  autoRenewEnabled?: boolean;
  priceChangeDetails?: SubscriptionItemPriceChangeDetailsJson;
};
 
export class AutoRenewingPlan {
  autoRenewEnabled?: boolean;
  priceChangeDetails?: SubscriptionItemPriceChangeDetails;
 
  constructor(
    autoRenewEnabled?: boolean,
    priceChangeDetails?: SubscriptionItemPriceChangeDetails
  ) {
    this.autoRenewEnabled = autoRenewEnabled;
    this.priceChangeDetails = priceChangeDetails;
  }
 
  static fromJson(json: AutoRenewingPlanJson): AutoRenewingPlan {
    return new AutoRenewingPlan(
      json.autoRenewEnabled,
      json.priceChangeDetails &&
        SubscriptionItemPriceChangeDetails.fromJson(json.priceChangeDetails)
    );
  }
 
  toJson(): AutoRenewingPlanJson {
    return {
      autoRenewEnabled: this.autoRenewEnabled,
      priceChangeDetails: this.priceChangeDetails?.toJson(),
    };
  }
}