tgstation-server  4.4.0
The /tg/station 13 server suite
GitHubClientFactory.cs
Go to the documentation of this file.
1 using System;
2 using Octokit;
4 
5 namespace Tgstation.Server.Host.Core
6 {
9  {
14 
19  public GitHubClientFactory(IAssemblyInformationProvider assemblyInformationProvider)
20  {
21  this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
22  }
23 
28  GitHubClient CreateBaseClient() => new GitHubClient(new ProductHeaderValue(assemblyInformationProvider.VersionPrefix, assemblyInformationProvider.Version.ToString()));
29 
31  public IGitHubClient CreateClient() => CreateBaseClient();
32 
34  public IGitHubClient CreateClient(string accessToken)
35  {
36  if (accessToken == null)
37  throw new ArgumentNullException(nameof(accessToken));
38  var result = CreateBaseClient();
39  result.Credentials = new Credentials(accessToken);
40  return result;
41  }
42  }
43 }
IGitHubClient CreateClient(string accessToken)
Create a client with authentication using a personal access token
GitHubClientFactory(IAssemblyInformationProvider assemblyInformationProvider)
Construct a GitHubClientFactory
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the GitHubClientFactory