toAndroidJson method
Implementation
String toAndroidJson() {
if (AWCommonUtil.strNotEmpty(productType) &&
productType == PRODUCT_TYPE_INAPP) {
return '{\"productId\":\"$productId\",'
'\"type\":\"$productType\",'
'\"title\":\"${AWCommonUtil.strNotEmpty(title) ? title : ""}\",'
'\"price_currency_code\":\"${AWCommonUtil.strNotEmpty(priceCurrency) ? priceCurrency : ""}\",'
'\"price_amount_micros\":\"$priceAmount\",'
'\"price\":\"${AWCommonUtil.strNotEmpty(price) ? price : ""}\",'
'\"original_price_micros\":\"${originalPriceAmount ?? ""}\",'
'\"original_price\":\"${AWCommonUtil.strNotEmpty(originalPrice) ? originalPrice : ""}\",'
'\"description\":\"${AWCommonUtil.strNotEmpty(description) ? description : ""}\"'
'}';
}
if (AWCommonUtil.strNotEmpty(productType) &&
productType == PRODUCT_TYPE_SUBS) {
String? introductoryPricePeriod;
int? introductoryAmountPrice;
int? introductoryPriceCycles;
if (introductDiscount != null &&
AWCommonUtil.strNotEmpty(introductDiscount?.discountPeriod)) {
introductoryPricePeriod = introductDiscount?.discountPeriod;
introductoryAmountPrice = introductDiscount?.discountPrice;
introductoryPriceCycles = introductDiscount?.discountCycle;
}
String? freeTrialPeriod;
if (discounts != null && discounts![0] != null) {
if (AWCommonUtil.strNotEmpty(discounts![0].discountPeriod)) {
freeTrialPeriod = discounts![0].discountPeriod;
}
}
return '{\"productId\":\"$productId\",'
'\"type\":\"$productType\",'
'\"title\":\"${AWCommonUtil.strNotEmpty(title) ? title : ""}\",'
'\"price_currency_code\":\"${AWCommonUtil.strNotEmpty(priceCurrency) ? priceCurrency : ""}\",'
'\"price_amount_micros\":\"$priceAmount\",'
'\"price\":\"${AWCommonUtil.strNotEmpty(price) ? price : ""}\",'
'\"original_price_micros\":\"${originalPriceAmount ?? ""}\",'
'\"original_price\":\"${AWCommonUtil.strNotEmpty(originalPrice) ? originalPrice : ""}\",'
'\"description\":\"${AWCommonUtil.strNotEmpty(description) ? description : ""}\",'
'\"freeTrialPeriod\":\"${AWCommonUtil.strNotEmpty(freeTrialPeriod) ? freeTrialPeriod : ""}\",'
'\"introductoryPricePeriod\":\"${AWCommonUtil.strNotEmpty(introductoryPricePeriod) ? introductoryPricePeriod : ""}\",'
'\"introductoryAmountPrice\":\"$introductoryAmountPrice\",'
'\"introductoryPriceCycles\":\"$introductoryPriceCycles\"'
'}';
}
return '';
}