| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using DCLServices.QuestsService; |
| | 5 | | using System; |
| | 6 | | using System.Collections; |
| | 7 | | using System.Collections.Generic; |
| | 8 | | using System.Threading; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.Networking; |
| | 11 | |
|
| | 12 | | namespace DCL.Quests |
| | 13 | | { |
| | 14 | | public class QuestRewardsResolver : IQuestRewardsResolver |
| | 15 | | { |
| | 16 | | private const string QUESTS_API_URL = "https://quests.decentraland.zone/quests"; |
| | 17 | |
|
| | 18 | | private readonly Service<IWebRequestController> webRequestController; |
| | 19 | |
|
| | 20 | | public async UniTask<IReadOnlyList<QuestReward>> ResolveRewards(string questId, CancellationToken cancellationTo |
| | 21 | | { |
| | 22 | | try |
| | 23 | | { |
| 0 | 24 | | UnityWebRequest result = await webRequestController.Ref.GetAsync($"{QUESTS_API_URL}/{questId}/rewards", |
| 0 | 25 | | QuestRewardResponse placesAPIResponse = Utils.SafeFromJson<QuestRewardResponse>(result.downloadHandler.t |
| 0 | 26 | | return new List<QuestReward>(placesAPIResponse.items); |
| | 27 | | } |
| 0 | 28 | | catch (Exception e) |
| | 29 | | { |
| 0 | 30 | | return new List<QuestReward>() {}; |
| | 31 | | } |
| 0 | 32 | | } |
| | 33 | | } |
| | 34 | | } |