Exemple #1
0
        public async Task GetByUsernameAsync()
        {
            var apiConnection = Substitute.For <IApiConnection>();
            var client        = new PodcastEpisodeClient(apiConnection);

            await client.GetByUsernameAsync("test");

            await apiConnection.Received().ExecutePaginationGetAsync <PodcastEpisode>("podcast_episodes?username=test", Arg.Any <PageQueryOption>());
        }
Exemple #2
0
        public async Task GetByUsernameAsync_UsernameEmpty_Throw()
        {
            var apiConnection = Substitute.For <IApiConnection>();
            var client        = new PodcastEpisodeClient(apiConnection);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await client.GetByUsernameAsync(string.Empty));

            await apiConnection.DidNotReceive().ExecutePaginationGetAsync <PodcastEpisode>(Arg.Any <string>(), Arg.Any <PageQueryOption>());
        }
Exemple #3
0
        /// <summary>
        /// API client
        /// </summary>
        /// <remarks>
        /// See the <a href="https://docs.dev.to/api/#section/Authentication/api_key">Authentication</a> for more information
        /// </remarks>
        /// <param name="apiUrl">API connection url</param>
        /// <param name="token">API key</param>
        public DevToClient(string apiUrl, string token)
        {
            var restClient = new RestClient(apiUrl);

            restClient.AddDefaultHeader("api-key", token);
            restClient.AddDefaultHeader("User-Agent", "DevToAPI-client-dotnet");
            var apiConnection = new ApiConnection(restClient);

            AdminConfigurations = new AdminConfigurationClient(apiConnection);
            Articles            = new ArticleClient(apiConnection);
            Comments            = new CommentClient(apiConnection);
            Followers           = new FollowerClient(apiConnection);
            Follows             = new FollowClient(apiConnection);
            Listings            = new ListingClient(apiConnection);
            Organizations       = new OrganizationClient(apiConnection);
            PodcastEpisodes     = new PodcastEpisodeClient(apiConnection);
            ReadingLists        = new ReadingListClient(apiConnection);
            Tags          = new TagClient(apiConnection);
            Users         = new UserClient(apiConnection);
            Videos        = new VideoClient(apiConnection);
            Webhooks      = new WebhookClient(apiConnection);
            ProfileImages = new ProfileImageClient(apiConnection);
        }