Skip to content

Commit

Permalink
Merge pull request #3 from felsokning/feature/Bus_Éireann
Browse files Browse the repository at this point in the history
Fix: Implementing Interface for DI for StopWrapper
  • Loading branch information
felsokning committed Mar 3, 2024
2 parents f9ddb70 + f40edf8 commit cd79f98
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Felsökning.Ireland/BusÉireann/IStopWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Felsökning.Ireland.BusÉireann
{
/// <summary>
/// Initializes a new instance of the <see cref="IStopWrapper"/> interface.
/// </summary>
public interface IStopWrapper
{
/// <summary>
/// Gets and stores the list of bus stops for a given geo location.
/// </summary>
/// <param name="latitudeNorth">Latitude North</param>
/// <param name="latitudeSouth">Latitude South</param>
/// <param name="longitudeEast">Longitude East</param>
/// <param name="longitudeWest">Longitude West</param>
/// <returns>An awaitable <see cref="Task"/>.</returns>
Task GetStopsForGeoLocationAsync(string latitudeNorth, string latitudeSouth, string longitudeEast, string longitudeWest);

/// <summary>
/// The Passages for an already retrieved list of stops.
/// <para><see cref="GetStopsForGeoLocationAsync"/> MUST be called, first.</para>
/// </summary>
/// <returns>An awaitable <see cref="Task{TaskToAsyncResult}"/> of <see cref="List{T}"/> of <see cref="CorrelatedPassages"/>.</returns>
Task<List<CorrelatedPassages>> GetPassagesForStopsAsync();
}
}
17 changes: 16 additions & 1 deletion Felsökning.Ireland/BusÉireann/StopWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
/// Initializes a new instance of the <see cref="StopWrapper"/> class,
/// which is used to wrap calls to the Proto Stop API endpoints.
/// </summary>
public class StopWrapper : HttpBase
/// <inheritdoc cref="HttpBase"/>
/// <inheritdoc cref="IStopWrapper"/>
public class StopWrapper : HttpBase, IStopWrapper
{
private const string _baseAddress = "https://www.buseireann.ie/inc/proto/";

Expand All @@ -21,6 +23,14 @@ public StopWrapper()
this.BusStops = new List<BusStop>(0);
}

/// <summary>
/// Gets and stores the list of bus stops for a given geo location.
/// </summary>
/// <param name="latitudeNorth">Latitude North</param>
/// <param name="latitudeSouth">Latitude South</param>
/// <param name="longitudeEast">Longitude East</param>
/// <param name="longitudeWest">Longitude West</param>
/// <returns>An awaitable <see cref="Task"/>.</returns>
public async Task GetStopsForGeoLocationAsync(string latitudeNorth, string latitudeSouth, string longitudeEast, string longitudeWest)
{
var instanceTime = Math.Round((DateTime.UtcNow - DateTime.UnixEpoch).TotalMilliseconds, 0);
Expand All @@ -42,6 +52,11 @@ public async Task GetStopsForGeoLocationAsync(string latitudeNorth, string latit
}
}

/// <summary>
/// The Passages for an already retrieved list of stops.
/// <para><see cref="GetStopsForGeoLocationAsync"/> MUST be called, first.</para>
/// </summary>
/// <returns>An awaitable <see cref="Task{TaskToAsyncResult}"/> of <see cref="List{T}"/> of <see cref="CorrelatedPassages"/>.</returns>
public async Task<List<CorrelatedPassages>> GetPassagesForStopsAsync()
{
if (this.BusStops.Count == 0)
Expand Down

0 comments on commit cd79f98

Please sign in to comment.