diff --git a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs
index 1097771f..4c80d17f 100644
--- a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs
+++ b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs
@@ -363,5 +363,28 @@ namespace Octokit.Reactive
/// Options to change API behaviour
///
IObservable GetAllFailedInvitations(string org, ApiOptions options);
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// Thrown when a general API error occurs.
+ ///
+ IObservable GetAllOrganizationMembershipsForCurrent();
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// Thrown when a general API error occurs.
+ /// Options to change API behaviour
+ ///
+ IObservable GetAllOrganizationMembershipsForCurrent(ApiOptions options);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs
index 1a1b5473..f7616aac 100644
--- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs
+++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs
@@ -506,5 +506,34 @@ namespace Octokit.Reactive
return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationFailedInvitations(org), null, options);
}
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// Thrown when a general API error occurs.
+ ///
+ public IObservable GetAllOrganizationMembershipsForCurrent()
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.UserOrganizationMemberships());
+ }
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// Thrown when a general API error occurs.
+ /// Options to change API behaviour
+ ///
+ public IObservable GetAllOrganizationMembershipsForCurrent(ApiOptions options)
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.UserOrganizationMemberships(), options);
+ }
}
}
diff --git a/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs
index 5e8dc01c..16f0f8cf 100644
--- a/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs
@@ -293,5 +293,37 @@ namespace Octokit.Tests.Integration.Clients
Assert.Empty(pendingInvitations);
}
}
+
+ public class TheGetAllOrganizationMembershipsForCurrentMethod
+ {
+ private IGitHubClient _gitHub;
+
+ public TheGetAllOrganizationMembershipsForCurrentMethod()
+ {
+ _gitHub = Helper.GetAuthenticatedClient();
+ }
+
+ [OrganizationTest]
+ public async Task ReturnsMemberships()
+ {
+ var memberships = await _gitHub.Organization.Member.GetAllOrganizationMembershipsForCurrent();
+ Assert.NotEmpty(memberships);
+ }
+
+ [OrganizationTest]
+ public async Task ReturnsCorrectCountOfMembersWithoutStart()
+ {
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1
+ };
+
+ var memberships = await _gitHub.Organization.Member.GetAllOrganizationMembershipsForCurrent(options);
+
+ Assert.Equal(1, memberships.Count);
+ }
+
+ }
}
}
diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs
index 328db251..222e10e5 100644
--- a/Octokit/Clients/IOrganizationMembersClient.cs
+++ b/Octokit/Clients/IOrganizationMembersClient.cs
@@ -369,5 +369,29 @@ namespace Octokit
/// Options to change API behaviour
///
Task> GetAllFailedInvitations(string org, ApiOptions options);
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// Thrown when a general API error occurs.
+ /// A list of the current user's s.
+ Task> GetAllOrganizationMembershipsForCurrent();
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// Thrown when a general API error occurs.
+ /// Options to change API behaviour
+ /// A list of the current user's s.
+ Task> GetAllOrganizationMembershipsForCurrent(ApiOptions options);
+
}
}
diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs
index d9f9d4fa..2e2de872 100644
--- a/Octokit/Clients/OrganizationMembersClient.cs
+++ b/Octokit/Clients/OrganizationMembersClient.cs
@@ -603,5 +603,29 @@ namespace Octokit
return ApiConnection.GetAll(ApiUrls.OrganizationFailedInvitations(org), null, options);
}
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ /// Thrown when a general API error occurs.
+ /// A list of the current user's s.
+ [ManualRoute("GET", "/user/memberships/orgs")]
+ public Task> GetAllOrganizationMembershipsForCurrent()
+ {
+ return ApiConnection.GetAll(ApiUrls.UserOrganizationMemberships());
+ }
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ /// Thrown when a general API error occurs.
+ /// Options to change API behaviour
+ /// A list of the current user's s.
+ [ManualRoute("GET", "/user/memberships/orgs")]
+ public Task> GetAllOrganizationMembershipsForCurrent(ApiOptions options)
+ {
+ return ApiConnection.GetAll(ApiUrls.UserOrganizationMemberships(), options);
+ }
+
}
}
diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs
index 82621ada..9b1a0727 100644
--- a/Octokit/Helpers/ApiUrls.cs
+++ b/Octokit/Helpers/ApiUrls.cs
@@ -143,6 +143,15 @@ namespace Octokit
{
return "user/orgs".FormatUri();
}
+
+ ///
+ /// Returns the that returns all of the organization memberships for the currently logged in user.
+ ///
+ ///
+ public static Uri UserOrganizationMemberships()
+ {
+ return "user/memberships/orgs".FormatUri();
+ }
///
/// Returns the that returns all of the organizations for the specified login.