public void AppendPurchases(IDictionary <string, object> rawList) { var parsedTotal = (long)rawList["total"]; if (parsedTotal <= 0) { return; } total = parsedTotal; 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) { var categoryName = item.GetString("name"); var matchingCategory = this.categories.FirstOrDefault(c => c.name == categoryName); if (matchingCategory != null) { matchingCategory.count += (long)item["count"]; } else { this.categories.Add(new Category { name = categoryName, count = (long)item["count"] }); } } }
public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { ResolveDependencies(assetStoreUtils, ioProxy); 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(assetStoreUtils, ioProxy); 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; m_IsHidden = purchaseInfo?.isHidden == true; if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid product details."))); } else { // The version we get from the product info the latest on the server // The version we get from the localInfo is the version publisher set when uploading the .unitypackage file // The publisher could update the version on the server but NOT upload a new .unitypackage file, that will // result in a case where localInfo and productInfo have different version numbers but no update is available // Because of this, we prefer showing version from the server (even when localInfo version is different) // and we only want to show the localInfo version when `localInfo.canUpdate` is set to true var latestVersion = new AssetStorePackageVersion(assetStoreUtils, ioProxy, productInfo); if (localInfo != null) { if (localInfo.canUpdate) { m_VersionList.AddVersion(new AssetStorePackageVersion(assetStoreUtils, ioProxy, productInfo, localInfo)); } else { latestVersion.SetLocalPath(localInfo.packagePath); if (localInfo.canDowngrade) { var warningMessage = string.Format(k_IncompatibleWarningMessage, localInfo.supportedVersion); AddError(new UIError(UIErrorCode.AssetStorePackageError, warningMessage, UIError.Attribute.IsWarning)); } } } m_VersionList.AddVersion(latestVersion); } LinkPackageAndVersions(); }
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_IsHidden = purchaseInfo?.isHidden == true; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; m_UpmVersionList = package?.versions as UpmVersionList ?? new UpmVersionList(); 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) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Unable to get asset purchase details because you may not have purchased this package."))); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Unable to retrieve asset product details."))); } else if (string.IsNullOrEmpty(package?.name)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Unable to retrieve asset package info."))); } LinkPackageAndVersions(); }
private void FetchInternal(long productId, AssetStorePurchaseInfo purchaseInfo) { RefreshLocalInfos(); var id = productId.ToString(); if (m_AssetStoreCache.GetLocalInfo(id)?.updateInfoFetched == false) { CheckUpdate(new[] { id }); } // 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.Downloadable, PackageProgress.Refreshing) }); } FetchDetails(new[] { productId }); onProductFetched?.Invoke(productId); }
public virtual void SetPurchaseInfo(AssetStorePurchaseInfo info) { m_PurchaseInfos[info.productId.ToString()] = info; }