-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathClientsFactory.cs
More file actions
42 lines (36 loc) · 1.3 KB
/
ClientsFactory.cs
File metadata and controls
42 lines (36 loc) · 1.3 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
using Microsoft.Extensions.Logging;
using System.Net.Http;
namespace OsmSharp.IO.API
{
/// <inheritdoc/>
public class ClientsFactory : IClientsFactory
{
/// <summary>
/// The URL of the production instance of OSM's API. Use with care.
/// </summary>
public const string PRODUCTION_URL = @"https://api.openstreetmap.org/api/";
/// <summary>
/// The URL of the development instance of OSM's API. The correct place to do testing.
/// </summary>
public const string DEVELOPMENT_URL = @"https://master.apis.dev.openstreetmap.org/api/";
private readonly ILogger _logger;
private readonly HttpClient _httpClient;
private readonly string _baseAddress;
public ClientsFactory(ILogger logger, HttpClient httpClient, string baseAddress)
{
_logger = logger;
_httpClient = httpClient;
_baseAddress = baseAddress;
}
/// <inheritdoc/>
public INonAuthClient CreateNonAuthClient()
{
return new OsmClient(_baseAddress, _httpClient, null, _logger);
}
/// <inheritdoc/>
public IAuthClient CreateOAuth2Client(string token)
{
return new OsmClient(_baseAddress, _httpClient, token, _logger);
}
}
}