| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using Newtonsoft.Json; |
| | 4 | | using Newtonsoft.Json.Linq; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | namespace DCL.Builder |
| | 8 | | { |
| | 9 | | public interface IBuilderAPIResponseResolver |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Resolve the data from the call removing de OK response |
| | 13 | | /// </summary> |
| | 14 | | /// <param name="result"></param> |
| | 15 | | /// <returns></returns> |
| | 16 | | T[] GetArrayFromCall<T>(string result); |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Resolve the data from the call removing de OK response |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="result"></param> |
| | 22 | | /// <returns></returns> |
| | 23 | | APIResponse GetResponseFromCall(string result); |
| | 24 | | } |
| | 25 | |
|
| | 26 | | public class BuilderAPIResponseResolver: IBuilderAPIResponseResolver |
| | 27 | | { |
| | 28 | | public T[] GetArrayFromCall<T>(string result) |
| | 29 | | { |
| 0 | 30 | | APIResponse response = GetResponseFromCall(result); |
| 0 | 31 | | string array = response.GetArrayJsonString(); |
| 0 | 32 | | return JsonConvert.DeserializeObject<T[]>(array); |
| | 33 | | } |
| | 34 | |
|
| | 35 | | public APIResponse GetResponseFromCall(string result) |
| | 36 | | { |
| 0 | 37 | | APIResponse response = JsonConvert.DeserializeObject<APIResponse>(result); |
| 0 | 38 | | return response; |
| | 39 | | } |
| | 40 | | } |
| | 41 | | } |