public async Task UnfollowAnAuthor() { var authorId = 1077326; var authorFollowing = await AuthorsFollowingClient.Follow(authorId); // arrange following var result = await AuthorsFollowingClient.Unfollow(authorFollowing.Id); // cleanup following Assert.True(result); }
public async Task FollowAnAuthor() { var authorId = 3173264; var authorFollowing = await AuthorsFollowingClient.Follow(authorId); await AuthorsFollowingClient.Unfollow(authorFollowing.Id); // cleanup following Assert.NotNull(authorFollowing); Assert.NotSame(authorFollowing.Id, default(int)); }
public async Task Show() { var authorId = 4470846; var followInfo = await AuthorsFollowingClient.Follow(authorId); // arrange following var responseInfo = await AuthorsFollowingClient.Show(followInfo.Id); await AuthorsFollowingClient.Unfollow(followInfo.Id); // cleanup following Assert.NotNull(responseInfo); Assert.Equal(followInfo.Id, responseInfo.Id); Assert.Equal(followInfo.Author.Id, responseInfo.Author.Id); Assert.Equal(followInfo.User.Id, responseInfo.User.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); }
public async Task ShowNotExistingInfo() { var responseInfo = await AuthorsFollowingClient.Show(51523178); Assert.Null(responseInfo); }