Example #1
0
 internal static IPDetails ConvertToIPDetails(this IPStackResponseModel resp)
 {
     return(new IP_Details
     {
         City = resp.City,
         Continent = resp.ContinentName,
         Country = resp.CountryName,
         Latitude = resp.Latitude,
         Longitude = resp.Longitude
     });
 }
Example #2
0
        public async Task <IPDetails> GetDetails(string ip)
        {
            ip.Validate();

            IPDetails details;

            try
            {
                IRestResponse restResp = await GetDetailsFromIpStack(ip);

                IsAnticipatedResponse(restResp);
                IPStackResponseModel resp = DeserializeResponse <IPStackResponseModel>(restResp);
                details = resp.ConvertToIPDetails();
            }
            catch (Exception ex)
            {
                throw new IPServiceNotAvailableException(ex.Message, ex.InnerException);
            }

            return(details);
        }