public void Request_url_returns_correct_format() { var expectedUrl = "?url=google.com"; var requestUrl = RequestUrlHelpers.ConstructRequest("google.com"); Assert.Equal(expectedUrl, requestUrl); }
public void Request_url_returns_correct_format_with_timestamp() { var expectedUrl = "?url=google.com×tamp=20201001000000"; var requestUrl = RequestUrlHelpers.ConstructRequestWithTimestamp("google.com", new DateTime(2020, 10, 01)); Assert.Equal(expectedUrl, requestUrl); }
public Task <ForecastedMarginalPowerConsumptionBreakdown> GetForecastedMarginalPowerConsumptionBreakdownAsync(double latitude, double longitude) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.MarginalPowerConsumptionBreakdown, ApiActions.Forecast, latitude, longitude); return(httpFacade .GetAsync <ForecastedMarginalPowerConsumptionBreakdown>(requestUrl)); }
public Task <ForecastedMarginalCarbonIntensity> GetForecastedMarginalCarbonIntensityAsync(string zone) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.MarginalCarbonIntensity, ApiActions.Forecast, zone); return(httpFacade .GetAsync <ForecastedMarginalCarbonIntensity>(requestUrl)); }
public Task <PastPowerBreakdownHistory> GetPastPowerBreakdownHistoryAsync(string zone, DateTime datetime) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.PowerConsumptionBreakdown, ApiActions.Past, zone, datetime); return(httpFacade .GetAsync <PastPowerBreakdownHistory>(requestUrl)); }
public Task <PastCarbonIntensityHistory> GetPastCarbonIntensityHistoryAsync(double latitude, double longitude, DateTime datetime) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.CarbonIntensity, ApiActions.Past, latitude, longitude, datetime); return(httpFacade .GetAsync <PastCarbonIntensityHistory>(requestUrl)); }
public Task <RecentPowerBreakdownHistory> GetRecentPowerBreakdownHistoryAsync(double latitude, double longitude) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.PowerConsumptionBreakdown, ApiActions.History, latitude, longitude); return(httpFacade .GetAsync <RecentPowerBreakdownHistory>(requestUrl)); }
public Task <UpdatedSince> GetUpdateInfoAsync(UpdatedSinceRequest updatedSinceRequest) { var requestUrl = RequestUrlHelpers .ConstructRequest(updatedSinceRequest); return(httpFacade .GetAsync <UpdatedSince>(requestUrl)); }
public Task <Dictionary <string, ZoneData> > GetAvailableZonesAsync() { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.Zones); return(httpFacade .GetAsync <Dictionary <string, ZoneData> >(requestUrl)); }
public Task <RecentPowerBreakdownHistory> GetRecentPowerBreakdownHistoryAsync(string zone) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.PowerConsumptionBreakdown, ApiActions.History, zone); return(httpFacade .GetAsync <RecentPowerBreakdownHistory>(requestUrl)); }
public Task <RecentCarbonIntensityHistory> GetRecentCarbonIntensityHistoryAsync(string zone) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.CarbonIntensity, ApiActions.History, zone); return(httpFacade .GetAsync <RecentCarbonIntensityHistory>(requestUrl)); }
public Task <RecentCarbonIntensityHistory> GetRecentCarbonIntensityHistoryAsync(double latitude, double longitude) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.CarbonIntensity, ApiActions.History, latitude, longitude); return(httpFacade .GetAsync <RecentCarbonIntensityHistory>(requestUrl)); }
public Task <LivePowerBreakdown> GetLivePowerBreakdownAsync(double latitude, double longitude) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.PowerConsumptionBreakdown, ApiActions.Latest, latitude, longitude); return(httpFacade .GetAsync <LivePowerBreakdown>(requestUrl)); }
public Task <LivePowerBreakdown> GetLivePowerBreakdownAsync(string zone) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.PowerConsumptionBreakdown, ApiActions.Latest, zone); return(httpFacade .GetAsync <LivePowerBreakdown>(requestUrl)); }
public Task <LiveCarbonIntensity> GetLiveCarbonIntensityAsync(double latitude, double longitude) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.CarbonIntensity, ApiActions.Latest, latitude, longitude); return(httpFacade .GetAsync <LiveCarbonIntensity>(requestUrl)); }
public Task <LiveCarbonIntensity> GetLiveCarbonIntensityAsync(string zone) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.CarbonIntensity, ApiActions.Latest, zone); return(httpFacade .GetAsync <LiveCarbonIntensity>(requestUrl)); }
public Task <ForecastedMarginalCarbonIntensity> GetForecastedMarginalCarbonIntensityAsync( double latitude, double longitude) { var requestUrl = RequestUrlHelpers .ConstructRequest(ApiAreas.MarginalCarbonIntensity, ApiActions.Forecast, latitude, longitude); return(httpFacade .GetAsync <ForecastedMarginalCarbonIntensity>(requestUrl)); }
public async Task <Snapshot> GetSnapshotClosestToDateAsync(string url, DateTime date) { string requestUrl = RequestUrlHelpers.ConstructRequestWithTimestamp(url, date); HttpResponseMessage response = await httpClient.GetAsync(requestUrl); response.EnsureSuccessStatusCode(); string responseString = await response.Content.ReadAsStringAsync(); Snapshot snapshot = JsonConvert.DeserializeObject <Snapshot>(responseString); return(snapshot); }
public async Task <bool> HasSnapshot(string url) { string requestUrl = RequestUrlHelpers.ConstructRequest(url); HttpResponseMessage response = await httpClient.GetAsync(requestUrl); response.EnsureSuccessStatusCode(); string responseString = await response.Content.ReadAsStringAsync(); Snapshot snapshot = JsonConvert.DeserializeObject <Snapshot>(responseString); return(snapshot.ArchivedSnapshots.Closest != null); }