checkPurchase method
Implementation
Future<bool> checkPurchase(contentmodel.Datum content) async {
String purchaseListData = await getPurchaseList();
if (purchaseListData == "") {
return false;
}
var purchaseModel = PurchaseModel.fromJson(purchaseListData);
//the response contains a purchase list, parse it and check if the objectid exists
var purchaseList = purchaseModel.data;
for (var i = 0; i < purchaseList!.length; i++) {
var purchaseItem = purchaseList[i];
var purchasedItemAvailabilityId = purchaseItem.availabilityid.toString();
if (content.contentdetails?.first.availabilityset
?.contains(purchasedItemAvailabilityId) ??
false) {
return true;
}
}
return false;
}