|
1 |
| -using System.Net; |
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Net; |
2 | 3 | using System.Net.Http.Headers;
|
3 | 4 | using System.Text;
|
4 | 5 | using Newtonsoft.Json;
|
5 | 6 |
|
6 | 7 | namespace Svix
|
7 | 8 | {
|
8 |
| - public class SvixHttpClient(string token, SvixOptions options, string userAgent) |
| 9 | + public class SvixHttpClient( |
| 10 | + string token, |
| 11 | + List<int> retryScheduleMilliseconds, |
| 12 | + string userAgent, |
| 13 | + string serverUrl |
| 14 | + ) |
9 | 15 | {
|
10 |
| - readonly SvixOptions _options = options; |
11 |
| - readonly HttpClient _httpClient = new(); |
| 16 | + private readonly List<int> retryScheduleMilliseconds = retryScheduleMilliseconds; |
| 17 | + private readonly string serverUrl = serverUrl; |
| 18 | + private readonly HttpClient _httpClient = new(); |
12 | 19 | private readonly string _token = token;
|
13 | 20 | private readonly JsonSerializerSettings patchJsonOptions = new();
|
14 | 21 | private readonly JsonSerializerSettings JsonOptions = new()
|
@@ -63,13 +70,13 @@ public async Task<ApiResponse<T>> SendRequestAsync<T>(
|
63 | 70 | content
|
64 | 71 | );
|
65 | 72 | var response = await _httpClient.SendAsync(request, cancellationToken);
|
66 |
| - for (var index = 0; index < _options.RetryScheduleMilliseconds.Count; index++) |
| 73 | + for (var index = 0; index < retryScheduleMilliseconds.Count; index++) |
67 | 74 | {
|
68 | 75 | if ((int)response.StatusCode < 500)
|
69 | 76 | {
|
70 | 77 | break;
|
71 | 78 | }
|
72 |
| - Thread.Sleep(_options.RetryScheduleMilliseconds[index]); |
| 79 | + Thread.Sleep(retryScheduleMilliseconds[index]); |
73 | 80 | HttpRequestMessage retryRequest = BuildRequest(
|
74 | 81 | method,
|
75 | 82 | path,
|
@@ -131,7 +138,7 @@ HttpRequestMessage BuildRequest(
|
131 | 138 | object? content = null
|
132 | 139 | )
|
133 | 140 | {
|
134 |
| - var url = _options.BaseUrl; |
| 141 | + var url = serverUrl; |
135 | 142 |
|
136 | 143 | // Apply path parameters if provided
|
137 | 144 | if (pathParams != null)
|
|
0 commit comments