public static SampleQuotesByPeriod ForGsp(this Dictionary <string, SampleQuotesByPeriod> value, string gsp) { Assertions.AssertValidGsp(gsp); if (value.ContainsKey(gsp)) { return(value[gsp]); } throw new ArgumentOutOfRangeException( string.Format(CultureInfo.CurrentCulture, Resources.GspNotSupported, gsp), nameof(gsp)); }
public async Task <string> GetGridSupplyPointByMpanAsync(string mpan) { var uriString = ComposeGetGridSupplyPointByMpanUri(mpan); var result = await GetAsync <MeterPointGridSupplyPoint>(new Uri(uriString)); Debug.Assert(result != null); var gsp = result.GroupId; Assertions.AssertValidGsp(gsp); return(gsp); }
public async Task <string> GetGridSupplyPointByPostcodeAsync(string postcode) { var uri = ComposeGetGridSupplyPointByPostcodeUri(postcode); var result = await GetCollectionAsync <GridSupplyPoint>(uri); Debug.Assert(result != null); if (!result.Any()) { throw new GspException(Resources.NoGspFound); } if (result.Count() > 1) { throw new GspException(Resources.MultipleGspFound); } var gsp = result.Single().GroupId; Assertions.AssertValidGsp(gsp); return(gsp); }