diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs
index a4bb8cc03f..79e84beb26 100644
--- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs
@@ -90,6 +90,19 @@ public interface IObservableRepoCollaboratorsClient
/// Thrown when a general API error occurs.
IObservable Add(string owner, string name, string user);
+ ///
+ /// Adds a new collaborator to the repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Username of the new collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ /// Thrown when a general API error occurs.
+ IObservable Add(string owner, string name, string user, CollaboratorRequest permission);
+
///
/// Adds a new collaborator to the repository.
///
@@ -101,6 +114,64 @@ public interface IObservableRepoCollaboratorsClient
/// Thrown when a general API error occurs.
IObservable Add(int repositoryId, string user);
+ ///
+ /// Adds a new collaborator to the repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ /// Username of the new collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ /// Thrown when a general API error occurs.
+ IObservable Add(int repositoryId, string user, CollaboratorRequest permission);
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The username of the prospective collaborator
+ IObservable Invite(string owner, string name, string user);
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The username of the prospective collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ IObservable Invite(string owner, string name, string user, CollaboratorRequest permission);
+
+ ///
+ /// Adds a new collaborator to the repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ /// Username of the new collaborator
+ /// Thrown when a general API error occurs.
+ IObservable Invite(int repositoryId, string user);
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ /// Username of the new collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ /// Thrown when a general API error occurs.
+ IObservable Invite(int repositoryId, string user, CollaboratorRequest permission);
+
///
/// Deletes a collaborator from the repository.
///
@@ -124,4 +195,4 @@ public interface IObservableRepoCollaboratorsClient
/// Thrown when a general API error occurs.
IObservable Delete(int repositoryId, string user);
}
-}
+}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
index 866f4956bb..bfa144ea53 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
@@ -559,6 +559,7 @@ public interface IObservableRepositoriesClient
/// See the Repository Deploy Keys API documentation for more information.
///
IObservableRepositoryDeployKeysClient DeployKeys { get; }
+
///
/// A client for GitHub's Repository Pages API.
///
@@ -566,5 +567,13 @@ public interface IObservableRepositoriesClient
/// See the Repository Pages API documentation for more information.
///
IObservableRepositoryPagesClient Page { get; }
+
+ ///
+ /// A client for GitHub's Repository Invitations API.
+ ///
+ ///
+ /// See the Repository Invitations API documentation for more information.
+ ///
+ IObservableRepositoryInvitationsClient Invitation { get; }
}
}
diff --git a/Octokit.Reactive/Clients/IObservableRepositoryInvitationsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryInvitationsClient.cs
new file mode 100644
index 0000000000..b2e9910978
--- /dev/null
+++ b/Octokit.Reactive/Clients/IObservableRepositoryInvitationsClient.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Collections.Generic;
+
+namespace Octokit.Reactive
+{
+ public interface IObservableRepositoryInvitationsClient
+ {
+ ///
+ /// Accept a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the invitation.
+ IObservable Accept(int invitationId);
+
+ ///
+ /// Decline a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the invitation.
+ IObservable Decline(int invitationId);
+
+ ///
+ /// Deletes a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository.
+ /// The id of the invitation.
+ IObservable Delete(int repositoryId, int invitationId);
+
+ ///
+ /// Gets all invitations for the current user.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ IObservable GetAllForCurrent();
+
+ ///
+ /// Gets all the invitations on a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ IObservable GetAllForRepository(int repositoryId);
+
+ ///
+ /// Updates a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository.
+ /// The id of the invitation.
+ /// The permission to set.
+ ///
+ IObservable Edit(int repositoryId, int invitationId, InvitationUpdate permissions);
+ }
+}
diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs
index 583adc4bf7..3eea4a4236 100644
--- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs
@@ -73,7 +73,7 @@ public IObservable GetAll(string owner, string name, ApiOptions options)
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
-
+
return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(owner, name), options);
}
@@ -132,7 +132,7 @@ public IObservable IsCollaborator(int repositoryId, string user)
/// Adds a new collaborator to the repository.
///
///
- /// See the API documentation for more information.
+ /// See the API documentation for more information.
///
/// The owner of the repository
/// The name of the repository
@@ -147,6 +147,27 @@ public IObservable Add(string owner, string name, string user)
return _client.Add(owner, name, user).ToObservable();
}
+ ///
+ /// Adds a new collaborator to the repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Username of the new collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ /// Thrown when a general API error occurs.
+ public IObservable Add(string owner, string name, string user, CollaboratorRequest permission)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNullOrEmptyString(user, "user");
+ Ensure.ArgumentNotNull(permission, "permission");
+
+ return _client.Add(owner, name, user, permission).ToObservable();
+ }
+
///
/// Adds a new collaborator to the repository.
///
@@ -163,6 +184,95 @@ public IObservable Add(int repositoryId, string user)
return _client.Add(repositoryId, user).ToObservable();
}
+ ///
+ /// Adds a new collaborator to the repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ /// Username of the new collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ /// Thrown when a general API error occurs.
+ public IObservable Add(int repositoryId, string user, CollaboratorRequest permission)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(user, "user");
+ Ensure.ArgumentNotNull(permission, "permission");
+
+ return _client.Add(repositoryId, user, permission).ToObservable();
+ }
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The username of the prospective collaborator
+ public IObservable Invite(string owner, string name, string user)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNullOrEmptyString(user, "user");
+
+ return _client.Invite(owner, name, user).ToObservable();
+ }
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The username of the prospective collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ public IObservable Invite(string owner, string name, string user, CollaboratorRequest permission)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNullOrEmptyString(user, "user");
+ Ensure.ArgumentNotNull(permission, "psermission");
+
+ return _client.Invite(owner, name, user, permission).ToObservable();
+ }
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ /// The username of the prospective collaborator
+
+ public IObservable Invite(int repositoryId, string user)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(user, "user");
+
+ return _client.Invite(repositoryId, user).ToObservable();
+ }
+
+ ///
+ /// Invites a user as a collaborator to a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ /// The username of the prospective collaborator
+ /// The permission to set. Only valid on organization-owned repositories.
+ public IObservable Invite(int repositoryId, string user, CollaboratorRequest permission)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(user, "user");
+ Ensure.ArgumentNotNull(permission, "psermission");
+
+ return _client.Invite(repositoryId, user, permission).ToObservable();
+ }
+
///
/// Deletes a collaborator from the repository.
///
@@ -198,4 +308,4 @@ public IObservable Delete(int repositoryId, string user)
return _client.Delete(repositoryId, user).ToObservable();
}
}
-}
+}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
index c54774af41..86d5e842ba 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
@@ -33,6 +33,7 @@ public ObservableRepositoriesClient(IGitHubClient client)
Content = new ObservableRepositoryContentsClient(client);
Merging = new ObservableMergingClient(client);
Page = new ObservableRepositoryPagesClient(client);
+ Invitation = new ObservableRepositoryInvitationsClient(client);
}
///
@@ -853,5 +854,13 @@ public IObservable Compare(string owner, string name, string @bas
/// See the Repository Pages API documentation for more information.
///
public IObservableRepositoryPagesClient Page { get; private set; }
+
+ ///
+ /// A client for GitHub's Repository Invitations API.
+ ///
+ ///
+ /// See the Repository Invitations API documentation for more information.
+ ///
+ public IObservableRepositoryInvitationsClient Invitation { get; private set; }
}
}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryInvitationsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryInvitationsClient.cs
new file mode 100644
index 0000000000..c1c19215db
--- /dev/null
+++ b/Octokit.Reactive/Clients/ObservableRepositoryInvitationsClient.cs
@@ -0,0 +1,98 @@
+using Octokit.Reactive.Internal;
+using System;
+using System.Collections.Generic;
+using System.Reactive;
+using System.Reactive.Threading.Tasks;
+
+namespace Octokit.Reactive
+{
+ public class ObservableRepositoryInvitationsClient : IObservableRepositoryInvitationsClient
+ {
+ readonly IRepositoryInvitationsClient _client;
+ readonly IConnection _connection;
+
+ public ObservableRepositoryInvitationsClient(IGitHubClient client)
+ {
+ Ensure.ArgumentNotNull(client, "client");
+
+ _client = client.Repository.Invitation;
+ _connection = client.Connection;
+ }
+
+ ///
+ /// Accept a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the invitation.
+ public IObservable Accept(int invitationId)
+ {
+ return _client.Accept(invitationId).ToObservable();
+ }
+
+ ///
+ /// Decline a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the invitation.
+ public IObservable Decline(int invitationId)
+ {
+ return _client.Decline(invitationId).ToObservable();
+ }
+
+ ///
+ /// Deletes a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository.
+ /// The id of the invitation.
+ public IObservable Delete(int repositoryId, int invitationId)
+ {
+ return _client.Delete(repositoryId, invitationId).ToObservable();
+ }
+
+ ///
+ /// Updates a repository invitation.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository.
+ /// The id of the invitatio.n
+ /// The permission to set.
+ public IObservable Edit(int repositoryId, int invitationId, InvitationUpdate permissions)
+ {
+ Ensure.ArgumentNotNull(permissions, "persmissions");
+
+ return _client.Edit(repositoryId, invitationId, permissions).ToObservable();
+ }
+
+ ///
+ /// Gets all invitations for the current user.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ public IObservable GetAllForCurrent()
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.UserInvitations(), null, AcceptHeaders.InvitationsApiPreview, ApiOptions.None);
+ }
+
+ ///
+ /// Gets all the invitations on a repository.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The id of the repository
+ public IObservable GetAllForRepository(int repositoryId)
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryInvitations(repositoryId), null, AcceptHeaders.InvitationsApiPreview, ApiOptions.None);
+ }
+ }
+}
diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj
index c6c1d6c718..0964b1ffa7 100644
--- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj
@@ -190,6 +190,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
index be8cc86b6d..6a5e5193d4 100644
--- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
@@ -206,6 +206,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
index 99353b995c..dcef4ea5f3 100644
--- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
@@ -202,6 +202,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj
index f3ab686b0c..cf8b2786ac 100644
--- a/Octokit.Reactive/Octokit.Reactive.csproj
+++ b/Octokit.Reactive/Octokit.Reactive.csproj
@@ -100,6 +100,7 @@
+
@@ -134,6 +135,7 @@
+
diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs
index d9400995b5..37a6710ab6 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs
@@ -306,4 +306,26 @@ public async Task CheckDeleteMethodWithRepositoryId()
}
}
}
+
+ public class TheInviteMethod
+ {
+ [IntegrationTest]
+ public async Task CanInviteNewCollaborator()
+ {
+ var github = Helper.GetAuthenticatedClient();
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, "octokat", permission);
+
+ Assert.Equal("octokat", response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs
new file mode 100644
index 0000000000..7b2ee01591
--- /dev/null
+++ b/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs
@@ -0,0 +1,191 @@
+using Octokit;
+using Octokit.Tests.Integration;
+using Octokit.Tests.Integration.Helpers;
+using System.Linq;
+using System.Threading.Tasks;
+using Xunit;
+
+public class RepositoryInvitationsClientTests
+{
+ const string owner = "octocat";
+ const string name = "Hello-World";
+
+ public class TheGetAllForRepositoryMethod
+ {
+ [IntegrationTest]
+ public async Task CanGetAllInvitations()
+ {
+ var github = Helper.GetAuthenticatedClient();
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, owner, permission);
+
+ Assert.Equal(owner, response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+
+ var invitations = await github.Repository.Invitation.GetAllForRepository(context.Repository.Id);
+
+ Assert.Equal(1, invitations.Count);
+ Assert.Equal(invitations[0].CreatedAt, response.CreatedAt);
+ Assert.Equal(invitations[0].Id, response.Id);
+ Assert.Equal(invitations[0].Invitee.Login, response.Invitee.Login);
+ Assert.Equal(invitations[0].Inviter.Login, response.Inviter.Login);
+ Assert.Equal(invitations[0].Permissions, response.Permissions);
+ Assert.Equal(invitations[0].Repository.Id, response.Repository.Id);
+ }
+ }
+ }
+
+ public class TheGetAllForCurrentMethod
+ {
+ [IntegrationTest]
+ public async Task CanGetAllInvitations()
+ {
+ var github = Helper.GetAuthenticatedClient();
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
+
+ Assert.Equal(context.RepositoryOwner, response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+
+ var invitations = await github.Repository.Invitation.GetAllForCurrent();
+
+ Assert.True(invitations.Count >= 1);
+ Assert.NotNull(invitations.FirstOrDefault(i => i.CreatedAt == response.CreatedAt));
+ Assert.NotNull(invitations.FirstOrDefault(i => i.Id == response.Id));
+ Assert.NotNull(invitations.FirstOrDefault(i => i.Inviter.Login == response.Inviter.Login));
+ Assert.NotNull(invitations.FirstOrDefault(i => i.Invitee.Login == response.Invitee.Login));
+ Assert.NotNull(invitations.FirstOrDefault(i => i.Permissions == response.Permissions));
+ Assert.NotNull(invitations.FirstOrDefault(i => i.Repository.Id == response.Repository.Id));
+ }
+ }
+ }
+
+ public class TheAcceptMethod
+ {
+ [IntegrationTest]
+ public async Task CanAcceptInvitation()
+ {
+ var github = Helper.GetAuthenticatedClient();
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
+
+ Assert.Equal(context.RepositoryOwner, response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+
+ // Accept the invitation
+ var accepted = await github.Repository.Invitation.Accept(response.Id);
+
+ Assert.True(accepted);
+ }
+ }
+ }
+
+ public class TheDeclineMethod
+ {
+ [IntegrationTest]
+ public async Task CanDeclineInvitation()
+ {
+ var github = Helper.GetAuthenticatedClient();
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
+
+ Assert.Equal(context.RepositoryOwner, response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+
+ // Decline the invitation
+ var declined = await github.Repository.Invitation.Decline(response.Id);
+
+ Assert.True(declined);
+ }
+ }
+ }
+
+ public class TheDeleteMethod
+ {
+ [IntegrationTest]
+ public async Task CanDeleteInvitation()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
+
+ Assert.Equal(context.RepositoryOwner, response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+
+ var delete = await github.Repository.Invitation.Delete(response.Repository.Id, response.Id);
+
+ Assert.True(delete);
+ }
+ }
+ }
+
+ public class TheUpdateMethod
+ {
+ [IntegrationTest]
+ public async Task CanUpdateInvitation()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
+ {
+ var fixture = github.Repository.Collaborator;
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ // invite a collaborator
+ var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
+
+ Assert.Equal(context.RepositoryOwner, response.Invitee.Login);
+ Assert.Equal(InvitationPermissionType.Write, response.Permissions);
+
+ var updatedInvitation = new InvitationUpdate(InvitationPermissionType.Admin);
+
+ var update = await github.Repository.Invitation.Edit(response.Repository.Id, response.Id, updatedInvitation);
+
+ Assert.Equal(updatedInvitation.Permissions, update.Permissions);
+ Assert.Equal(response.Id, update.Id);
+ Assert.Equal(response.Repository.Id, update.Repository.Id);
+ Assert.Equal(response.Invitee.Login, update.Invitee.Login);
+ Assert.Equal(response.Inviter.Login, update.Inviter.Login);
+ }
+ }
+ }
+}
+
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index a2c7d73ad7..4681be2473 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -109,6 +109,7 @@
+
diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs
index 42bb95eb24..3fb20b53ee 100644
--- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs
+++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs
@@ -229,6 +229,36 @@ public async Task EnsuresNonNullArguments()
}
}
+ public class TheInviteMethod
+ {
+ [Fact]
+ public void RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepoCollaboratorsClient(connection);
+
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ client.Invite("owner", "test", "user1", permission);
+ connection.Received().Put(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators/user1"), Arg.Is(permission), Arg.Any(), Arg.Is("application/vnd.github.swamp-thing-preview+json"));
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var client = new RepoCollaboratorsClient(Substitute.For());
+ var permission = new CollaboratorRequest(Permission.Push);
+
+ await Assert.ThrowsAsync(() => client.Invite(null, "test", "user1", permission));
+ await Assert.ThrowsAsync(() => client.Invite("", "test", "user1", permission));
+ await Assert.ThrowsAsync(() => client.Invite("owner", null, "user1", permission));
+ await Assert.ThrowsAsync(() => client.Invite("owner", "", "user1", permission));
+ await Assert.ThrowsAsync(() => client.Invite("owner", "test", "", permission));
+ await Assert.ThrowsAsync(() => client.Invite("owner", "test", null, permission));
+ await Assert.ThrowsAsync(() => client.Invite("owner", "test", "user1", null));
+ }
+ }
+
public class TheDeleteMethod
{
[Fact]
@@ -260,8 +290,8 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.Delete("owner", null, "user1"));
await Assert.ThrowsAsync(() => client.Delete("owner", "test", null));
await Assert.ThrowsAsync(() => client.Delete(1, null));
-
- await Assert.ThrowsAsync(() => client.Delete("", "test", "user1"));;
+
+ await Assert.ThrowsAsync(() => client.Delete("", "test", "user1")); ;
await Assert.ThrowsAsync(() => client.Delete("owner", "", "user1"));
await Assert.ThrowsAsync(() => client.Delete("owner", "test", ""));
await Assert.ThrowsAsync(() => client.Delete(1, ""));
diff --git a/Octokit.Tests/Clients/RepositoryInvitationsClientTests.cs b/Octokit.Tests/Clients/RepositoryInvitationsClientTests.cs
new file mode 100644
index 0000000000..374ce74826
--- /dev/null
+++ b/Octokit.Tests/Clients/RepositoryInvitationsClientTests.cs
@@ -0,0 +1,112 @@
+using NSubstitute;
+using Octokit;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+public class RepositoryInvitationsClientTests
+{
+ public class TheCtor
+ {
+ [Fact]
+ public void EnsuresNonNullArguments()
+ {
+ Assert.Throws(() => new RepositoryInvitationsClient(null));
+ }
+ }
+
+ public class TheGetAllForRepositoryMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryInvitationsClient(connection);
+
+ await client.GetAllForRepository(1);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/invitations"), "application/vnd.github.swamp-thing-preview+json");
+ }
+ }
+
+ public class TheGetAllForCurrentMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryInvitationsClient(connection);
+
+ await client.GetAllForCurrent();
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/repository_invitations"), "application/vnd.github.swamp-thing-preview+json");
+ }
+ }
+
+ public class TheAcceptMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryInvitationsClient(connection);
+
+ await client.Accept(1);
+
+ connection.Connection.Received().Patch(Arg.Is(u => u.ToString() == "user/repository_invitations/1"), "application/vnd.github.swamp-thing-preview+json");
+ }
+ }
+
+ public class TheDeclineMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryInvitationsClient(connection);
+
+ await client.Decline(1);
+
+ connection.Connection.Received().Delete(Arg.Is(u => u.ToString() == "user/repository_invitations/1"), Arg.Any
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 1fba6249a5..2c472d67d9 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -490,6 +490,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index 0bdf885b25..16c0e17c21 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -486,6 +486,11 @@
+
+
+
+
+
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index 138d85c764..f28e8a25ac 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -476,6 +476,11 @@
+
+
+
+
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index a19cc40a60..d807f7c109 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -483,6 +483,11 @@
+
+
+
+
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index a27d92848d..4adbffc62a 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -62,6 +62,7 @@
+
@@ -101,6 +102,7 @@
+
@@ -132,6 +134,8 @@
+
+
@@ -203,6 +207,7 @@
+