-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
GitHubClientFactory.cs
27 lines (22 loc) · 857 Bytes
/
GitHubClientFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) David Pine. All rights reserved.
// Licensed under the MIT License.
namespace Actions.Octokit;
/// <summary>
/// Represents a factory for creating <see cref="GitHubClient"/> instances.
/// </summary>
public static class GitHubClientFactory
{
/// <summary>
/// Creates a new <see cref="GitHubClient"/> from the given <paramref name="token"/>.
/// </summary>
/// <param name="token">The token used to initialize the client.</param>
/// <returns>A new <see cref="GitHubClient"/> instance.</returns>
public static GitHubClient Create(string token)
{
ArgumentException.ThrowIfNullOrWhiteSpace(token);
var tokenProvider = new TokenProvider(token);
var request = RequestAdapter.Create(
new TokenAuthProvider(tokenProvider));
return new GitHubClient(request);
}
}