ACMESharp.Providers.CloudFlare.CloudFlareHelper.GetZoneId C# (CSharp) Method

GetZoneId() private method

private GetZoneId ( ) : string
return string
        private string GetZoneId()
        {
            List<Zone> zones = new List<Zone>();
            bool finishedPaginating = false;
            int page = 1;
            HttpClient client = new HttpClient();
            while (!finishedPaginating)
            {
                var request = CreateRequest(HttpMethod.Get, $"{ListZonesUrl}?page={page}");
                var result = client.SendAsync(request).GetAwaiter().GetResult();
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                    var zonesResult = JsonConvert.DeserializeObject<ZoneResult>(content);
                    zones.AddRange(zonesResult.Result);
                    if (zonesResult.ResultInfo.Page == zonesResult.ResultInfo.TotalPages)
                    {
                        finishedPaginating = true;
                    }
                    else
                    {
                        page = page + 1;
                    }
                }
                else
                {
                    throw new Exception(
                            $"Could not retrieve a zone id for domain name {_domainName}. Result: {result.StatusCode} - {result.Content.ReadAsStringAsync().GetAwaiter().GetResult()}");
                }
            }
            var zoneResult = zones.FirstOrDefault(x => x.Name == _domainName);
            if (zoneResult == null)
            {
                throw new Exception($"Could not fine a zone with matching domain name. Provided domain name: {_domainName}");
            }
            return zoneResult.Id;
        }