-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d671fa1
commit 2458d8a
Showing
10 changed files
with
263 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using RestSharp; | ||
|
||
namespace DepartureBoardCore.DataSource; | ||
|
||
public class TflBase | ||
{ | ||
protected readonly RestClient _client = new RestClient("https://api.tfl.gov.uk"); | ||
protected static string AppKey => ConfigService.TflApiToken; | ||
protected JsonSerializerOptions SerializerOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; | ||
protected RestResponse SendRequest(RestRequest request) | ||
{ | ||
request.AddQueryParameter("app_key", AppKey); | ||
return _client.Execute(request); | ||
} | ||
|
||
protected int? GetConvertedTimeToStation(int? timeInSeconds) | ||
{ | ||
if (!timeInSeconds.HasValue) | ||
return null; | ||
|
||
return Convert.ToInt32(Math.Ceiling(timeInSeconds.Value / 60m)); | ||
} | ||
|
||
public class TflStopPointResponse | ||
{ | ||
public List<StopPoint> StopPoints { get; set; } | ||
} | ||
|
||
public class StopPoint | ||
{ | ||
public string NaptanId { get; set; } | ||
public string StationNaptan { get; set; } | ||
public string CommonName { get; set; } | ||
public string PlatformName { get; set; } | ||
public List<string> Modes { get; set; } | ||
public List<dynamic> Lines { get; set; } | ||
} | ||
|
||
public class TflArrival | ||
{ | ||
public string StationName { get; set; } | ||
public string LineName { get; set; } | ||
public string DestinationName { get; set; } | ||
public DateTime ExpectedArrival { get; set; } | ||
public string PlatformName { get; set; } | ||
public int? TimeToStation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.