public AssetStorePackage(AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, UpmPackage package) { m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = package?.name ?? string.Empty; m_ProductId = productInfo?.id.ToString(); m_Images = productInfo?.images ?? new List <PackageImage>(); m_Links = productInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(); m_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; m_UpmVersionList = package?.versions as UpmVersionList ?? new UpmVersionList(); foreach (var version in m_UpmVersionList.Cast <UpmPackageVersion>()) { version.UpdateProductInfo(productInfo); } if (purchaseInfo == null) { AddError(new UIError(UIErrorCode.AssetStorePackageError, "Invalid purchase details.")); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, "Invalid product details.")); } else if (string.IsNullOrEmpty(package?.name)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, "Invalid package info.")); } }
public AssetStorePackage(AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = string.Empty; m_ProductId = productInfo?.id.ToString(); m_Images = productInfo?.images ?? new List <PackageImage>(); m_Links = productInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(); m_UpmVersionList = new UpmVersionList(); m_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; if (purchaseInfo == null) { AddError(new UIError(UIErrorCode.AssetStorePackageError, "Invalid purchase details.")); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, "Invalid product details.")); } else if (localInfo == null) { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo)); } else { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo, localInfo)); if (localInfo.canUpdate && (localInfo.versionId != productInfo.versionId || localInfo.versionString != productInfo.versionString)) { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo)); } } }
public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, UpmPackage package) { ResolveDependencies(assetStoreUtils, ioProxy); m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = package?.name ?? string.Empty; m_ProductId = productInfo?.id.ToString(); m_Images = productInfo?.images ?? new List <PackageImage>(); m_Links = productInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(assetStoreUtils, ioProxy); m_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; m_UpmVersionList = package?.versions as UpmVersionList ?? new UpmVersionList(ioProxy); if (productInfo != null) { foreach (var version in m_UpmVersionList.Cast <UpmPackageVersion>()) { version.UpdateProductInfo(productInfo); } } m_AssetStoreLink = productInfo?.assetStoreLink.url; var firstPublishedDateString = productInfo?.firstPublishedDate ?? string.Empty; m_FirstPublishedDateTicks = !string.IsNullOrEmpty(firstPublishedDateString) ? DateTime.Parse(firstPublishedDateString).Ticks : 0; if (purchaseInfo == null) { var errorMessage = L10n.Tr("Unable to get purchase details because you may not have purchased this package."); AddError(new UIError(UIErrorCode.AssetStorePackageError, errorMessage)); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid product details."))); } else if (string.IsNullOrEmpty(package?.name)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid package info."))); } }
public AssetStorePackage(AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = string.Empty; m_ProductId = productInfo?.id.ToString(); m_Images = productInfo?.images ?? new List <PackageImage>(); m_Links = productInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(); m_UpmVersionList = new UpmVersionList(); m_AssetStoreLink = productInfo?.assetStoreLink.url; var firstPublishedDateString = productInfo?.firstPublishedDate ?? string.Empty; m_FirstPublishedDateTicks = !string.IsNullOrEmpty(firstPublishedDateString) ? DateTime.Parse(firstPublishedDateString).Ticks : 0; m_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; if (purchaseInfo == null) { var errorMessage = ApplicationUtil.instance.GetTranslationForText("Unable to get purchase details because you may not have purchased this package."); AddError(new UIError(UIErrorCode.AssetStorePackageError, errorMessage)); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, ApplicationUtil.instance.GetTranslationForText("Invalid product details."))); } else if (localInfo == null) { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo)); } else { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo, localInfo)); if (localInfo.canUpdate && (localInfo.versionId != productInfo.versionId || localInfo.versionString != productInfo.versionString)) { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo)); } } }
private void FetchInternal(long productId, AssetStorePurchaseInfo purchaseInfo) { RefreshLocalInfos(); var id = productId.ToString(); var localInfo = m_AssetStoreCache.GetLocalInfo(id); if (localInfo?.updateInfoFetched == false) { RefreshProductUpdateDetails(new[] { localInfo }); } // create a placeholder before fetching data from the cloud for the first time if (m_AssetStoreCache.GetProductInfo(id) == null) { onPackagesChanged?.Invoke(new[] { new PlaceholderPackage(id, purchaseInfo?.displayName ?? string.Empty, PackageType.AssetStore, PackageTag.None, PackageProgress.Refreshing) }); } FetchDetails(new[] { productId }); onProductFetched?.Invoke(productId); }
public void ParsePurchases(IDictionary <string, object> rawList) { total = (long)rawList["total"]; if (total <= 0) { return; } var results = rawList.GetList <Dictionary <string, object> >("results") ?? Enumerable.Empty <Dictionary <string, object> >(); foreach (var item in results) { list.Add(AssetStorePurchaseInfo.ParsePurchaseInfo(item)); } var categories = rawList.GetList <Dictionary <string, object> >("category") ?? Enumerable.Empty <Dictionary <string, object> >(); foreach (var item in categories) { this.categories.Add(new Category { name = item.GetString("name"), count = (long)item["count"] }); } }
public void SetPurchaseInfo(AssetStorePurchaseInfo info) { m_PurchaseInfos[info.productId.ToString()] = info; }