/// <summary>
        /// Attach Domain to a zone asynchronously
        /// </summary>
        /// <param name="uuid">The uuid of the zone</param>
        /// <param name="fqdn">Domain name</param>
        /// <returns>an error code and the json response</returns>
        public async Task <DomainDetailResponse> AttachDomainAsync(string uuid, string fqdn)
        {
            ApiResponse resp = await _client.AttachDomainAsync(uuid, fqdn);

            DomainDetailResponse retour = new DomainDetailResponse();

            retour.Load(resp);
            return(retour);
        }
        /// <summary>
        /// Get Domain detail
        /// </summary>
        /// <param name="fqdn">The fqdn of the Domain</param>
        /// <returns>False if error or if id doesn't exist else true </returns>
        public async Task <DomainDetailResponse> GetDetailAsync(string fqdn)
        {
            ApiResponse resp = await _client.GetDetailAsync(fqdn);

            DomainDetailResponse retour = new DomainDetailResponse();

            retour.Load(resp);
            return(retour);
        }
        /// <summary>
        /// Function to update a domain in Gandi
        /// </summary>
        /// <param name="domain">domain name</param>
        /// <param name="apikey">The Gandi api key</param>
        /// <returns>a message in case of error</returns>
        public static string UpdateDomainGandi(string domain, string apikey)
        {
            //Read ip
            //https://api.ipify.org?format=json
            //https://api.myip.com
            //https://ip.seeip.org/jsonip?
            // brute
            //http://ipv4bot.whatismyipaddress.com/
            string ip = GetIPJson("https://api.ipify.org?format=json");

            if (string.IsNullOrEmpty(ip))
            {
                ip = GetIPJson("https://api.myip.com");
            }
            if (string.IsNullOrEmpty(ip))
            {
                ip = GetIPJson("https://ip.seeip.org/jsonip?");
            }
            if (string.IsNullOrEmpty(ip))
            {
                ip = GetIP("http://ipv4bot.whatismyipaddress.com/");
            }

            using (ManagerZone GandiZone = new ManagerZone("https://dns.api.gandi.net/api/v5/", apikey))
                using (ManagerDomain GandiDomain = new ManagerDomain("https://dns.api.gandi.net/api/v5/", apikey))
                {
                    DomainDetailResponse rep = GandiDomain.GetDetail(domain);
                    if (rep.ErrorMessage != null)
                    {
                        return("Error occurs on getting domain :" + domain + " \r\nError:" + rep.ErrorMessage.GetMessage());
                    }

                    RecordListResponse rec = GandiZone.GetAllRecords(rep.Data.Domain.ZoneUuid);
                    if (rec.ErrorMessage != null)
                    {
                        return("Error occurs on getting Record of zone :" + rep.Data.Domain.ZoneUuid + " \r\nError:" + rec.ErrorMessage.GetMessage());
                    }

                    //find record and modify it if different
                    foreach (RecordDto r in rec.Data.Records)
                    {
                        if (r.RrsetName == "@" && r.RrsetType == "A")
                        {
                            string before = string.Empty;
                            foreach (string s in r.RrsetValues)
                            {
                                before += s + " ";
                                if (s == ip)
                                {
                                    return(string.Empty);
                                }
                            }

                            r.RrsetValues = new List <string>()
                            {
                                ip
                            };
                            ZoneUpdateResponse zu = GandiZone.UpdateOneRecords(rep.Data.Domain.ZoneUuid, "@", "A", r);
                            if (rec.ErrorMessage != null)
                            {
                                return("Error occurs on update Record @ A with ip :" + ip + " of zone :" + rep.Data.Domain.ZoneUuid + " \r\nError:" + rec.ErrorMessage.GetMessage());
                            }
                        }
                    }
                }

            return(string.Empty);
        }