async public static Task <GetStoreItemsResult> GetStoreData(string titleId, string storeId) { var currentPlayFabTitleId = PlayFabSettings.TitleId; var currentDevKey = PlayFabSettings.DeveloperSecretKey; var title = FindTitle(titleId); PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = title.SecretKey; var result = await PlayFabAdminAPI.GetStoreItemsAsync(new PlayFab.AdminModels.GetStoreItemsRequest() { StoreId = storeId }); PlayFabSettings.TitleId = currentPlayFabTitleId; PlayFabSettings.DeveloperSecretKey = currentDevKey; if (result.Error != null) { Console.WriteLine("Get Store Error: " + PlayFabUtil.GetErrorReport(result.Error)); return(null); } //var version = result.Result.CatalogVersion; //var marketingModel = result.Result.MarketingData; //var currentStoreId = result.Result.StoreId; return(result.Result); }
public static void GetStoreData(string titleId, string storeId, Action <bool, string, string, StoreMarketingModel, List <PlayFab.AdminModels.StoreItem> > callback) { var currentPlayFabTitleId = PlayFabSettings.TitleId; var currentDevKey = PlayFabSettings.DeveloperSecretKey; var title = FindTitle(titleId); PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = title.SecretKey; var task = PlayFabAdminAPI.GetStoreItemsAsync(new PlayFab.AdminModels.GetStoreItemsRequest() { StoreId = storeId }) .ContinueWith( (result) => { PlayFabSettings.TitleId = currentPlayFabTitleId; PlayFabSettings.DeveloperSecretKey = currentDevKey; if (result.Result.Error != null) { Console.WriteLine("Get Store Error: " + PlayFabUtil.GetErrorReport(result.Result.Error)); callback(false, null, null, null, null); return; } if (result.IsCompleted) { var version = result.Result.Result.CatalogVersion; var marketingModel = result.Result.Result.MarketingData; var currentStoreId = result.Result.Result.StoreId; callback(true, version, currentStoreId, marketingModel, result.Result.Result.Store); } }); }
public async Task <List <PlayFabItem> > GetStoreItems() { var isCacheUpdated = await IsCacheUpdated(); if (!cache.TryGetValue(CacheKeys.Store, out List <PlayFabItem> items) || !isCacheUpdated) { var reqGetCatalog = new GetCatalogItemsRequest { CatalogVersion = configuration.CatalogName, }; var reqGetStore = new GetStoreItemsRequest { CatalogVersion = configuration.CatalogName, StoreId = configuration.StoreName }; var resultCatalog = await PlayFabAdminAPI.GetCatalogItemsAsync(reqGetCatalog); if (resultCatalog.Error != null) { throw new Exception(resultCatalog.Error.ErrorMessage); } var resultStore = await PlayFabAdminAPI.GetStoreItemsAsync(reqGetStore); if (resultStore.Error != null) { throw new Exception(resultStore.Error.ErrorMessage); } var catalog = resultCatalog.Result.Catalog; var store = resultStore.Result.Store; items = MergeAndGetItemList(catalog, store); cache.Set(CacheKeys.Store, items, cacheEntryOptions); if (!isCacheUpdated) { await UpdateStoreVersionCache(); } } return(items); }