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

33.33% Statements 4/12
0% Branches 0/4
25% Functions 1/4
27.27% Lines 3/11

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 521x                 1x                               1x                                                    
import { Money, MoneyArgs } from "./money_model";
 
export type SubscriptionItemPriceChangeDetailsJson = {
  expectedNewPriceChargeTime: string;
  priceChangeMode: string;
  priceChangeState: string;
  newPrice?: MoneyArgs;
};
 
export class SubscriptionItemPriceChangeDetails {
  expectedNewPriceChargeTime: string;
  priceChangeMode: string;
  priceChangeState: string;
  newPrice?: Money;
 
  constructor(
    expectedNewPriceChargeTime: string,
    priceChangeMode: string,
    priceChangeState: string,
    newPrice?: Money
  ) {
    this.expectedNewPriceChargeTime = expectedNewPriceChargeTime;
    this.priceChangeMode = priceChangeMode;
    this.priceChangeState = priceChangeState;
    this.newPrice = newPrice;
  }
 
  static fromJson(
    json: SubscriptionItemPriceChangeDetailsJson
  ): SubscriptionItemPriceChangeDetails {
    const newPriceInstance = json.newPrice
      ? Money.fromJson(json.newPrice)
      : undefined;
 
    return new SubscriptionItemPriceChangeDetails(
      json.expectedNewPriceChargeTime,
      json.priceChangeMode,
      json.priceChangeState,
      newPriceInstance
    );
  }
 
  toJson(): SubscriptionItemPriceChangeDetailsJson {
    return {
      expectedNewPriceChargeTime: this.expectedNewPriceChargeTime,
      priceChangeMode: this.priceChangeMode,
      priceChangeState: this.priceChangeState,
      newPrice: this.newPrice ? this.newPrice.toJson() : undefined,
    };
  }
}