-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathIGeolocationService.cs
More file actions
87 lines (73 loc) · 2.61 KB
/
IGeolocationService.cs
File metadata and controls
87 lines (73 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace CleanArchitecture.Blazor.Application.Common.Interfaces;
/// <summary>
/// Service for retrieving geolocation information based on IP addresses.
/// </summary>
public interface IGeolocationService
{
/// <summary>
/// Gets the country code for the specified IP address.
/// </summary>
/// <param name="ipAddress">The IP address to look up.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The ISO 3166-1 alpha-2 country code, or null if lookup fails.</returns>
Task<string?> GetCountryAsync(string ipAddress, CancellationToken cancellationToken = default);
/// <summary>
/// Gets detailed geolocation information for the specified IP address.
/// </summary>
/// <param name="ipAddress">The IP address to look up.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Geolocation information, or null if lookup fails.</returns>
Task<GeolocationInfo?> GetGeolocationAsync(string ipAddress, CancellationToken cancellationToken = default);
}
/// <summary>
/// Represents geolocation information for an IP address.
/// </summary>
public class GeolocationInfo
{
/// <summary>
/// Gets or sets the IP address.
/// </summary>
public string IpAddress { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the ISO 3166-1 alpha-2 country code.
/// </summary>
public string? Country { get; set; }
/// <summary>
/// Gets or sets the country name.
/// </summary>
public string? CountryName { get; set; }
/// <summary>
/// Gets or sets the region or state.
/// </summary>
public string? Region { get; set; }
/// <summary>
/// Gets or sets the city.
/// </summary>
public string? City { get; set; }
/// <summary>
/// Gets or sets the postal code.
/// </summary>
public string? PostalCode { get; set; }
/// <summary>
/// Gets or sets the latitude.
/// </summary>
public double? Latitude { get; set; }
/// <summary>
/// Gets or sets the longitude.
/// </summary>
public double? Longitude { get; set; }
/// <summary>
/// Gets or sets the timezone.
/// </summary>
public string? Timezone { get; set; }
/// <summary>
/// Gets or sets the Internet Service Provider (ISP).
/// </summary>
public string? Isp { get; set; }
/// <summary>
/// Gets or sets the organization.
/// </summary>
public string? Organization { get; set; }
}