| | 1 | | using System; |
| | 2 | |
|
| | 3 | | namespace DCL.Helpers.NFT.Markets.OpenSea_Internal |
| | 4 | | { |
| | 5 | | public abstract class RequestBase<T> |
| | 6 | | { |
| | 7 | | public event Action<RequestBase<T>> OnSuccess; |
| | 8 | | public event Action<RequestBase<T>> OnFail; |
| | 9 | |
|
| 0 | 10 | | public bool resolved { private set; get; } |
| 0 | 11 | | public bool rejected { private set; get; } |
| 0 | 12 | | public bool pending => !rejected && !resolved; |
| 0 | 13 | | public string error { private set; get; } |
| | 14 | | public abstract string requestId { get; } |
| | 15 | |
|
| 0 | 16 | | public T resolvedValue { private set; get; } |
| | 17 | |
|
| | 18 | | public void Resolve(T response) |
| | 19 | | { |
| 0 | 20 | | resolvedValue = response; |
| 0 | 21 | | resolved = true; |
| 0 | 22 | | OnSuccess?.Invoke(this); |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | public void Reject(string error) |
| | 26 | | { |
| 0 | 27 | | this.error = error; |
| 0 | 28 | | rejected = true; |
| 0 | 29 | | OnFail?.Invoke(this); |
| 0 | 30 | | } |
| | 31 | | } |
| | 32 | | } |