예제 #1
0
        /// <summary>
        /// Inyternal method to retrieve depatures and arrivals
        /// </summary>
        /// <param name="stationId">Id of the train station</param>
        /// <param name="dateTime">The timestamp for the request</param>
        /// <param name="endpoint">arrivalBoard or depatureBoard</param>
        /// <returns></returns>
        private async Task <IList <TrainStationEvent> > GetTrainStationEvents(
            long stationId,
            DateTime dateTime,
            string endpoint)
        {
            string dt      = dateTime.ToString("s", CultureInfo.InvariantCulture);
            string reqAddr = $"{_apiBaseUrl}{_apiBasePath}{endpoint}/{stationId}?date={dt}";

            return(await LokomotivHttpClient.Get <List <TrainStationEvent> >(_http, reqAddr));
        }
예제 #2
0
        /// <summary>
        /// Looks up train stations by location name
        /// </summary>
        /// <param name="locName">Location search term</param>
        /// <returns></returns>
        public async Task <IList <TrainStation> > FindLocation(string locName)
        {
            if (String.IsNullOrWhiteSpace(locName))
            {
                throw new LokomotivException("Cannot lookup empty name");
            }

            string reqAddr = $"{_apiBaseUrl}{_apiBasePath}location/{locName}";

            return(await LokomotivHttpClient.Get <List <TrainStation> >(_http, reqAddr));
        }
예제 #3
0
        /// <summary>
        /// Returns the details of a journey.
        /// </summary>
        /// <param name="detailsId">The journey id can be retrieved from a arrival/depature list</param>
        /// <returns></returns>
        public async Task <IList <JourneyEvent> > GetJourneyDetails(string detailsId)
        {
            if (String.IsNullOrWhiteSpace(detailsId))
            {
                throw new LokomotivException("Cannot lookup empty name");
            }

            string reqAddr = $"{_apiBaseUrl}{_apiBasePath}journeyDetails/{detailsId}";

            return(await LokomotivHttpClient.Get <List <JourneyEvent> >(_http, reqAddr));
        }