forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGithubScripts.cs
More file actions
75 lines (59 loc) · 3.06 KB
/
GithubScripts.cs
File metadata and controls
75 lines (59 loc) · 3.06 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ServiceStack.IO;
namespace ServiceStack.Script
{
public class GithubPlugin : IScriptPlugin
{
public void Register(ScriptContext context)
{
context.ScriptMethods.Add(new GithubScripts());
}
}
public class GithubScripts : ScriptMethods
{
public GistVirtualFiles gistVirtualFiles(string gistId) => new GistVirtualFiles(gistId);
public GistVirtualFiles gistVirtualFiles(string gistId, string accessToken) =>
new GistVirtualFiles(gistId, accessToken);
public GithubGateway githubGateway() => new GithubGateway();
public GithubGateway githubGateway(string accessToken) => new GithubGateway(accessToken);
public string githubSourceZipUrl(GithubGateway gateway, string orgNames, string name) =>
gateway.GetSourceZipUrl(orgNames, name);
public Task<object> githubSourceRepos(GithubGateway gateway, string orgName) =>
Task.FromResult<object>(gateway.GetSourceReposAsync(orgName));
public Task<object> githubUserAndOrgRepos(GithubGateway gateway, string githubOrgOrUser) =>
Task.FromResult<object>(gateway.GetUserAndOrgReposAsync(githubOrgOrUser));
public List<GithubRepo> githubUserRepos(GithubGateway gateway, string githubUser) =>
gateway.GetUserRepos(githubUser);
public List<GithubRepo> githubOrgRepos(GithubGateway gateway, string githubOrg) =>
gateway.GetOrgRepos(githubOrg);
public GithubGist githubCreateGist(GithubGateway gateway, string description, Dictionary<string, string> files) =>
gateway.CreateGithubGist(description:description, isPublic:true, files:files);
public GithubGist githubCreatePrivateGist(GithubGateway gateway, string description, Dictionary<string, string> files) =>
gateway.CreateGithubGist(description:description, isPublic:false, files:files);
public GithubGist githubGist(GithubGateway gateway, string gistId) =>
gateway.GetGithubGist(gistId);
public IgnoreResult githubWriteGistFiles(GithubGateway gateway, string gistId, Dictionary<string, string> gistFiles)
{
gateway.WriteGistFiles(gistId, gistFiles);
return IgnoreResult.Value;
}
public IgnoreResult githubWriteGistFile(GithubGateway gateway, string gistId, string filePath, string contents)
{
gateway.WriteGistFile(gistId, filePath, contents);
return IgnoreResult.Value;
}
public IgnoreResult githuDeleteGistFiles(GithubGateway gateway, string gistId, string filePath)
{
gateway.DeleteGistFiles(gistId, filePath);
return IgnoreResult.Value;
}
public IgnoreResult githuDeleteGistFiles(GithubGateway gateway, string gistId, IEnumerable<string> filePaths)
{
gateway.DeleteGistFiles(gistId, filePaths.ToArray());
return IgnoreResult.Value;
}
}
}