private async Task <bool> TryGetEntitiesWithLegacyApiV3() { var mark = Mark.CreateNew(); var url = this._shopUrl + ProductsLegacyApiV3Url; try { return(await new ActionPolicy(this._retryAttempts).ExecuteAsync <bool>(async() => { var response = await this._httpClient.GetAsync(url).ConfigureAwait(false); var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return response.StatusCode == System.Net.HttpStatusCode.NotFound && !string.IsNullOrWhiteSpace(content) && content.Contains("api_authentication_error"); }, (timeSpan, retryCount) => { string retryDetails = Misc.CreateMethodCallInfo(url, mark); WooCommerceLogger.LogTraceRetryStarted(timeSpan.Seconds, retryCount, retryDetails); }, () => Misc.CreateMethodCallInfo(url, mark), WooCommerceLogger.LogTraceException).ConfigureAwait(false)); } catch { return(false); } }
private async Task <bool> TryGetV3JsonApiDescription() { var mark = Mark.CreateNew(); var url = this._shopUrl + JsonApiV3DescriptionUrl; try { return(await new ActionPolicy(this._retryAttempts).ExecuteAsync <bool>(async() => { var response = await this._httpClient.GetAsync(url).ConfigureAwait(false); return response.StatusCode == System.Net.HttpStatusCode.OK; }, (timeSpan, retryCount) => { string retryDetails = Misc.CreateMethodCallInfo(url, mark); WooCommerceLogger.LogTraceRetryStarted(timeSpan.Seconds, retryCount, retryDetails); }, () => Misc.CreateMethodCallInfo(url, mark), WooCommerceLogger.LogTraceException).ConfigureAwait(false)); } catch { return(false); } }