public ICollection <ShelfItem> GetBookIds(string userId, string shelfName, byte perPage) { _call.BaseUrl = "https://www.goodreads.com/review/list/" + userId; _call.QueryParams.Add("format", "json"); _call.QueryParams.Add("key", _key); _call.QueryParams.Add("v", "2"); _call.QueryParams.Add("shelf", shelfName); if (perPage > 0) { _call.QueryParams.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture)); } var result = _call.Execute <ShelfItem[]>(); return(result.DataItem); }
public void ReturnsExpectedResultWithCustomApi() { const string endPoint = "https://maps.googleapis.com/maps/api/distancematrix/json?sensor=false&origins=95969&destinations=95928"; using (IApiCall client = new ApiCall(endPoint, new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() })) { var result = client.Execute <DistanceResults>(); Assert.Equal(HttpStatusCode.OK, result.StatusCode); var resultDuration = ParseDuration((string)result.DataItem.GetResult(0).Duration.Text); resultDuration.ShouldBeInRange(20, 30); } }
public void ReturnsResultWithCustomApiAndQueryParams() { const string baseUri = "https://maps.googleapis.com/maps/api/distancematrix/json"; // sensor=false&origins=95969&destinations=95928 using (IApiCall client = new ApiCall(baseUri, new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() })) { client.QueryParams.Add("sensor", "false"); client.QueryParams.Add("origins", "95969"); client.QueryParams.Add("destinations", "95928"); var result = client.Execute <DistanceResults>(); Assert.Equal(HttpStatusCode.OK, result.StatusCode); var resultDuration = ParseDuration((string)result.DataItem.GetResult(0).Duration.Text); resultDuration.ShouldBeInRange(20, 30); } }