public async Task GetRecommendations() { const int id = 26826409; var recommendation = await RecommendationsClient.GetRecommendation(id); Assert.NotNull(recommendation); Assert.Equal(recommendation.Id, id); }
/// <summary> /// Initializes a new instance of the <see cref="GoodreadsClient"/> class. /// Use this constructor if you already have OAuth permissions for the user. /// </summary> /// <param name="apiKey">Your Goodreads API key.</param> /// <param name="apiSecret">Your Goodreads API secret.</param> /// <param name="accessToken">The user's OAuth access token.</param> /// <param name="accessSecret">The user's OAuth access secret.</param> public GoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret) { var client = new RestClient(new Uri(GoodreadsUrl)) { UserAgent = "goodreads-dotnet" }; client.AddDefaultParameter("key", apiKey, ParameterType.QueryString); client.AddDefaultParameter("format", "xml", ParameterType.QueryString); var apiCredentials = new ApiCredentials(client, apiKey, apiSecret, accessToken, accessSecret); // Setup the OAuth authenticator if they have passed on the appropriate tokens if (!string.IsNullOrWhiteSpace(accessToken) && !string.IsNullOrWhiteSpace(accessSecret)) { client.Authenticator = OAuth1Authenticator.ForProtectedResource( apiKey, apiSecret, accessToken, accessSecret); } Connection = new Connection(client, apiCredentials); Authors = new AuthorsClient(Connection); Books = new BooksClient(Connection); Shelves = new ShelvesClient(Connection); Users = new UsersClient(Connection); Reviews = new ReviewsClient(Connection); Series = new SeriesClient(Connection); AuthorsFollowing = new AuthorsFollowingClient(Connection); Events = new EventsClient(Connection); Followers = new FollowersClient(Connection); Friends = new FriendsClient(Connection); Notifications = new NotificationsClient(Connection); Groups = new GroupClient(Connection); Quotes = new QuotesClient(Connection); UserStatuses = new UserStatusesClient(Connection); Updates = new UpdatesClient(Connection); Recommendations = new RecommendationsClient(Connection); ReadStatuses = new ReadStatusesClient(Connection); }