blob: 3ec0c6f4c6d1c63256bba46d086703baf0ede024 (
plain)
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
|
using System.Net.Http.Json;
namespace Enmarcha.Sources.CtagShuttle;
public class CtagShuttleRealtimeEstimatesProvider
{
private HttpClient _http;
public CtagShuttleRealtimeEstimatesProvider(HttpClient http)
{
_http = http;
}
public async Task<CtagShuttleStatus> GetShuttleStatus()
{
const string url = "https://shuttle.brain4mobility.com/status";
var response = await _http.GetAsync(url);
var status = await response.Content.ReadFromJsonAsync<CtagShuttleStatus>();
if (status is null)
{
throw new InvalidOperationException("Failed to retrieve shuttle status");
}
return status;
}
}
|