| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL; |
| | 3 | | using DCL.Backpack; |
| | 4 | | using DCLServices.Lambdas; |
| | 5 | | using System; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using System.Threading; |
| | 8 | | using UnityEngine; |
| | 9 | |
|
| | 10 | | public class LambdaOutfitsService |
| | 11 | | { |
| | 12 | | private const string OUTFITS_ENDPOINT = "outfits/"; |
| | 13 | | private readonly ILambdasService lambdasService; |
| | 14 | | private ICatalyst catalyst; |
| | 15 | |
|
| 25 | 16 | | public LambdaOutfitsService(ILambdasService lambdasService, IServiceProviders serviceProviders) |
| | 17 | | { |
| 25 | 18 | | this.lambdasService = lambdasService; |
| 25 | 19 | | this.catalyst = serviceProviders.catalyst; |
| 25 | 20 | | } |
| | 21 | |
|
| | 22 | | public async UniTask<(IReadOnlyList<OutfitItem> outfits, int totalAmount)> RequestOwnedOutfits( |
| | 23 | | string userId, |
| | 24 | | CancellationToken cancellationToken) |
| | 25 | | { |
| 0 | 26 | | (OutfitsResponse response, bool success) = await lambdasService.Get<OutfitsResponse>( |
| | 27 | | OUTFITS_ENDPOINT + userId, |
| | 28 | | OUTFITS_ENDPOINT + userId, |
| | 29 | | cancellationToken: cancellationToken); |
| | 30 | |
|
| | 31 | |
|
| 0 | 32 | | if (!success) |
| 0 | 33 | | throw new Exception($"The request of outfits for '{userId}' failed!"); |
| | 34 | |
|
| 0 | 35 | | return (response.metadata.outfits, response.metadata.outfits.Length); |
| 0 | 36 | | } |
| | 37 | | } |