using System; using System.Diagnostics.CodeAnalysis; using System.Text; using System.Threading.Tasks; using Octokit.Http; namespace Octokit { /// /// Represents an oauth application. /// public class Application { /// /// Name. /// public string Name { get; set; } /// /// The Url of this . /// public string Url { get; set; } } public class AuthorizationUpdate { /// /// Replace scopes with this list. /// [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Special type of model object that only updates none-null fields.")] public string[] Scopes { get; set; } /// /// Notes about this particular . /// public string Note { get; set; } /// /// A url for more information about notes. /// public string NoteUrl { get; set; } } /// /// Represents an oauth access given to a particular application. /// public class Authorization { /// /// The Id of this . /// public int Id { get; set; } /// /// The API URL for this . /// public string Url { get; set; } /// /// The that created this . /// public Application Application { get; set; } /// /// The oauth token (be careful with these, they are like passwords!). /// public string Token { get; set; } /// /// Notes about this particular . /// public string Note { get; set; } /// /// A url for more information about notes. /// public string NoteUrl { get; set; } /// /// When this was created. /// public DateTimeOffset CreatedAt { get; set; } /// /// When this was last updated. /// public DateTimeOffset UpdateAt { get; set; } /// /// The scopes that this has. This is the kind of access that the token allows. /// [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Special type of model object that only updates none-null fields.")] public string[] Scopes { get; set; } public string ScopesDelimited { get { return string.Join(",", Scopes); } } } /// /// Represents updatable fields on a user. Values that are null will not be sent in the request. /// Use string.empty if you want to clear clear a value. /// public class UserUpdate { /// /// This user's bio. /// public string Bio { get; set; } /// /// URL for this user's blog. /// public string Blog { get; set; } /// /// The company this user's works for. /// public string Company { get; set; } /// /// This user's email. /// public string Email { get; set; } /// /// The geographic location of this user. /// public string Location { get; set; } /// /// This user's full name. /// public string Name { get; set; } /// /// Tells if this user is currently hireable. /// public bool? Hireable { get; set; } } /// /// Represents a user on GitHub. /// public class User { /// /// URL for this user's avatar. /// public string AvatarUrl { get; set; } /// /// This user's bio. /// public string Bio { get; set; } /// /// URL for this user's blog. /// public string Blog { get; set; } /// /// Number of collaborators this user has on their account. /// public int Collaborators { get; set; } /// /// The company this user's works for. /// public string Company { get; set; } /// /// The date this user account was create. /// public DateTimeOffset CreatedAt { get; set; } /// /// The amout of disk space this user is currently using. /// public int DiskUsage { get; set; } /// /// This user's email. /// public string Email { get; set; } /// /// Number of follwers this user has. /// public int Followers { get; set; } /// /// Number of other users this user is following. /// public int Following { get; set; } /// /// Tells if this user is currently hireable. /// public bool Hireable { get; set; } /// /// The HTML URL for this user on github.com. /// public string HtmlUrl { get; set; } /// /// The system-wide unique Id for this user. /// public int Id { get; set; } /// /// The geographic location of this user. /// public string Location { get; set; } /// /// This user's login. /// public string Login { get; set; } /// /// This user's full name. /// public string Name { get; set; } /// /// Number of private repos owned by this user. /// public int OwnedPrivateRepos { get; set; } /// /// The plan this user pays for. /// public Plan Plan { get; set; } /// /// The number of private gists this user has created. /// public int PrivateGists { get; set; } /// /// The number of public gists this user has created. /// public int PublicGists { get; set; } /// /// The number of public repos owned by this user. /// public int PublicRepos { get; set; } /// /// The total number of private repos this user owns. /// public int TotalPrivateRepos { get; set; } /// /// The type of this record. (User for user account, Organization for org account) /// [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] public string Type { get; set; } /// /// The api URL for this user. /// public string Url { get; set; } /// /// Whether or not the user is an administrator of the site /// public bool SiteAdmin { get; set; } } public class Organization { /// /// URL for this user's avatar. /// public string AvatarUrl { get; set; } /// /// The system-wide unique Id for this user. /// public int Id { get; set; } /// /// This org's login. /// public string Login { get; set; } /// /// The api URL for this organization. /// public string Url { get; set; } } internal class ReadmeResponse { public string Content { get; set; } public string Name { get; set; } public string HtmlUrl { get; set; } public string Url { get; set; } public string Encoding { get; set; } } public class Readme { readonly Lazy> htmlContent; internal Readme(ReadmeResponse response, IApiConnection client) { Ensure.ArgumentNotNull(response, "response"); Ensure.ArgumentNotNull(client, "client"); Name = response.Name; Url = new Uri(response.Url); HtmlUrl = new Uri(response.HtmlUrl); if (response.Encoding.Equals("base64", StringComparison.OrdinalIgnoreCase)) { var contentAsBytes = Convert.FromBase64String(response.Content); Content = Encoding.UTF8.GetString(contentAsBytes, 0, contentAsBytes.Length); } htmlContent = new Lazy>(async () => await client.GetHtml(HtmlUrl)); } public string Content { get; private set; } public string Name { get; private set; } public Uri HtmlUrl { get; private set; } public Uri Url { get; private set; } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Makse a network request")] public async Task GetHtmlContent() { return await htmlContent.Value; } } public class SshKey { /// /// The system-wide unique Id for this user. /// public int Id { get; set; } /// /// The SSH Key /// public string Key { get; set; } /// /// The title of the SSH key /// public string Title { get; set; } /// /// The api URL for this organization. /// public string Url { get; set; } } /// /// Represents the data and name parsed from the Ssh key. /// public class SshKeyInfo { public SshKeyInfo(string data, string name) { Ensure.ArgumentNotNull(data, "data"); Ensure.ArgumentNotNull(name, "name"); Data = data; Name = name; } public string Data { get; private set; } public string Name { get; private set; } } public class SshKeyUpdate { /// /// The SSH Key /// public string Key { get; set; } /// /// The title of the SSH key /// public string Title { get; set; } } /// /// A plan (either paid or free) for a particular user /// public class Plan { /// /// The number of collaborators allowed with this plan. /// public int Collaborators { get; set; } /// /// The name of the plan. /// public string Name { get; set; } /// /// The number of private repositories allowed with this plan. /// public int PrivateRepos { get; set; } /// /// The amount of disk space allowed with this plan. /// public int Space { get; set; } } public class Repository { public string Url { get; set; } public string HtmlUrl { get; set; } public string CloneUrl { get; set; } public string GitUrl { get; set; } public string SshUrl { get; set; } public string SvnUrl { get; set; } public string MirrorUrl { get; set; } public int Id { get; set; } public User Owner { get; set; } public string Name { get; set; } public string FullName { get; set; } public string Description { get; set; } public string Homepage { get; set; } public string Language { get; set; } public bool Private { get; set; } public bool Fork { get; set; } public int ForksCount { get; set; } public int WatchersCount { get; set; } public string MasterBranch { get; set; } public int OpenIssuesCount { get; set; } public DateTimeOffset PushedAt { get; set; } public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset UpdatedAt { get; set; } public User Organization { get; set; } public Repository Parent { get; set; } public Repository Source { get; set; } public bool HasIssues { get; set; } public bool HasWiki { get; set; } public bool HasDownloads { get; set; } } }