tgstation-server
The /tg/station 13 server suite
GitHubClientFactory.cs
Go to the documentation of this file.
1 using System;
2 using Octokit;
3 
4 namespace Tgstation.Server.Host.Core
5 {
8  {
13 
18  public GitHubClientFactory(IApplication application)
19  {
20  this.application = application ?? throw new ArgumentNullException(nameof(application));
21  }
22 
27  GitHubClient CreateBaseClient() => new GitHubClient(new ProductHeaderValue(application.VersionPrefix, application.Version.ToString()));
28 
30  public IGitHubClient CreateClient() => CreateBaseClient();
31 
33  public IGitHubClient CreateClient(string accessToken)
34  {
35  if (accessToken == null)
36  throw new ArgumentNullException(nameof(accessToken));
37  var result = CreateBaseClient();
38  result.Credentials = new Credentials(accessToken);
39  return result;
40  }
41  }
42 }
IGitHubClient CreateClient(string accessToken)
Create a client with authentication using a personal access token
Configures the ASP.NET Core web application
Definition: IApplication.cs:8
GitHubClientFactory(IApplication application)
Construct a GitHubClientFactory
readonly IApplication application
The IApplication for the GitHubClientFactory