diff --git a/Octokit.Tests/Models/CollaboratorPermissionResponseTests.cs b/Octokit.Tests/Models/CollaboratorPermissionResponseTests.cs new file mode 100644 index 0000000000..b70fce52ee --- /dev/null +++ b/Octokit.Tests/Models/CollaboratorPermissionResponseTests.cs @@ -0,0 +1,52 @@ +using Octokit; +using Octokit.Internal; +using Xunit; + +public class CollaboratorPermissionResponseTests +{ + [Fact] + public void CanDeserialize() + { + const string json = @"{ + ""permission"": ""read"", + ""user"": { + ""login"": ""octocat"", + ""id"": 583231, + ""node_id"": ""MDQ6VXNlcjU4MzIzMQ=="", + ""avatar_url"": ""https://avatars.githubusercontent.com/u/583231?v=4"", + ""gravatar_id"": """", + ""url"": ""https://api.github.com/users/octocat"", + ""html_url"": ""https://github.com/octocat"", + ""followers_url"": ""https://api.github.com/users/octocat/followers"", + ""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"", + ""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"", + ""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"", + ""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"", + ""organizations_url"": ""https://api.github.com/users/octocat/orgs"", + ""repos_url"": ""https://api.github.com/users/octocat/repos"", + ""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"", + ""received_events_url"": ""https://api.github.com/users/octocat/received_events"", + ""type"": ""User"", + ""site_admin"": false, + ""permissions"": { + ""admin"": false, + ""maintain"": false, + ""push"": false, + ""triage"": false, + ""pull"": true + }, + ""role_name"": ""read"" + }, + ""role_name"": ""read"" + }"; + + var actual = new SimpleJsonSerializer().Deserialize(json); + + Assert.Equal("read", actual.Permission); + Assert.Equal("octocat", actual.Collaborator.Login); + Assert.Equal(583231, actual.Collaborator.Id); + Assert.Equal("read", actual.RoleName); + + Assert.Equal("Collaborator: 583231 Permission: read RoleName: read", actual.DebuggerDisplay); + } +} diff --git a/Octokit/Models/Response/CollaboratorPermissionResponse.cs b/Octokit/Models/Response/CollaboratorPermissionResponse.cs index 7dd8aa8b9e..69b802b7c5 100644 --- a/Octokit/Models/Response/CollaboratorPermissionResponse.cs +++ b/Octokit/Models/Response/CollaboratorPermissionResponse.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using Octokit.Internal; namespace Octokit { @@ -21,6 +22,7 @@ public CollaboratorPermissionResponse(string permission, string roleName, Collab public string RoleName { get; private set; } + [Parameter(Key = "user")] public Collaborator Collaborator { get; private set; } internal string DebuggerDisplay => $"Collaborator: {Collaborator.Id} Permission: {Permission} RoleName: {RoleName}";