public async Task <string> Joke(CancellationToken cancellationToken) { var uriStr = await _configApi.GetAsync(ConfigKey.With("api-uri"), cancellationToken).ConfigureAwait(false); var uri = new Uri(uriStr, UriKind.Absolute); var jokeContainer = await _httpApi.GetAsyncAs <JokeContainer>(uri, cancellationToken).ConfigureAwait(false); return(jokeContainer.Value.Joke); }
public async Task <IGitHubClient> GetClientAsync(CancellationToken cancellationToken) { if (_gitHubClient != null) { return(_gitHubClient); } var token = await _configApi.GetAsync(ConfigKey.With("github-token"), cancellationToken).ConfigureAwait(false); if (string.IsNullOrEmpty(token)) { token = Environment.GetEnvironmentVariable("GITHUB_TOKEN"); } var productHeaderValue = new ProductHeaderValue( "TheBorg.Plugins.GitHub", GetType().Assembly.GetName().Version.ToString()); _gitHubClient = new GitHubClient(productHeaderValue) { Credentials = new Credentials(token) }; return(_gitHubClient); }