| | | 1 | | using System.Text.Json; |
| | | 2 | | using TeleFlow.Telegram.Schema.Types; |
| | | 3 | | |
| | | 4 | | namespace TeleFlow.Telegram.Internal; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Owns a parsed Telegram Bot API response envelope for one request attempt. |
| | | 8 | | /// The request executor uses it to decide between success, API error, retry-after, and decode failure paths. |
| | | 9 | | /// </summary> |
| | | 10 | | internal sealed class TelegramTransportEnvelope : IDisposable |
| | | 11 | | { |
| | | 12 | | private readonly JsonDocument _document; |
| | | 13 | | |
| | | 14 | | public TelegramTransportEnvelope( |
| | | 15 | | JsonDocument document, |
| | | 16 | | bool ok, |
| | | 17 | | bool hasResult, |
| | | 18 | | JsonElement result, |
| | | 19 | | string? description, |
| | | 20 | | int? errorCode, |
| | | 21 | | ResponseParameters? responseParameters) |
| | | 22 | | { |
| | 82 | 23 | | ArgumentNullException.ThrowIfNull(document); |
| | | 24 | | |
| | 82 | 25 | | _document = document; |
| | | 26 | | Ok = ok; |
| | | 27 | | HasResult = hasResult; |
| | | 28 | | Result = result; |
| | | 29 | | Description = description; |
| | | 30 | | ErrorCode = errorCode; |
| | | 31 | | ResponseParameters = responseParameters; |
| | 82 | 32 | | } |
| | | 33 | | |
| | | 34 | | public bool Ok { get; } |
| | | 35 | | |
| | | 36 | | public bool HasResult { get; } |
| | | 37 | | |
| | | 38 | | public JsonElement Result { get; } |
| | | 39 | | |
| | | 40 | | public string? Description { get; } |
| | | 41 | | |
| | | 42 | | public int? ErrorCode { get; } |
| | | 43 | | |
| | | 44 | | public ResponseParameters? ResponseParameters { get; } |
| | | 45 | | |
| | | 46 | | public void Dispose() |
| | | 47 | | { |
| | 82 | 48 | | _document.Dispose(); |
| | 82 | 49 | | } |
| | | 50 | | } |