public async Task <StreamFlow> GetStreamFlow(params string[] sites)
        {
            var relativeUrl = GetRelativeUrl(sites);
            // i.e. https://waterservices.usgs.gov/nwis/iv/?sites=03539600&format=json&variable=00060,00065,00010
            var usgsIvUrl = $"{this.client.BaseAddress}{relativeUrl}";

            this.logger.LogInformation("Getting stream flow using: {usgsIvUrl}", usgsIvUrl);

            var json = await this.client.GetStringAsync(relativeUrl);

            this.logger.LogTrace(json);

            this.logger.LogTrace(
                "Parsing {length} bytes of json for sites {sites}",
                json.Length,
                string.Join(',', sites));
            var streamFlow = StreamFlow.FromJson(json);

            this.logger.LogInformation(
                "{length} bytes of JSON returned and parsed for {usgsIvUrl}",
                json.Length,
                usgsIvUrl);

            return(streamFlow);
        }
Exemple #2
0
 public static string ToJson(this StreamFlow self) => JsonConvert.SerializeObject(self, RiverFlowProcessor.USGS.Converter.Settings);