public static void InitConfig(string configRaw) { var dto = JsonSerializer.DeserializeObject <ConfigDto>(configRaw); ValidateConfig(dto); ApplicationEnvironment = dto !.ApplicationEnvironment !.Value; NotionTokenV2 = dto !.NotionTokenV2 !; DropboxAccessToken = dto !.DropboxAccessToken !; NotionWorkspaceId = dto !.NotionWorkspaceId !; UserName = dto !.UserName !; LogPath = dto !.LogPath !; RawConfig = dto; RawConfig.DropboxAccessToken = "SECRET"; RawConfig.NotionTokenV2 = "SECRET"; RawConfig.UserName = "******"; RawConfig.NotionWorkspaceId = "SECRET"; }
private async Task <TContentResult> MakePostRequestWithRetriesAsync <TRequest, TContentResult>(string relativeUrl, TRequest request) where TContentResult : class { var result = await ExecuteWithRetriesAsync(async() => await httpClient.SendAsync( new HttpRequestMessage(HttpMethod.Post, $"{BaseUrl}/{relativeUrl}") { Content = new StringContent(JsonSerializer.SerializeObject(request), Encoding.UTF8, "application/json") }).ConfigureAwait(false)).ConfigureAwait(false); if (result.StatusCode != HttpStatusCode.OK) { throw new WebException($"HTTP request unsuccessful. {result}"); } var contentResult = await ExecuteWithRetriesAsync( async() => JsonSerializer.DeserializeObject <TContentResult>(await result.Content .ReadAsStringAsync().ConfigureAwait(false))).ConfigureAwait(false); return(contentResult !); }