diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs index fc596118..a5d2c165 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -2,7 +2,6 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using Octokit.Models.Request; using Xunit; namespace Octokit.Tests.Integration.Clients @@ -66,7 +65,7 @@ namespace Octokit.Tests.Integration.Clients repository.Name, "somefile.txt", new CreateFileRequest("Test commit", "Some Content")); - Assert.Equal("Some Content", file.Content.Content); + Assert.Equal("somefile.txt", file.Content.Name); var contents = await fixture.GetContents(repository.Owner.Login, repository.Name, "somefile.txt"); string fileSha = contents.First().Sha; @@ -78,7 +77,7 @@ namespace Octokit.Tests.Integration.Clients "somefile.txt", new UpdateFileRequest("Updating file", "New Content", fileSha)); string updatedFileSha = update.Commit.Sha; - Assert.Equal("New Content", update.Content.Content); + Assert.Equal("somefile.txt", update.Content.Name); await fixture.DeleteFile( repository.Owner.Login, diff --git a/Octokit.Tests/Clients/TagsClientTests.cs b/Octokit.Tests/Clients/TagsClientTests.cs index 4db58afc..7d693d36 100644 --- a/Octokit.Tests/Clients/TagsClientTests.cs +++ b/Octokit.Tests/Clients/TagsClientTests.cs @@ -83,7 +83,7 @@ public class TagsClientTests Tag = "tag-name", Object = "tag-object", Type = TaggedType.Tree, - Tagger = new Signature + Tagger = new SignatureResponse { Name = "tagger-name", Email = "tagger-email", diff --git a/Octokit.Tests/Models/CommitTests.cs b/Octokit.Tests/Models/CommitTests.cs index c79ee5e2..74cdd533 100644 --- a/Octokit.Tests/Models/CommitTests.cs +++ b/Octokit.Tests/Models/CommitTests.cs @@ -14,14 +14,14 @@ public class CommitTests var parent1 = new GitReference { Sha = "parent1-reference", Url = "parent1-url" }; var parent2 = new GitReference { Sha = "parent2-reference", Url = "parent2-url" }; - var author = new Signature + var author = new SignatureResponse { Name = "author-name", Email = "author-email", Date = DateTimeOffset.Parse("2013-10-15T13:40:14Z") }; - var committer = new Signature { + var committer = new SignatureResponse { Name = "committer-name", Email = "committer-email", Date = DateTimeOffset.Parse("2013-06-29T10:12:50Z") diff --git a/Octokit/Clients/IRepositoryContentsClient.cs b/Octokit/Clients/IRepositoryContentsClient.cs index 9c6e6dc9..35714603 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Octokit.Models.Request; namespace Octokit { diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index 8f3d30b7..a9d67858 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Octokit.Models.Request; namespace Octokit { diff --git a/Octokit/Models/Request/CreateFileRequest.cs b/Octokit/Models/Request/CreateFileRequest.cs index b66c6ccb..7bac4403 100644 --- a/Octokit/Models/Request/CreateFileRequest.cs +++ b/Octokit/Models/Request/CreateFileRequest.cs @@ -1,8 +1,9 @@ using System; using System.Diagnostics; using System.Globalization; +using Octokit.Helpers; -namespace Octokit.Models.Request +namespace Octokit { /// /// Base class with common properties for all the Repository Content Request APIs. @@ -30,12 +31,12 @@ namespace Octokit.Models.Request /// /// Specifies the committer to use for the commit. This is optional. /// - public Signature Committer { get; set; } + public SignatureResponse Committer { get; set; } /// /// Specifies the author to use for the commit. This is optional. /// - public Signature Author { get; set; } + public SignatureResponse Author { get; set; } } /// @@ -83,6 +84,7 @@ namespace Octokit.Models.Request /// /// The contents of the file to create. This is required. /// + [SerializeAsBase64] public string Content { get; private set; } internal virtual string DebuggerDisplay diff --git a/Octokit/Models/Request/NewCommit.cs b/Octokit/Models/Request/NewCommit.cs index a918e6c7..d449697e 100644 --- a/Octokit/Models/Request/NewCommit.cs +++ b/Octokit/Models/Request/NewCommit.cs @@ -47,8 +47,8 @@ namespace Octokit public string Tree { get; set; } public IEnumerable Parents { get; set; } - public Signature Author { get; set; } - public Signature Committer { get; set; } + public SignatureResponse Author { get; set; } + public SignatureResponse Committer { get; set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Request/NewTag.cs b/Octokit/Models/Request/NewTag.cs index ed5f2643..344c2a18 100644 --- a/Octokit/Models/Request/NewTag.cs +++ b/Octokit/Models/Request/NewTag.cs @@ -13,7 +13,7 @@ namespace Octokit public string Object { get; set; } [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "Property name as defined by web api")] public TaggedType Type { get; set; } - public Signature Tagger { get; set; } + public SignatureResponse Tagger { get; set; } internal string DebuggerDisplay { get diff --git a/Octokit/Models/Request/Signature.cs b/Octokit/Models/Request/Signature.cs index aa36b571..81b9e795 100644 --- a/Octokit/Models/Request/Signature.cs +++ b/Octokit/Models/Request/Signature.cs @@ -2,7 +2,7 @@ using System.Diagnostics; using System.Globalization; -namespace Octokit.Models.Request +namespace Octokit { /// /// Information about an author or committer. diff --git a/Octokit/Models/Response/Commit.cs b/Octokit/Models/Response/Commit.cs index c89039ea..c0eb3df0 100644 --- a/Octokit/Models/Response/Commit.cs +++ b/Octokit/Models/Response/Commit.cs @@ -7,8 +7,8 @@ namespace Octokit public class Commit : GitReference { public string Message { get; set; } - public Signature Author { get; set; } - public Signature Committer { get; set; } + public SignatureResponse Author { get; set; } + public SignatureResponse Committer { get; set; } public GitReference Tree { get; set; } public IEnumerable Parents { get; set; } public int CommentCount { get; set; } diff --git a/Octokit/Models/Response/CommitContent.cs b/Octokit/Models/Response/CommitContent.cs new file mode 100644 index 00000000..89055111 --- /dev/null +++ b/Octokit/Models/Response/CommitContent.cs @@ -0,0 +1,54 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Octokit +{ + public class RepositoryContentInfo + { + /// + /// Name of the content. + /// + public string Name { get; set; } + + /// + /// Path to this content. + /// + public string Path { get; set; } + + /// + /// SHA of the last commit that modified this content. + /// + public string Sha { get; set; } + + /// + /// Size of the content. + /// + public int Size { get; set; } + + /// + /// The type of this content. It might be a File, Directory, Submodule, or Symlink + /// + [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "Matches the property name used by the API")] + public ContentType Type { get; set; } + + /// + /// URL to the raw content + /// + public Uri DownloadUrl { get; set; } + + /// + /// URL to this content + /// + public Uri Url { get; set; } + + /// + /// The GIT URL to this content. + /// + public Uri GitUrl { get; set; } + + /// + /// The URL to view this content on GitHub. + /// + public Uri HtmlUrl { get; set; } + } +} diff --git a/Octokit/Models/Response/ContentType.cs b/Octokit/Models/Response/ContentType.cs new file mode 100644 index 00000000..410181a4 --- /dev/null +++ b/Octokit/Models/Response/ContentType.cs @@ -0,0 +1,16 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Octokit +{ + /// + /// The possible repository content types. + /// + public enum ContentType + { + File, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dir", Justification = "Matches the value returned by the API")] + Dir, + Symlink, + Submodule + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/DirectoryContent.cs b/Octokit/Models/Response/DirectoryContent.cs deleted file mode 100644 index f33be101..00000000 --- a/Octokit/Models/Response/DirectoryContent.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Octokit -{ - /// - /// Represents a piece of content in the repository. This could be a submodule, a symlink, a directory, or a file. - /// Look at the Type property to figure out which one it is. - /// - public class RepositoryContent - { - /// - /// Name of the content. - /// - public string Name { get; set; } - - /// - /// Path to this content. - /// - public string Path { get; set; } - - /// - /// SHA of the last commit that modified this content. - /// - public string Sha { get; set; } - - /// - /// Size of the content. - /// - public int Size { get; set; } - - /// - /// The encoding of the content if this is a file. Typically "base64". Otherwise it's null. - /// - public string Encoding { get; set; } - - /// - /// The encoded content if this is a file. Otherwise it's null. - /// - public string Content { get; set; } - - /// - /// The type of this content. It might be a File, Directory, Submodule, or Symlink - /// - [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "Matches the property name used by the API")] - public ContentType Type { get; set; } - - /// - /// Path to the target file in the repository if this is a symlink. Otherwise it's null. - /// - public string Target { get; set; } - - /// - /// The location of the submodule repository if this is a submodule. Otherwise it's null. - /// - public Uri SubmoduleGitUrl { get; set; } - - /// - /// URL to this content - /// - public Uri Url { get; set; } - - /// - /// The GIT URL to this content. - /// - public Uri GitUrl { get; set; } - - /// - /// The URL to view this content on GitHub. - /// - public Uri HtmlUrl { get; set; } - } - - /// - /// The possible repository content types. - /// - public enum ContentType - { - File, - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dir", Justification = "Matches the value returned by the API")] - Dir, - Symlink, - Submodule - } - - /// - /// The response from the Repository Contents API. The API assumes a dynamic client type so we need - /// to model that. - /// - /// https://developer.github.com/v3/repos/contents/ - public class RepositoryContentChangeSet - { - /// - /// The directory content of the response. - /// - public RepositoryContent Content { get; set; } - - /// - /// The commit information for the content change. - /// - public Commit Commit { get; set; } - } -} \ No newline at end of file diff --git a/Octokit/Models/Response/GitTag.cs b/Octokit/Models/Response/GitTag.cs index 984a8457..a80250e7 100644 --- a/Octokit/Models/Response/GitTag.cs +++ b/Octokit/Models/Response/GitTag.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using System.Globalization; +using System.Diagnostics; namespace Octokit { @@ -9,7 +7,7 @@ namespace Octokit { public string Tag { get; set; } public string Message { get; set; } - public Signature Tagger { get; set; } + public SignatureResponse Tagger { get; set; } public TagObject Object { get; set; } } } \ No newline at end of file diff --git a/Octokit/Models/Response/PullRequestCommit.cs b/Octokit/Models/Response/PullRequestCommit.cs index 24504cf8..9b5942fe 100644 --- a/Octokit/Models/Response/PullRequestCommit.cs +++ b/Octokit/Models/Response/PullRequestCommit.cs @@ -8,10 +8,10 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PullRequestCommit { - public Signature Author { get; set; } + public SignatureResponse Author { get; set; } public Uri CommentsUrl { get; set; } public Commit Commit { get; set; } - public Signature Committer { get; set; } + public SignatureResponse Committer { get; set; } public Uri HtmlUrl { get; set; } public IEnumerable Parents { get; set; } public string Sha { get; set; } diff --git a/Octokit/Models/Response/RepositoryContent.cs b/Octokit/Models/Response/RepositoryContent.cs new file mode 100644 index 00000000..5c65e1f4 --- /dev/null +++ b/Octokit/Models/Response/RepositoryContent.cs @@ -0,0 +1,31 @@ +using System; + +namespace Octokit +{ + /// + /// Represents a piece of content in the repository. This could be a submodule, a symlink, a directory, or a file. + /// Look at the Type property to figure out which one it is. + /// + public class RepositoryContent : RepositoryContentInfo + { + /// + /// The encoding of the content if this is a file. Typically "base64". Otherwise it's null. + /// + public string Encoding { get; set; } + + /// + /// The encoded content if this is a file. Otherwise it's null. + /// + public string Content { get; set; } + + /// + /// Path to the target file in the repository if this is a symlink. Otherwise it's null. + /// + public string Target { get; set; } + + /// + /// The location of the submodule repository if this is a submodule. Otherwise it's null. + /// + public Uri SubmoduleGitUrl { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/RepositoryContentChangeSet.cs b/Octokit/Models/Response/RepositoryContentChangeSet.cs new file mode 100644 index 00000000..ddebb086 --- /dev/null +++ b/Octokit/Models/Response/RepositoryContentChangeSet.cs @@ -0,0 +1,20 @@ +namespace Octokit +{ + /// + /// The response from the Repository Contents API. The API assumes a dynamic client type so we need + /// to model that. + /// + /// https://developer.github.com/v3/repos/contents/ + public class RepositoryContentChangeSet + { + /// + /// The content of the response. + /// + public RepositoryContentInfo Content { get; set; } + + /// + /// The commit information for the content change. + /// + public Commit Commit { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Signature.cs b/Octokit/Models/Response/SignatureResponse.cs similarity index 93% rename from Octokit/Models/Response/Signature.cs rename to Octokit/Models/Response/SignatureResponse.cs index 12640d17..517d5b3b 100644 --- a/Octokit/Models/Response/Signature.cs +++ b/Octokit/Models/Response/SignatureResponse.cs @@ -5,7 +5,7 @@ using System.Globalization; namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class Signature + public class SignatureResponse { public string Name { get; set; } public string Email { get; set; } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index b862edf6..4cd84b5d 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -149,7 +149,6 @@ - @@ -349,10 +348,14 @@ - + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 06a52c62..c9fb49cb 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -363,6 +363,11 @@ + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index af746d31..1c48d90f 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -358,6 +358,11 @@ + + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 54e82861..07419f45 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -248,7 +248,6 @@ - @@ -347,10 +346,14 @@ - + + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 244f2ae5..50f4c6a4 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -253,7 +253,6 @@ - @@ -351,10 +350,14 @@ - + + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 0f8e3ad1..96fa68a9 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -85,7 +85,11 @@ + + + + @@ -97,7 +101,6 @@ - @@ -262,7 +265,7 @@ - +