fromAndroidJson static method

AWProduct fromAndroidJson(
  1. Map<String, dynamic> json
)

android用

Implementation

static AWProduct fromAndroidJson(Map<String, dynamic> json) {
  final product = AWProduct();
  product.productId = json["productId"];
  product.productType = json["type"];
  product.price = json["price"];
  product.priceAmount = json["price_amount_micros"];
  product.originalPrice = json["original_price"];
  product.originalPriceAmount = json["original_price_micros"];
  product.priceCurrency = json["price_currency_code"];
  product.title = json["title"];
  if (json["type"] == AWProduct.PRODUCT_TYPE_SUBS) {
    product.subscriptionPeriod = json["subscriptionPeriod"];
    if (json["introductoryAmountPrice"] != null &&
        json["price_currency_code"] != null &&
        json["price_currency_code"].toString().length > 0 &&
        json["introductoryPricePeriod"] != null &&
        json["introductoryPricePeriod"].toString().length > 0 &&
        json["introductoryPriceCycles"] != null)
      product.introductDiscount = ProductDiscount.fromAndroidParams(
          json["introductoryAmountPrice"],
          json["price_currency_code"],
          json["introductoryPricePeriod"],
          json["introductoryPriceCycles"]);
    product.discounts = json["freeTrialPeriod"] == null ||
            json["freeTrialPeriod"].toString().length <= 0
        ? null
        : [
            ProductDiscount.fromAndroidParams(
                0, json["price_currency_code"], json["freeTrialPeriod"], 1)
          ];
  }
  return product;
}